Updated Seen.seen to accept no arguments.

This commit is contained in:
James Vega 2004-03-09 22:04:41 +00:00
parent 672b2e9df1
commit a79bc26201
3 changed files with 113 additions and 99 deletions

View File

@ -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
we get it updated to use commands as heralds instead of plain
strings.

View File

@ -78,6 +78,7 @@ class SeenDB(plugins.ChannelUserDB):
def update(self, channel, nickOrId, saying):
seen = time.time()
self[channel, nickOrId] = (seen, saying)
self[channel, '<last>'] = (seen, saying)
def seen(self, channel, nickOrId):
return self[channel, nickOrId]
@ -111,17 +112,19 @@ class Seen(callbacks.Privmsg):
pass # Not in the database.
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
saying. --user will look for user <name> instead of using <name> as
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
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)
(optlist, rest) = getopt.getopt(args, '', ['user'])
name = privmsgs.getArgs(rest)
name = privmsgs.getArgs(rest, required=0, optional=1)
if name:
nickOrId = name
if ('--user', '') in optlist:
try:
@ -139,6 +142,13 @@ class Seen(callbacks.Privmsg):
(name, utils.timeElapsed(time.time()-when), said))
except KeyError:
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

View File

@ -51,6 +51,7 @@ class ChannelDBTestCase(ChannelPluginTestCase):
self.assertNotRegexp('seen asldfkjasdlfkj', 'KeyError')
def testSeen(self):
self.assertNotError('seen')
self.assertNotError('list')
self.assertNotError('seen %s' % self.nick)
m = self.assertNotError('seen %s' % self.nick.upper())