From edecd51fc17e4e8515fa5b271e5c60249d53dea7 Mon Sep 17 00:00:00 2001 From: James Vega Date: Mon, 23 Aug 2004 19:23:01 +0000 Subject: [PATCH] It's handy to translate the user id to a name. --- plugins/FunDB.py | 11 +++++++++-- test/test_FunDB.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/FunDB.py b/plugins/FunDB.py index eab73d531..9334e372d 100755 --- a/plugins/FunDB.py +++ b/plugins/FunDB.py @@ -62,7 +62,7 @@ class DbiFunDBDB(object): 'by', 'text', ] - + def __init__(self): self.dbs = ircutils.IrcDict() self.filenames = sets.Set() @@ -133,6 +133,12 @@ class FunDB(callbacks.Privmsg): def die(self): self.db.close() + def _getBy(self, by): + try: + return ircdb.users.getUser(int(by)).name + except ValueError: + return by + def _validType(self, irc, type, error=True): if type not in self._types: if error: @@ -287,7 +293,8 @@ class FunDB(callbacks.Privmsg): return try: x = self.db.get(channel, type, id) - reply = '%s #%s: %r; Created by %s.' % (type, x.id, x.text, x.by) + reply = '%s #%s: %r; Created by %s.' % (type, x.id, x.text, + self._getBy(x.by)) irc.reply(reply) except KeyError: irc.error('There is no %s with that id.' % type) diff --git a/test/test_FunDB.py b/test/test_FunDB.py index bcb10f342..38bfcec06 100644 --- a/test/test_FunDB.py +++ b/test/test_FunDB.py @@ -156,7 +156,7 @@ class TestFunDB(ChannelPluginTestCase, PluginDocumentation): def testInfo(self): self.assertNotError('add praise $who') - self.assertRegexp('info praise 1', r'Created by') + self.assertRegexp('info praise 1', r'Created by [^\d]+') self.assertNotError('remove praise 1') self.assertError('info fake 1')