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

165
ChangeLog
View File

@ -1,9 +1,12 @@
* 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.
* Updated echo to use the standard substitute on its reply. * Updated echo to use the standard substitute on its reply.
* Updated Network.whois so that it can now retrieve * Updated Network.whois so that it can now retrieve
information on all domains. information on all domains.
@ -17,12 +20,12 @@
* Updated standard replies (such as supybot.replies.success, etc.) * Updated standard replies (such as supybot.replies.success, etc.)
to use the standard substitute (such as $nick, $who, $channel, to use the standard substitute (such as $nick, $who, $channel,
etc.) in their text. etc.) in their text.
* Fixed snarfers to respect lobotomies. * Fixed snarfers to respect lobotomies.
* Fixed Admin.join not to add the channel to the supybot.channels * Fixed Admin.join not to add the channel to the supybot.channels
registry entry if joining the channel wasn't successful. registry entry if joining the channel wasn't successful.
2004-02-20 Jeremy Fincher <jemfinch@supybot.org> 2004-02-20 Jeremy Fincher <jemfinch@supybot.org>
* Version 0.77.0! * Version 0.77.0!
@ -31,73 +34,73 @@
something much more readable and user-editable. Be sure, if something much more readable and user-editable. Be sure, if
you're upgrading, to run tools/ircdbConvert.py on your user and you're upgrading, to run tools/ircdbConvert.py on your user and
channel databases *BEFORE* installing the new version. channel databases *BEFORE* installing the new version.
* Updated almost every document we have, and added a * Updated almost every document we have, and added a
GETTING_STARTED document. Yay! GETTING_STARTED document. Yay!
* Added several new options for Channel.kban: --exact, --nick, * Added several new options for Channel.kban: --exact, --nick,
--user, --host, for more flexibility in determining what the --user, --host, for more flexibility in determining what the
banmask is. banmask is.
* Added a Scheduler plugin for scheduling events to occur at * Added a Scheduler plugin for scheduling events to occur at
specific times. specific times.
* Added a Herald plugin for announcing to the channel the arrival * Added a Herald plugin for announcing to the channel the arrival
of certain users. of certain users.
* Changed the reply method of the irc object given to plugins not * Changed the reply method of the irc object given to plugins not
to require a msg object. to require a msg object.
* Added inter-factoid references for MoobotFactoids. Simply * Added inter-factoid references for MoobotFactoids. Simply
define a factoid as "see <factoid-key>" (and nothing else) and it define a factoid as "see <factoid-key>" (and nothing else) and it
will automatically go pick up the value for that factoid and will automatically go pick up the value for that factoid and
display it in its place. Sort of a "symlink" for MoobotFactoids. display it in its place. Sort of a "symlink" for MoobotFactoids.
* Added the ability to reply to factoids without the "whatis" in * Added the ability to reply to factoids without the "whatis" in
the Factoids plugin. Now, you can use "@foo" instead of "@whatis the Factoids plugin. Now, you can use "@foo" instead of "@whatis
foo". foo".
* Added --{from,to} and --sent options to Note.sent. * Added --{from,to} and --sent options to Note.sent.
* Changed Note.get to simply be "note". Instead of "note get * Changed Note.get to simply be "note". Instead of "note get
145", you should use "note 145". 145", you should use "note 145".
* Changed channel capabilities to use a comma to separate the * Changed channel capabilities to use a comma to separate the
channel from the capability instead of a period. This is because channel from the capability instead of a period. This is because
channels can include periods (but not commas) and since we now channels can include periods (but not commas) and since we now
allow "plugin.command" capabilities, there's no way to know allow "plugin.command" capabilities, there's no way to know
whether a given dot is separating the channel from the capability whether a given dot is separating the channel from the capability
or the plugin from the command. or the plugin from the command.
* Removed Admin.setprefixchar, since it's unneeded with the new * Removed Admin.setprefixchar, since it's unneeded with the new
configuration. configuration.
* Removed Status.bestuptime, since it was buggy and no one felt * Removed Status.bestuptime, since it was buggy and no one felt
like maintaining it. like maintaining it.
* Added Http.cyborg, a fun little command for getting cyborg * Added Http.cyborg, a fun little command for getting cyborg
abbreviations for names. abbreviations for names.
* Added Sourceforge.totalbugs and Sourceforge.totalrfes * Added Sourceforge.totalbugs and Sourceforge.totalrfes
* Removed Owner.{set,unset} since they matter not. * Removed Owner.{set,unset} since they matter not.
* Made the smileys and frowns configurable in ChannelDB. * Made the smileys and frowns configurable in ChannelDB.
* Added a vast array of new configurables -- check out the various * Added a vast array of new configurables -- check out the various
config commands in Configurable plugins to see. config commands in Configurable plugins to see.
* Added better error reporting for Admin.join, explaining to the * Added better error reporting for Admin.join, explaining to the
user if the bot can't join the channel. user if the bot can't join the channel.
* Added a title-snarfer to the URL plugin. * Added a title-snarfer to the URL plugin.
* Added Relay.command, a command for sending commands to the bot * Added Relay.command, a command for sending commands to the bot
on a different network. on a different network.
* Added Bugzilla.search, a new command for searching a bugzilla * Added Bugzilla.search, a new command for searching a bugzilla
installation installation
* Added an INVITE handler in Admin, allowing users with the admin * Added an INVITE handler in Admin, allowing users with the admin
capability to INVITE the bot to a channel. There's also a config capability to INVITE the bot to a channel. There's also a config
variable, alwaysJoinOnInvite, that will cause the bot to join variable, alwaysJoinOnInvite, that will cause the bot to join
@ -106,10 +109,10 @@
* Added conf.requireChannelCommandsToBeSentInChannel for requiring * Added conf.requireChannelCommandsToBeSentInChannel for requiring
all channel-related commands to be sent in the channel. all channel-related commands to be sent in the channel.
* Added conf.followIdentificationThroughNickChanges for having the * Added conf.followIdentificationThroughNickChanges for having the
bot update user's identified hostmask when they change nicks. bot update user's identified hostmask when they change nicks.
* Added conf.replyWhenNotAddressed, a configuration variable for * Added conf.replyWhenNotAddressed, a configuration variable for
having the bot always attempt to parse a message as a command. having the bot always attempt to parse a message as a command.
@ -119,34 +122,34 @@
* Added conf.replyWithNickPrefix, a configuration variable for * Added conf.replyWithNickPrefix, a configuration variable for
having the bot not prefix the nick of the person giving a command having the bot not prefix the nick of the person giving a command
to the reply. to the reply.
* Changed all "zegrep" stuff to "zgrep -e" stuff, since zegrep is * Changed all "zegrep" stuff to "zgrep -e" stuff, since zegrep is
on fewer platforms than zgrep. on fewer platforms than zgrep.
2003-12-12 Jeremy Fincher <jemfinch@supybot.org> 2003-12-12 Jeremy Fincher <jemfinch@supybot.org>
* Version 0.76.1! The birthday release! * Version 0.76.1! The birthday release!
* Fixed a bug in irclib.py that could cause the bot to loop, * Fixed a bug in irclib.py that could cause the bot to loop,
connecting and disconnecting from the server because it didn't connecting and disconnecting from the server because it didn't
think the server responded to its PING. think the server responded to its PING.
* Fixed a bug in the Services implementation that could cause * Fixed a bug in the Services implementation that could cause
the bot to continually loop, connecting and disconnecting from the the bot to continually loop, connecting and disconnecting from the
server. server.
* Fixed Misc.help to follow the same default plugin rules that the * Fixed Misc.help to follow the same default plugin rules that the
rest of the bot follows. rest of the bot follows.
* Added better error reporting to Admin.join, so the various error * Added better error reporting to Admin.join, so the various error
conditions that might make the bot incapable of joining a channel conditions that might make the bot incapable of joining a channel
will be reported. will be reported.
* Updated RootWarner to be configurable, offering each channel the * Updated RootWarner to be configurable, offering each channel the
ability to define whether or not people who IRC as root will be ability to define whether or not people who IRC as root will be
warned, what that warning will be, and whether or not they should warned, what that warning will be, and whether or not they should
be kicked. be kicked.
* Added a configurable 'topic-sync' to the Relay plugin to * Added a configurable 'topic-sync' to the Relay plugin to
determine whether the topics of the two channels should be kept determine whether the topics of the two channels should be kept
synchronized. synchronized.
@ -169,110 +172,110 @@
* Added utils.sorted, which does what list.sorted will do when 2.4 * Added utils.sorted, which does what list.sorted will do when 2.4
is released. is released.
* Added ircutils.isCtcp, for determining whether or not a message * Added ircutils.isCtcp, for determining whether or not a message
is a CTCP message. is a CTCP message.
2003-12-6 Jeremy Fincher <jemfinch@supybot.org> 2003-12-6 Jeremy Fincher <jemfinch@supybot.org>
* Version 0.76.0! * Version 0.76.0!
* Added a "trusted" capability that defaults to off (-trusted) and * Added a "trusted" capability that defaults to off (-trusted) and
is required for Utilities.re (with which it's possible to DoS the is required for Utilities.re (with which it's possible to DoS the
bot) and for the new Math.icalc (with which it is trivially bot) and for the new Math.icalc (with which it is trivially
possible to DoS the bot). possible to DoS the bot).
* Added Math.icalc, a new command for doing integer arithmetic. * Added Math.icalc, a new command for doing integer arithmetic.
It requires the "trusted" capability. It requires the "trusted" capability.
* Added the Fun.ping command, because MozBot has it. * Added the Fun.ping command, because MozBot has it.
* Added Note.unsend command, to allow users to "unsend" notes * Added Note.unsend command, to allow users to "unsend" notes
they've sent but whose recipient has not yet read. they've sent but whose recipient has not yet read.
* Added Channel.{deop,devoice,dehalfop,kick}. * Added Channel.{deop,devoice,dehalfop,kick}.
* Added Http.size and Http.doctype and Http.headers to retrieve * Added Http.size and Http.doctype and Http.headers to retrieve
various meta-information on URLs. various meta-information on URLs.
* Added a ranking to ChannelDB.wordstats. * Added a ranking to ChannelDB.wordstats.
* Added Karma.most for determining various "mosts" in the Karma * Added Karma.most for determining various "mosts" in the Karma
database. database.
* Added User.list command to list registered users. * Added User.list command to list registered users.
* Added 'roulette' command to Fun plugin. * Added 'roulette' command to Fun plugin.
* Added a Channel.lobotomies command to list the channels in which * Added a Channel.lobotomies command to list the channels in which
the bot is lobotomized. the bot is lobotomized.
* Added a swap function to Math.rpn. * Added a swap function to Math.rpn.
* Changed the name of User.changeusername to User.changename. * Changed the name of User.changeusername to User.changename.
* Changed the logging infrastructure significantly; each plugin * Changed the logging infrastructure significantly; each plugin
now has its own logger (and thus logfile), in addition to being now has its own logger (and thus logfile), in addition to being
logged in the main logfile. logged in the main logfile.
* Fixed bug in which the bot wouldn't rejoin channels after a * Fixed bug in which the bot wouldn't rejoin channels after a
reconnect. Thank the Lord for tcpkill :) reconnect. Thank the Lord for tcpkill :)
* Fixed Http.freshmeat for projects with a space in their names. * Fixed Http.freshmeat for projects with a space in their names.
* Changed RSS so RSS feed commands may be added while the bot is * Changed RSS so RSS feed commands may be added while the bot is
running, and so added RSS feed commands are in the RSS plugin. running, and so added RSS feed commands are in the RSS plugin.
* Changed Lookup so added lookups are added in the Lookup plugin * Changed Lookup so added lookups are added in the Lookup plugin
itself so there's no dependency on Alias, and so loaded lookups itself so there's no dependency on Alias, and so loaded lookups
can be seen via 'list Lookup'. can be seen via 'list Lookup'.
* Fixed bug #850931 as well as several other minor bugs in * Fixed bug #850931 as well as several other minor bugs in
Utilities.re. Utilities.re.
* Fixed bug #851254, Factoids.whatis didn't work on numeric keys. * Fixed bug #851254, Factoids.whatis didn't work on numeric keys.
* Added the ability to turn on/off the showing of ids in FunDB * Added the ability to turn on/off the showing of ids in FunDB
excuse/insult/praise/lart. excuse/insult/praise/lart.
* Added the to= keyword argument to the various reply functions to * Added the to= keyword argument to the various reply functions to
you can specify a target to send the message to. you can specify a target to send the message to.
* Changed socketDrivers to allow more time (10x more, to be exact) * Changed socketDrivers to allow more time (10x more, to be exact)
for connecting to the network than for the normal read. for connecting to the network than for the normal read.
* Fixed a bug in Http.weather that would cause an ugly error * Fixed a bug in Http.weather that would cause an ugly error
message for a command like "weather hell". message for a command like "weather hell".
* Added the number of strings to the Fun.object output. * Added the number of strings to the Fun.object output.
* Fixed bug in RSS.configure; no aliases could be added. * Fixed bug in RSS.configure; no aliases could be added.
* Changed Alias.freeze to Alias.lock. * Changed Alias.freeze to Alias.lock.
* Fixed sorting in Status' uptime database. * Fixed sorting in Status' uptime database.
* Updated the Gameknot tests for expired games, and updated the * Updated the Gameknot tests for expired games, and updated the
Gameknot plugin to handle such links in its snarfer. Gameknot plugin to handle such links in its snarfer.
* Added a 'server' attribute to Irc objects to unify the way to * Added a 'server' attribute to Irc objects to unify the way to
access such information. access such information.
* Added revision command for finding out the revision of the files * Added revision command for finding out the revision of the files
in a running bot; also added __revision__ strings so CVS would be in a running bot; also added __revision__ strings so CVS would be
happy to keep such information for us :) happy to keep such information for us :)
* Fixed bug #848475 -- bad error message from regexp-expecting * Fixed bug #848475 -- bad error message from regexp-expecting
commands. commands.
* Stopped listing the plugin dispatcher command in the list of * Stopped listing the plugin dispatcher command in the list of
commands for that plugin. commands for that plugin.
* Fixed bug in Gameknot.gkstats when retrieving the stats for * Fixed bug in Gameknot.gkstats when retrieving the stats for
users who haven't yet played a game. users who haven't yet played a game.
* Added a numUsers() method to ircdb.UsersDB (ircdb.users). * Added a numUsers() method to ircdb.UsersDB (ircdb.users).
2003-11-18 Jeremy Fincher <jemfinch@users.sf.net> 2003-11-18 Jeremy Fincher <jemfinch@users.sf.net>
* Changed commands so that plugins no longer have to make sure * Changed commands so that plugins no longer have to make sure
@ -297,7 +300,7 @@
* Added the ability for users to specify that their passwords * Added the ability for users to specify that their passwords
should be hashed on disk. should be hashed on disk.
* Added MoobotFactoids plugin for moobot-style factoids (which are * Added MoobotFactoids plugin for moobot-style factoids (which are
meant to mimic blootbot-style factoids). People used to meant to mimic blootbot-style factoids). People used to
traditional IRC bot factoids plugins will probably find this traditional IRC bot factoids plugins will probably find this
@ -312,7 +315,7 @@
* Added Bugzilla module for accessing various data in Bugzilla * Added Bugzilla module for accessing various data in Bugzilla
pages. pages.
* Added QuoteGrabs module which allows people to grab interesting * Added QuoteGrabs module which allows people to grab interesting
quotes from other people and store them in the bot for later retrieval quotes from other people and store them in the bot for later retrieval
(also optionally have the bot randomly snarf quotes). (also optionally have the bot randomly snarf quotes).
@ -325,7 +328,7 @@
* Changed FundB to allow accessing excuses, larts, and praises by * Changed FundB to allow accessing excuses, larts, and praises by
id. id.
* Added substitutions for 'me' and 'my' in insult/praise/lart. * Added substitutions for 'me' and 'my' in insult/praise/lart.
* Added 'change' and 'old' commands for News. * Added 'change' and 'old' commands for News.
@ -349,10 +352,10 @@
* Removed the Moobot plugin (the commands were moved to the Fun * Removed the Moobot plugin (the commands were moved to the Fun
plugin or dropped entirely). plugin or dropped entirely).
* Removed all example strings from plugins. To be replaced with an * Removed all example strings from plugins. To be replaced with an
automated process later. automated process later.
* Converted several plugins to the new Configurable plugin type * Converted several plugins to the new Configurable plugin type
Plugins modified include Bugzilla, ChannelDB, Dict, Ebay, Plugins modified include Bugzilla, ChannelDB, Dict, Ebay,
Enforcer, Gameknot, Google, Python, Relay, and URL (formerly Enforcer, Gameknot, Google, Python, Relay, and URL (formerly
@ -363,7 +366,7 @@
* Changed Http.geekquote to use multiline geekquotes (and removed * Changed Http.geekquote to use multiline geekquotes (and removed
the option to do so, since it's now the default). the option to do so, since it's now the default).
* Added a --id switch to geekquote to pick a specific geekquote. * Added a --id switch to geekquote to pick a specific geekquote.
* Changed most commands in News to require the 'news' capability. * Changed most commands in News to require the 'news' capability.
@ -390,13 +393,13 @@
* Changed the name of the "bug" command in the AdminCommands * Changed the name of the "bug" command in the AdminCommands
plugin to "reportbug" instead. plugin to "reportbug" instead.
* Added QUIT stat-keeping to ChannelDB. * Added QUIT stat-keeping to ChannelDB.
* Removed the OwnerCommands.say command; it wasn't useful enough, * Removed the OwnerCommands.say command; it wasn't useful enough,
and is so easily written that anyone can have it back if they want and is so easily written that anyone can have it back if they want
it. it.
* Changed OwnerCommands.load (and reload) to be case-insensitive, * Changed OwnerCommands.load (and reload) to be case-insensitive,
so "load funcommands" works just as well as "load FunCommands". so "load funcommands" works just as well as "load FunCommands".
@ -445,9 +448,9 @@
which existed prior to the addition of more, and aren't needed which existed prior to the addition of more, and aren't needed
anymore. anymore.
2003-10-12 Jeremy Fincher <jemfinch@users.sf.net> 2003-10-12 Jeremy Fincher <jemfinch@users.sf.net>
* Version 0.73.1! * Version 0.73.1!
* Fixed a bug in Math.{calc,rpn} where certain functions * Fixed a bug in Math.{calc,rpn} where certain functions
@ -457,7 +460,7 @@
* Added an optional "key" argument to ChannelCommands.cycle. * Added an optional "key" argument to ChannelCommands.cycle.
* Fixed bolding in supybot-wizard.py. * Fixed bolding in supybot-wizard.py.
* Fixed handling of the secure flag by ircdb.IrcUser.setAuth; * Fixed handling of the secure flag by ircdb.IrcUser.setAuth;
previously it didn't prevent someone with an unmatched hostmask previously it didn't prevent someone with an unmatched hostmask
from identifying. from identifying.
@ -503,7 +506,7 @@
* Version 0.73.0! * Version 0.73.0!
* Added the News plugin, news handling for channels. * Added the News plugin, news handling for channels.
* Changed the initial character of anti capabilities to '-' * Changed the initial character of anti capabilities to '-'
instead of '!'. '!' can be the initial character in a channel instead of '!'. '!' can be the initial character in a channel
name, and so any command using getChannel and accepting a name, and so any command using getChannel and accepting a
@ -552,4 +555,4 @@
last_seen TIMESTAMP, last_seen TIMESTAMP,
last_msg TEXT last_msg TEXT
); );

View File

@ -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,34 +112,43 @@ 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)
nickOrId = name if name:
if ('--user', '') in optlist: nickOrId = name
try: if ('--user', '') in optlist:
nickOrId = ircdb.users.getUserId(name)
except KeyError:
try: try:
hostmask = irc.state.nickToHostmask(name) nickOrId = ircdb.users.getUserId(name)
nickOrId = ircdb.users.getUserId(hostmask)
except KeyError: except KeyError:
irc.errorNoUser() try:
return hostmask = irc.state.nickToHostmask(name)
try: nickOrId = ircdb.users.getUserId(hostmask)
(when, said) = self.db.seen(channel, nickOrId) except KeyError:
irc.reply('%s was last seen here %s ago saying: %s' % irc.errorNoUser()
(name, utils.timeElapsed(time.time()-when), said)) return
except KeyError: try:
irc.reply('I have not seen %s.' % name) (when, said) = self.db.seen(channel, nickOrId)
irc.reply('%s was last seen here %s ago saying: %s' %
(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 Class = Seen

View File

@ -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())