diff --git a/plugins/News.py b/plugins/News.py index 12db44187..7ca40fdc9 100644 --- a/plugins/News.py +++ b/plugins/News.py @@ -94,7 +94,7 @@ class News(callbacks.Privmsg, ChannelDBHandler): db.commit() return db - def addnews(self, irc, msg, args): + def addnews(self, irc, msg, args, channel): """[] : Adds a given news item of to a channel with the given . @@ -102,12 +102,6 @@ class News(callbacks.Privmsg, ChannelDBHandler): now. is only necessary if the message isn't sent in the channel itself. """ - channel = privmsgs.getChannel(msg, args) - # Check if they have the appropriate capability. - capability = ircdb.makeChannelCapability(channel, 'news') - if not ircdb.checkCapability(msg.prefix, capability): - irc.error(msg, conf.replyNoCapability % capability) - return # Parse out the args i = None for i, arg in enumerate(args): @@ -123,7 +117,7 @@ class News(callbacks.Privmsg, ChannelDBHandler): text = ' '.join(args[i:]) # Set the other stuff needed for the insert. if ircdb.users.hasUser(msg.prefix): - name = ircdb.users.getUserName(msg.prefix) + name = ircdb.users.getUser(msg.prefix).name else: name = msg.nick @@ -133,6 +127,7 @@ class News(callbacks.Privmsg, ChannelDBHandler): subject[:-1], text, added_at, expires, name) db.commit() irc.reply(msg, conf.replySuccess) + addnews = privmsgs.checkChannelCapability(addnews, 'news') def readnews(self, irc, msg, args): """[] diff --git a/test/test_News.py b/test/test_News.py index dda0a85d3..1a5efd52b 100644 --- a/test/test_News.py +++ b/test/test_News.py @@ -33,13 +33,20 @@ from test import * import utils -class NewsTestCase(PluginTestCase): +class NewsTestCase(ChannelPluginTestCase): plugins = ('News',) def testAddNews(self): - self.assertNotError('addnews 0 subject: foo') - self.assertNotError('addnews #somechannel subject: foo') + self.assertNotError('addnews #somechannel 0 subject: foo') + self.assertNotError('addnews 0 subject2: foo2') def testListNews(self): + # These should both fail first, as they will have nothing in the DB + self.assertError('listnews') + self.assertError('listnews #channel') + # Now we'll add news and make sure listnews doesn't fail + self.assertNotError('addnews #channel 0 subject: foo') + self.assertNotError('listnews #channel') + self.assertNotError('addnews 0 subject: foo') self.assertNotError('listnews') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: