Made command names more generic.

This commit is contained in:
Jeremy Fincher 2003-10-21 05:19:54 +00:00
parent 1037ade8cb
commit 48737f2085
4 changed files with 44 additions and 43 deletions

View File

@ -296,7 +296,7 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
else:
irc.error(msg, conf.replyNoCapability % capability)
def randomfactoid(self, irc, msg, args):
def random(self, irc, msg, args):
"""[<channel>]
Returns a random factoid from the database for <channel>. <channel>
@ -318,7 +318,7 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
else:
irc.error(msg, 'I couldn\'t find a factoid.')
def factoidinfo(self, irc, msg, args):
def info(self, irc, msg, args):
"""[<channel>] <key>
Gives information about the factoid(s) associated with <key>.
@ -351,7 +351,7 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
irc.reply(msg, s)
_sqlTrans = string.maketrans('*?', '%_')
def searchfactoids(self, irc, msg, args):
def search(self, irc, msg, args):
"""[<channel>] [--{regexp,exact}=<value>] [<glob>]
Searches the keyspace for keys matching <glob>. If --regexp is given,

View File

@ -75,7 +75,7 @@ class Quotes(plugins.ChannelDBHandler, callbacks.Privmsg):
db.commit()
return db
def addquote(self, irc, msg, args):
def add(self, irc, msg, args):
"""[<channel>] <quote>
Adds <quote> to the quotes database for <channel>. <channel> is only
@ -98,7 +98,7 @@ class Quotes(plugins.ChannelDBHandler, callbacks.Privmsg):
quoteid = cursor.fetchone()[0]
irc.reply(msg, '%s (Quote #%s added)' % (conf.replySuccess, quoteid))
def numquotes(self, irc, msg, args):
def num(self, irc, msg, args):
"""[<channel>]
Returns the numbers of quotes in the quote database for <channel>.
@ -191,7 +191,7 @@ class Quotes(plugins.ChannelDBHandler, callbacks.Privmsg):
irc.reply(msg, utils.commaAndify(idsWithSnippets))
### FIXME: we need to remove those predicates from the database.
def randomquote(self, irc, msg, args):
def random(self, irc, msg, args):
"""[<channel>]
Returns a random quote from <channel>. <channel> is only necessary if
@ -209,7 +209,7 @@ class Quotes(plugins.ChannelDBHandler, callbacks.Privmsg):
(id,) = cursor.fetchone()
self.quote(irc, msg, [channel, '--id', str(id)])
def quoteinfo(self, irc, msg, args):
def info(self, irc, msg, args):
"""[<channel>] <id>
Returns the metadata about the quote <id> in the quotes
@ -230,7 +230,7 @@ class Quotes(plugins.ChannelDBHandler, callbacks.Privmsg):
else:
irc.error(msg, 'There isn\'t a quote with that id.')
def removequote(self, irc, msg, args):
def remove(self, irc, msg, args):
"""[<channel>] <id>
Removes quote <id> from the quotes database for <channel>. <channel>

View File

