mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +01:00
It's handy to translate the user id to a name.
This commit is contained in:
parent
91c440ad09
commit
edecd51fc1
@ -133,6 +133,12 @@ class FunDB(callbacks.Privmsg):
|
|||||||
def die(self):
|
def die(self):
|
||||||
self.db.close()
|
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):
|
def _validType(self, irc, type, error=True):
|
||||||
if type not in self._types:
|
if type not in self._types:
|
||||||
if error:
|
if error:
|
||||||
@ -287,7 +293,8 @@ class FunDB(callbacks.Privmsg):
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
x = self.db.get(channel, type, id)
|
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)
|
irc.reply(reply)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error('There is no %s with that id.' % type)
|
irc.error('There is no %s with that id.' % type)
|
||||||
|
@ -156,7 +156,7 @@ class TestFunDB(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
|
|
||||||
def testInfo(self):
|
def testInfo(self):
|
||||||
self.assertNotError('add praise $who')
|
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.assertNotError('remove praise 1')
|
||||||
self.assertError('info fake 1')
|
self.assertError('info fake 1')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user