mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-02 15:44:06 +01:00
Damn, it feels good to be a ChannelDB
This commit is contained in:
parent
949ea7aa2b
commit
7a418a1bf6
@ -314,8 +314,8 @@ class FunDB(callbacks.Privmsg, plugins.Configurable, plugins.ChannelDBHandler):
|
||||
reply = '%s #%s: Created by %s.' % (table, id, add)
|
||||
irc.reply(msg, reply)
|
||||
|
||||
def _formatResponse(self, s, id):
|
||||
if self.configurables.get('show-ids'):
|
||||
def _formatResponse(self, s, id, showids):
|
||||
if showids:
|
||||
return '%s (#%s)' % (s, id)
|
||||
else:
|
||||
return s
|
||||
@ -343,7 +343,8 @@ class FunDB(callbacks.Privmsg, plugins.Configurable, plugins.ChannelDBHandler):
|
||||
nick = re.sub(r'\bme\b', msg.nick, nick)
|
||||
nick = re.sub(r'\bmy\b', '%s\'s' % msg.nick, nick)
|
||||
insult = insult.replace('$who', nick)
|
||||
irc.reply(msg, self._formatResponse(insult, id), to=nick)
|
||||
showid = self.configurables.get('show-ids', channel)
|
||||
irc.reply(msg, self._formatResponse(insult, id, showid), to=nick)
|
||||
|
||||
def excuse(self, irc, msg, args):
|
||||
"""[<channel>] [<id>]
|
||||
@ -376,7 +377,8 @@ class FunDB(callbacks.Privmsg, plugins.Configurable, plugins.ChannelDBHandler):
|
||||
irc.error(msg, 'There are currently no available excuses.')
|
||||
else:
|
||||
(id, excuse) = cursor.fetchone()
|
||||
irc.reply(msg, self._formatResponse(excuse, id))
|
||||
showid = self.configurables.get('show-ids', channel)
|
||||
irc.reply(msg, self._formatResponse(excuse, id, showid))
|
||||
|
||||
def lart(self, irc, msg, args):
|
||||
"""[<channel>] [<id>] <text> [for <reason>]
|
||||
@ -429,7 +431,8 @@ class FunDB(callbacks.Privmsg, plugins.Configurable, plugins.ChannelDBHandler):
|
||||
if reason:
|
||||
s = '%s for %s' % (s, reason)
|
||||
s = s.rstrip('.')
|
||||
irc.reply(msg, self._formatResponse(s, id), action=True)
|
||||
showid = self.configurables.get('show-ids', channel)
|
||||
irc.reply(msg, self._formatResponse(s, id, showid), action=True)
|
||||
|
||||
def praise(self, irc, msg, args):
|
||||
"""[<channel>] [<id>] <text> [for <reason>]
|
||||
@ -481,7 +484,8 @@ class FunDB(callbacks.Privmsg, plugins.Configurable, plugins.ChannelDBHandler):
|
||||
if reason:
|
||||
s = '%s for %s' % (s, reason)
|
||||
s = s.rstrip('.')
|
||||
irc.reply(msg, self._formatResponse(s, id), action=True)
|
||||
showid = self.configurables.get('show-ids', channel)
|
||||
irc.reply(msg, self._formatResponse(s, id, showid), action=True)
|
||||
|
||||
Class = FunDB
|
||||
|
||||
|
@ -39,14 +39,19 @@ except ImportError:
|
||||
sqlite = None
|
||||
|
||||
if sqlite is not None:
|
||||
class TestFunDB(PluginTestCase, PluginDocumentation):
|
||||
class TestFunDB(ChannelPluginTestCase, PluginDocumentation):
|
||||
plugins = ('FunDB','User','Utilities')
|
||||
def setUp(self):
|
||||
PluginTestCase.setUp(self)
|
||||
ChannelPluginTestCase.setUp(self)
|
||||
self.prefix = 't3st!bar@foo.com'
|
||||
self.assertNotError('register t3st moo')
|
||||
ircdb.users.getUser('t3st').addCapability('admin')
|
||||
self.assertNotError('fundb config show-ids on')
|
||||
self.nick = 't3st'
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.irc.nick,
|
||||
'register t3st moo',
|
||||
prefix=self.prefix))
|
||||
_ = self.irc.takeMsg()
|
||||
#ircdb.users.getUser('t3st').addCapability('admin')
|
||||
ircdb.users.getUser('t3st').addCapability('#test.op')
|
||||
self.assertNotError('fundb config #test show-ids on')
|
||||
|
||||
def testAdd(self):
|
||||
self.assertError('add l4rt foo')
|
||||
@ -129,7 +134,7 @@ if sqlite is not None:
|
||||
def testInsult(self):
|
||||
self.assertNotError('add insult Fatty McFatty')
|
||||
self.assertResponse('insult jemfinch',
|
||||
'Fatty McFatty (#1)')
|
||||
'jemfinch: Fatty McFatty (#1)')
|
||||
self.assertRegexp('num insult', r'currently 1')
|
||||
self.assertNotError('remove insult 1')
|
||||
self.assertRegexp('num insult', 'currently 0')
|
||||
|
Loading…
Reference in New Issue
Block a user