@ -40,13 +40,13 @@ if sqlite is not None:
class FactoidsTestCase(ChannelPluginTestCase, PluginDocumentation):
plugins = ('Factoids',)
def testRandomfactoid(self):
self.assertError('randomfactoid')
self.assertError('random')
self.assertNotError('learn jemfinch as my primary author')
self.assertRegexp('randomfactoid', 'primary author')
self.assertRegexp('random', 'primary author')
def testLearn(self):
self.assertNotError('learn jemfinch as my primary author')
self.assertNotError('factoidinfo jemfinch')
self.assertNotError('info jemfinch')
self.assertRegexp('whatis jemfinch', 'my primary author')
self.assertRegexp('whatis JEMFINCH', 'my primary author')
self.assertRegexp('whatis JEMFINCH 1', 'my primary author')
@ -60,10 +60,10 @@ if sqlite is not None:
self.assertNotError('forget jemfinch 2')
self.assertNotError('forget jemfinch 1')
self.assertError('whatis jemfinch')
self.assertError('factoidinfo jemfinch')
self.assertError('info jemfinch')
self.assertNotError('learn foo bar as baz')
self.assertNotError('factoidinfo foo bar')
self.assertNotError('info foo bar')
self.assertRegexp('whatis foo bar', 'baz')
self.assertNotError('learn foo bar as quux')
self.assertRegexp('whatis foo bar', '.*baz.*quux')
@ -71,7 +71,7 @@ if sqlite is not None:
self.assertNotError('forget foo bar 2')
self.assertNotError('forget foo bar 1')
self.assertError('whatis foo bar')
self.assertError('factoidinfo foo bar')
self.assertError('info foo bar')
self.assertRegexp('learn foo bar baz', '^learn') # No 'as'
self.assertRegexp('learn foo bar', '^learn') # No 'as'
@ -82,25 +82,25 @@ if sqlite is not None:
self.assertNotError('learn inkedmn as another of my developers')
self.assertNotError('learn jamessan as a developer of much python')
self.assertNotError('learn bwp as author of my weather command')
self.assertRegexp('searchfactoids --regexp /.w./', 'bwp')
self.assertRegexp('searchfactoids --regexp /^.+i/',
self.assertRegexp('search --regexp /.w./', 'bwp')
self.assertRegexp('search --regexp /^.+i/',
'jemfinch.*strike')
self.assertNotRegexp('searchfactoids --regexp /^.+i/', 'inkedmn')
self.assertRegexp('searchfactoids --regexp /^j/',
self.assertNotRegexp('search --regexp /^.+i/', 'inkedmn')
self.assertRegexp('search --regexp /^j/',
'jemfinch.*jamessan')
self.assertRegexp('searchfactoids j*', 'jemfinch.*jamessan')
self.assertRegexp('searchfactoids --exact ke',
self.assertRegexp('search j*', 'jemfinch.*jamessan')
self.assertRegexp('search --exact ke',
'inkedmn.*strike|strike.*inkedmn')
self.assertRegexp('searchfactoids *ke*',
self.assertRegexp('search *ke*',
'inkedmn.*strike|strike.*inkedmn')
def testNotZeroIndexed(self):
self.assertNotError('learn foo as bar')
self.assertNotRegexp('factoidinfo foo', '#0')
self.assertNotRegexp('info foo', '#0')
self.assertNotRegexp('whatis foo', '#0')
self.assertNotError('learn foo as baz')
self.assertNotRegexp('factoidinfo foo', '#0')
self.assertNotRegexp('info foo', '#0')
self.assertNotRegexp('whatis foo', '#0')

View File

@ -40,35 +40,36 @@ if sqlite is not None:
class QuotesTestCase(PluginTestCase, PluginDocumentation):
plugins = ('Quotes',)
def test(self):
self.assertRegexp('numquotes #foo', '0')
self.assertRegexp('addquote #foo foo', 'Quote #1 added')
self.assertRegexp('numquotes #foo', '1')
self.assertRegexp('num #foo', '0')
self.assertRegexp('add #foo foo', 'Quote #1 added')
self.assertRegexp('num #foo', '1')
self.assertResponse('quote #foo --id 1', '#1: foo')
self.assertResponse('quote #foo 1', '#1: foo')
self.assertRegexp('addquote #foo bar','Quote #2 added')
self.assertRegexp('add #foo bar','Quote #2 added')
self.assertResponse('quote #foo 2', '#2: bar')
self.assertResponse('quote #foo --id 2', '#2: bar')
self.assertRegexp('addquote #foo baz','Quote #3 added')
self.assertRegexp('numquotes #foo', '3')
self.assertRegexp('add #foo baz','Quote #3 added')
self.assertRegexp('num #foo', '3')
self.assertResponse('quote #foo 3', '#3: baz')
self.assertRegexp('quote #foo --regexp m/ba/', 'bar.*baz')
self.assertRegexp('quote #foo --regexp ba', 'bar.*baz')
self.assertRegexp('quote #foo --with bar', '#2: bar')
self.assertRegexp('quote #foo bar', '#2: bar')
self.assertNotError('quoteinfo #foo 1')
self.assertNotError('randomquote #foo')
self.assertError('removequote #foo 4')
self.assertError('quoteinfo #foo 4')
self.assertNotError('removequote #foo 3')
self.assertRegexp('numquotes #foo', '2')
self.assertNotError('removequote #foo 1')
self.assertError('quoteinfo #foo 3')
self.assertError('quoteinfo #foo 1')
self.assertRegexp('randomquote #foo', '#2')
self.assertError('removequote #foo 3')
self.assertNotError('removequote #foo 2')
self.assertRegexp('numquotes #foo', '0')
self.assertError('randomquote #foo')
self.assertNotError('info #foo 1')
self.assertNotError('random #foo')
self.assertError('remove #foo 4')
self.assertError('info #foo 4')
self.assertNotError('quote #foo 3')
self.assertNotError('remove #foo 3')
self.assertRegexp('num #foo', '2')
self.assertNotError('remove #foo 1')
self.assertError('info #foo 3')
self.assertError('info #foo 1')
self.assertRegexp('random #foo', '#2')
self.assertError('remove #foo 3')
self.assertNotError('remove #foo 2')
self.assertRegexp('num #foo', '0')
self.assertError('random #foo')