mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-30 22:24:20 +01:00
Fix the @seen --user bug and add a test to keep it fixed
This commit is contained in:
parent
8f1329b20e
commit
9d8d47bbe7
@ -349,6 +349,7 @@ class ChannelDB(callbacks.Privmsg,
|
|||||||
if ('--user', '') in optlist:
|
if ('--user', '') in optlist:
|
||||||
table = 'user_stats'
|
table = 'user_stats'
|
||||||
criterion = 'user_id=%s'
|
criterion = 'user_id=%s'
|
||||||
|
name = ircdb.users.getUserId(name)
|
||||||
if not ircdb.users.hasUser(name):
|
if not ircdb.users.hasUser(name):
|
||||||
try:
|
try:
|
||||||
hostmask = irc.state.nickToHostmask(name)
|
hostmask = irc.state.nickToHostmask(name)
|
||||||
@ -367,6 +368,8 @@ class ChannelDB(callbacks.Privmsg,
|
|||||||
else:
|
else:
|
||||||
(seen, m) = cursor.fetchone()
|
(seen, m) = cursor.fetchone()
|
||||||
seen = int(seen)
|
seen = int(seen)
|
||||||
|
if isinstance(name, int):
|
||||||
|
name = ircdb.users.getUser(int(name)).name
|
||||||
s = '%s was last seen here %s ago saying %r' % \
|
s = '%s was last seen here %s ago saying %r' % \
|
||||||
(name, utils.timeElapsed(time.time() - seen), m)
|
(name, utils.timeElapsed(time.time() - seen), m)
|
||||||
irc.reply(msg, s)
|
irc.reply(msg, s)
|
||||||
|
@ -76,7 +76,7 @@ if sqlite is not None:
|
|||||||
self.assertEqual(m1.args[1], m2.args[1])
|
self.assertEqual(m1.args[1], m2.args[1])
|
||||||
|
|
||||||
def testNoKeyErrorEscapeFromSeen(self):
|
def testNoKeyErrorEscapeFromSeen(self):
|
||||||
self.assertRegexp('seen asldfkjasdlfkj', 'I have not seen')
|
self.assertRegexp('seen asldfkjasdlfkj', '^I have not seen')
|
||||||
self.assertNotRegexp('seen asldfkjasdlfkj', 'KeyError')
|
self.assertNotRegexp('seen asldfkjasdlfkj', 'KeyError')
|
||||||
|
|
||||||
def testNoKeyErrorStats(self):
|
def testNoKeyErrorStats(self):
|
||||||
@ -86,6 +86,8 @@ if sqlite is not None:
|
|||||||
self.assertNotError('list')
|
self.assertNotError('list')
|
||||||
self.assertNotError('seen %s' % self.nick)
|
self.assertNotError('seen %s' % self.nick)
|
||||||
self.assertNotError('seen %s' % self.nick.upper())
|
self.assertNotError('seen %s' % self.nick.upper())
|
||||||
|
self.assertRegexp('seen --user %s' % self.nick,
|
||||||
|
'^%s was last seen' % self.nick)
|
||||||
|
|
||||||
def testWordStatsNoArgs(self):
|
def testWordStatsNoArgs(self):
|
||||||
self.assertResponse('wordstats', 'I am not currently keeping any '
|
self.assertResponse('wordstats', 'I am not currently keeping any '
|
||||||
|
Loading…
Reference in New Issue
Block a user