It's handy to translate the user id to a name.

This commit is contained in:
James Vega 2004-08-23 19:23:01 +00:00
parent 91c440ad09
commit edecd51fc1
2 changed files with 10 additions and 3 deletions

View File

@ -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)

View File

@ -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')