From 7a418a1bf6dc9ee57c354d168b13650c749a7c6e Mon Sep 17 00:00:00 2001 From: James Vega Date: Tue, 2 Dec 2003 19:00:11 +0000 Subject: [PATCH] Damn, it feels good to be a ChannelDB --- plugins/FunDB.py | 16 ++++++++++------ test/test_FunDB.py | 17 +++++++++++------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/plugins/FunDB.py b/plugins/FunDB.py index a2a7562bc..5a64ced73 100755 --- a/plugins/FunDB.py +++ b/plugins/FunDB.py @@ -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): """[] [] @@ -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): """[] [] [for ] @@ -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): """[] [] [for ] @@ -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 diff --git a/test/test_FunDB.py b/test/test_FunDB.py index 7e36ebc0d..a20f5583e 100644 --- a/test/test_FunDB.py +++ b/test/test_FunDB.py @@ -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')