Converted to use more generic command names.

This commit is contained in:
Jeremy Fincher 2003-10-21 05:32:57 +00:00
parent c4b838894d
commit 0349f7b3b1
2 changed files with 20 additions and 20 deletions

View File

@ -98,7 +98,7 @@ class News(plugins.ChannelDBHandler, callbacks.Privmsg):
db.commit() db.commit()
return db return db
def addnews(self, irc, msg, args, channel): def add(self, irc, msg, args, channel):
"""[<channel>] <expires> <subject>: <text> """[<channel>] <expires> <subject>: <text>
Adds a given news item of <text> to a channel with the given <subject>. Adds a given news item of <text> to a channel with the given <subject>.
@ -131,7 +131,7 @@ class News(plugins.ChannelDBHandler, callbacks.Privmsg):
subject[:-1], text, added_at, expires, name) subject[:-1], text, added_at, expires, name)
db.commit() db.commit()
irc.reply(msg, conf.replySuccess) irc.reply(msg, conf.replySuccess)
addnews = privmsgs.checkChannelCapability(addnews, 'news') add = privmsgs.checkChannelCapability(add, 'news')
def _readnews(self, irc, msg, args): def _readnews(self, irc, msg, args):
"""[<channel>] <number> """[<channel>] <number>
@ -190,7 +190,7 @@ class News(plugins.ChannelDBHandler, callbacks.Privmsg):
s = 'News for %s: %s' % (channel, '; '.join(items)) s = 'News for %s: %s' % (channel, '; '.join(items))
irc.reply(msg, s) irc.reply(msg, s)
def removenews(self, irc, msg, args, channel): def remove(self, irc, msg, args, channel):
"""[<channel>] <number> """[<channel>] <number>
Removes the news item with id <number> from <channel>. <channel> is Removes the news item with id <number> from <channel>. <channel> is
@ -206,9 +206,9 @@ class News(plugins.ChannelDBHandler, callbacks.Privmsg):
cursor.execute("""DELETE FROM news WHERE news.id = %s""", id) cursor.execute("""DELETE FROM news WHERE news.id = %s""", id)
db.commit() db.commit()
irc.reply(msg, conf.replySuccess) irc.reply(msg, conf.replySuccess)
removenews = privmsgs.checkChannelCapability(removenews, 'news') remove = privmsgs.checkChannelCapability(remove, 'news')
def changenews(self, irc, msg, args, channel): def change(self, irc, msg, args, channel):
"""[<channel>] <number> <regexp> """[<channel>] <number> <regexp>
Changes the news item with id <number> from <channel> according to the Changes the news item with id <number> from <channel> according to the
@ -235,9 +235,9 @@ class News(plugins.ChannelDBHandler, callbacks.Privmsg):
cursor.execute("""UPDATE news SET subject=%s, item=%s WHERE id=%s""", cursor.execute("""UPDATE news SET subject=%s, item=%s WHERE id=%s""",
newSubject, newItem, id) newSubject, newItem, id)
irc.reply(msg, conf.replySuccess) irc.reply(msg, conf.replySuccess)
changenews = privmsgs.checkChannelCapability(changenews, 'news') change = privmsgs.checkChannelCapability(change, 'news')
def oldnews(self, irc, msg, args): def old(self, irc, msg, args):
"""[<channel>] [<number>] """[<channel>] [<number>]
Returns the old news item for <channel> with id <number>. If no number Returns the old news item for <channel> with id <number>. If no number

View File

@ -45,11 +45,11 @@ if sqlite is not None:
class NewsTestCase(ChannelPluginTestCase): class NewsTestCase(ChannelPluginTestCase):
plugins = ('News',) plugins = ('News',)
def testAddnews(self): def testAddnews(self):
self.assertNotError('addnews 0 subject: foo') self.assertNotError('add 0 subject: foo')
self.assertRegexp('news', 'subject') self.assertRegexp('news', 'subject')
self.assertNotError('addnews 0 subject2: foo2') self.assertNotError('add 0 subject2: foo2')
self.assertRegexp('news', 'subject.*subject2') self.assertRegexp('news', 'subject.*subject2')
self.assertNotError('addnews 5 subject3: foo3') self.assertNotError('add 5 subject3: foo3')
self.assertRegexp('news', 'subject3') self.assertRegexp('news', 'subject3')
print print
print 'Sleeping to expire the news item (testAddnews)' print 'Sleeping to expire the news item (testAddnews)'
@ -62,29 +62,29 @@ if sqlite is not None:
self.assertRegexp('news', 'no news') self.assertRegexp('news', 'no news')
self.assertRegexp('news #channel', 'no news') self.assertRegexp('news #channel', 'no news')
# Now we'll add news and make sure listnews doesn't fail # Now we'll add news and make sure listnews doesn't fail
self.assertNotError('addnews #channel 0 subject: foo') self.assertNotError('add #channel 0 subject: foo')
self.assertNotError('news #channel') self.assertNotError('news #channel')
self.assertNotError('addnews 0 subject: foo') self.assertNotError('add 0 subject: foo')
self.assertRegexp('news', '#1') self.assertRegexp('news', '#1')
self.assertNotError('news 1') self.assertNotError('news 1')
def testChangenews(self): def testChangenews(self):
self.assertNotError('addnews 0 Foo: bar') self.assertNotError('add 0 Foo: bar')
self.assertNotError('changenews 1 s/bar/baz/') self.assertNotError('change 1 s/bar/baz/')
self.assertNotRegexp('news 1', 'bar') self.assertNotRegexp('news 1', 'bar')
self.assertRegexp('news 1', 'baz') self.assertRegexp('news 1', 'baz')
def testOldnews(self): def testOldnews(self):
self.assertError('oldnews') self.assertError('old')
self.assertNotError('addnews 0 a: b') self.assertNotError('add 0 a: b')
self.assertError('oldnews') self.assertError('old')
self.assertNotError('addnews 5 foo: bar') self.assertNotError('add 5 foo: bar')
self.assertError('oldnews') self.assertError('old')
print print
print 'Sleeping to expire the news item (testOldnews)' print 'Sleeping to expire the news item (testOldnews)'
time.sleep(6) time.sleep(6)
print 'Done sleeping.' print 'Done sleeping.'
self.assertNotError('oldnews') self.assertNotError('old')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: