Made stats default to the name of the person asking.

This commit is contained in:
Jeremy Fincher 2003-10-23 20:59:51 +00:00
parent 6d9aea2d26
commit 68dd30cb8b
2 changed files with 13 additions and 5 deletions

View File

@ -408,14 +408,21 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
WHERE name=%s""", name)
def stats(self, irc, msg, args):
"""[<channel>] <nick>
"""[<channel>] [<name>]
Returns the statistics for <nick> on <channel>. <channel> is only
necessary if the message isn't sent on the channel itself.
Returns the statistics for <name> on <channel>. <channel> is only
necessary if the message isn't sent on the channel itself. If <name>
isn't given, it defaults to the user sending the command.
"""
channel = privmsgs.getChannel(msg, args)
name = privmsgs.getArgs(args)
if not ircdb.users.hasUser(name):
name = privmsgs.getArgs(args, needed=0, optional=1)
if not name:
try:
id = ircdb.users.getUserId(msg.prefix)
except KeyError:
irc.error(msg, 'I couldn\'t find you in my user database.')
return
elif not ircdb.users.hasUser(name):
try:
hostmask = irc.state.nickToHostmask(name)
id = ircdb.users.getUserId(hostmask)

View File

@ -57,6 +57,7 @@ if sqlite is not None:
self.assertError('stats %s' % self.nick)
self.assertNotError('stats %s' % self.nick)
self.assertNotError('stats %s' % self.nick.upper())
self.assertNotError('stats')
def testNoKeyErrorEscapeFromSeen(self):
self.assertRegexp('seen asldfkjasdlfkj', 'I have not seen')