From 68dd30cb8babdb18a15086936ec97a3d7b02da72 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 23 Oct 2003 20:59:51 +0000 Subject: [PATCH] Made stats default to the name of the person asking. --- plugins/ChannelDB.py | 17 ++++++++++++----- test/test_ChannelDB.py | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/ChannelDB.py b/plugins/ChannelDB.py index d78527300..ea8d6b17c 100644 --- a/plugins/ChannelDB.py +++ b/plugins/ChannelDB.py @@ -408,14 +408,21 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp): WHERE name=%s""", name) def stats(self, irc, msg, args): - """[] + """[] [] - Returns the statistics for on . is only - necessary if the message isn't sent on the channel itself. + Returns the statistics for on . is only + necessary if the message isn't sent on the channel itself. If + 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) diff --git a/test/test_ChannelDB.py b/test/test_ChannelDB.py index efa6eba5b..5cc9a4d65 100644 --- a/test/test_ChannelDB.py +++ b/test/test_ChannelDB.py @@ -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')