mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
It's handy to translate the user id to a name.
This commit is contained in:
parent
91c440ad09
commit
edecd51fc1
@ -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)
|
||||
|
@ -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')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user