mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-03-29 19:06:49 +01:00
Updated Seen.seen to accept no arguments.
This commit is contained in:
parent
672b2e9df1
commit
a79bc26201
@ -1,3 +1,6 @@
|
|||||||
|
* Updated Seen.seen to accept no arguments and return the last
|
||||||
|
message spoken by anyone.
|
||||||
|
|
||||||
* Updated the Herald plugin to use the standard substitute until
|
* Updated the Herald plugin to use the standard substitute until
|
||||||
we get it updated to use commands as heralds instead of plain
|
we get it updated to use commands as heralds instead of plain
|
||||||
strings.
|
strings.
|
||||||
|
@ -78,6 +78,7 @@ class SeenDB(plugins.ChannelUserDB):
|
|||||||
def update(self, channel, nickOrId, saying):
|
def update(self, channel, nickOrId, saying):
|
||||||
seen = time.time()
|
seen = time.time()
|
||||||
self[channel, nickOrId] = (seen, saying)
|
self[channel, nickOrId] = (seen, saying)
|
||||||
|
self[channel, '<last>'] = (seen, saying)
|
||||||
|
|
||||||
def seen(self, channel, nickOrId):
|
def seen(self, channel, nickOrId):
|
||||||
return self[channel, nickOrId]
|
return self[channel, nickOrId]
|
||||||
@ -111,17 +112,19 @@ class Seen(callbacks.Privmsg):
|
|||||||
pass # Not in the database.
|
pass # Not in the database.
|
||||||
|
|
||||||
def seen(self, irc, msg, args):
|
def seen(self, irc, msg, args):
|
||||||
"""[<channel>] [--user] <name>
|
"""[<channel>] [--user] [<name>]
|
||||||
|
|
||||||
Returns the last time <name> was seen and what <name> was last seen
|
Returns the last time <name> was seen and what <name> was last seen
|
||||||
saying. --user will look for user <name> instead of using <name> as
|
saying. --user will look for user <name> instead of using <name> as
|
||||||
a nick (registered users, remember, can be recognized under any number
|
a nick (registered users, remember, can be recognized under any number
|
||||||
of nicks) <channel> is only necessary if the message isn't sent on the
|
of nicks) <channel> is only necessary if the message isn't sent on the
|
||||||
channel itself.
|
channel itself. If <name> is not specified, the last person that was
|
||||||
|
seen and their message will be returned.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
channel = privmsgs.getChannel(msg, args)
|
||||||
(optlist, rest) = getopt.getopt(args, '', ['user'])
|
(optlist, rest) = getopt.getopt(args, '', ['user'])
|
||||||
name = privmsgs.getArgs(rest)
|
name = privmsgs.getArgs(rest, required=0, optional=1)
|
||||||
|
if name:
|
||||||
nickOrId = name
|
nickOrId = name
|
||||||
if ('--user', '') in optlist:
|
if ('--user', '') in optlist:
|
||||||
try:
|
try:
|
||||||
@ -139,6 +142,13 @@ class Seen(callbacks.Privmsg):
|
|||||||
(name, utils.timeElapsed(time.time()-when), said))
|
(name, utils.timeElapsed(time.time()-when), said))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.reply('I have not seen %s.' % name)
|
irc.reply('I have not seen %s.' % name)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
(when, said) = self.db.seen(channel, '<last>')
|
||||||
|
irc.reply('Someone was last seen here %s ago saying: %s' %
|
||||||
|
(utils.timeElapsed(time.time()-when), said))
|
||||||
|
except KeyError:
|
||||||
|
irc.reply('I have never seen anyone.')
|
||||||
|
|
||||||
|
|
||||||
Class = Seen
|
Class = Seen
|
||||||
|
@ -51,6 +51,7 @@ class ChannelDBTestCase(ChannelPluginTestCase):
|
|||||||
self.assertNotRegexp('seen asldfkjasdlfkj', 'KeyError')
|
self.assertNotRegexp('seen asldfkjasdlfkj', 'KeyError')
|
||||||
|
|
||||||
def testSeen(self):
|
def testSeen(self):
|
||||||
|
self.assertNotError('seen')
|
||||||
self.assertNotError('list')
|
self.assertNotError('list')
|
||||||
self.assertNotError('seen %s' % self.nick)
|
self.assertNotError('seen %s' % self.nick)
|
||||||
m = self.assertNotError('seen %s' % self.nick.upper())
|
m = self.assertNotError('seen %s' % self.nick.upper())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user