mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
* Added a required per-channel news capability
* Fixed tests (syntax error, tabs/spaces) * Updated addnews to use new persistent userids
This commit is contained in:
parent
2682670fc6
commit
b71787b702
@ -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):
|
||||
"""[<channel>] <expires> <subject>: <text>
|
||||
|
||||
Adds a given news item of <text> to a channel with the given <subject>.
|
||||
@ -102,12 +102,6 @@ class News(callbacks.Privmsg, ChannelDBHandler):
|
||||
now. <channel> 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):
|
||||
"""[<channel>] <number>
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user