Damn, it feels good to be a ChannelDB

This commit is contained in:
James Vega 2003-12-02 19:00:11 +00:00
parent 949ea7aa2b
commit 7a418a1bf6
2 changed files with 21 additions and 12 deletions

View File

@ -314,8 +314,8 @@ class FunDB(callbacks.Privmsg, plugins.Configurable, plugins.ChannelDBHandler):
reply = '%s #%s: Created by %s.' % (table, id, add) reply = '%s #%s: Created by %s.' % (table, id, add)
irc.reply(msg, reply) irc.reply(msg, reply)
def _formatResponse(self, s, id): def _formatResponse(self, s, id, showids):
if self.configurables.get('show-ids'): if showids:
return '%s (#%s)' % (s, id) return '%s (#%s)' % (s, id)
else: else:
return s 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'\bme\b', msg.nick, nick)
nick = re.sub(r'\bmy\b', '%s\'s' % msg.nick, nick) nick = re.sub(r'\bmy\b', '%s\'s' % msg.nick, nick)
insult = insult.replace('$who', 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): def excuse(self, irc, msg, args):
"""[<channel>] [<id>] """[<channel>] [<id>]
@ -376,7 +377,8 @@ class FunDB(callbacks.Privmsg, plugins.Configurable, plugins.ChannelDBHandler):
irc.error(msg, 'There are currently no available excuses.') irc.error(msg, 'There are currently no available excuses.')
else: else:
(id, excuse) = cursor.fetchone() (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): def lart(self, irc, msg, args):
"""[<channel>] [<id>] <text> [for <reason>] """[<channel>] [<id>] <text> [for <reason>]
@ -429,7 +431,8 @@ class FunDB(callbacks.Privmsg, plugins.Configurable, plugins.ChannelDBHandler):
if reason: if reason:
s = '%s for %s' % (s, reason) s = '%s for %s' % (s, reason)
s = s.rstrip('.') 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): def praise(self, irc, msg, args):
"""[<channel>] [<id>] <text> [for <reason>] """[<channel>] [<id>] <text> [for <reason>]
@ -481,7 +484,8 @@ class FunDB(callbacks.Privmsg, plugins.Configurable, plugins.ChannelDBHandler):
if reason: if reason:
s = '%s for %s' % (s, reason) s = '%s for %s' % (s, reason)
s = s.rstrip('.') 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 Class = FunDB

View File

@ -39,14 +39,19 @@ except ImportError:
sqlite = None sqlite = None
if sqlite is not None: if sqlite is not None:
class TestFunDB(PluginTestCase, PluginDocumentation): class TestFunDB(ChannelPluginTestCase, PluginDocumentation):
plugins = ('FunDB','User','Utilities') plugins = ('FunDB','User','Utilities')
def setUp(self): def setUp(self):
PluginTestCase.setUp(self) ChannelPluginTestCase.setUp(self)
self.prefix = 't3st!bar@foo.com' self.prefix = 't3st!bar@foo.com'
self.assertNotError('register t3st moo') self.nick = 't3st'
ircdb.users.getUser('t3st').addCapability('admin') self.irc.feedMsg(ircmsgs.privmsg(self.irc.nick,
self.assertNotError('fundb config show-ids on') '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): def testAdd(self):
self.assertError('add l4rt foo') self.assertError('add l4rt foo')
@ -129,7 +134,7 @@ if sqlite is not None:
def testInsult(self): def testInsult(self):
self.assertNotError('add insult Fatty McFatty') self.assertNotError('add insult Fatty McFatty')
self.assertResponse('insult jemfinch', self.assertResponse('insult jemfinch',
'Fatty McFatty (#1)') 'jemfinch: Fatty McFatty (#1)')
self.assertRegexp('num insult', r'currently 1') self.assertRegexp('num insult', r'currently 1')
self.assertNotError('remove insult 1') self.assertNotError('remove insult 1')
self.assertRegexp('num insult', 'currently 0') self.assertRegexp('num insult', 'currently 0')