diff options
author | Sean B. Palmer <http://inamidst.com/sbp/> | 2008-02-29 15:36:18 +0000 |
---|---|---|
committer | Sean B. Palmer <http://inamidst.com/sbp/> | 2008-02-29 15:36:18 +0000 |
commit | 3d920f431789ac53596933785b5fe61463335e3b (patch) | |
tree | 654b01dfb141aba551d400393263fa6914ba9310 /modules/info.py | |
parent | cbdf9ebd7312bf570a212057ad793ae520bac38f (diff) | |
download | bot-3d920f431789ac53596933785b5fe61463335e3b.tar.gz bot-3d920f431789ac53596933785b5fe61463335e3b.tar.bz2 bot-3d920f431789ac53596933785b5fe61463335e3b.zip |
Some more little fixes, and added a Makefile.
Diffstat (limited to 'modules/info.py')
-rw-r--r-- | modules/info.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/modules/info.py b/modules/info.py index a70c823..df6ad69 100644 --- a/modules/info.py +++ b/modules/info.py @@ -40,5 +40,48 @@ def help(phenny, input): help.rule = ('$nick', r'(?i)help(?:[?!]+)?$') help.priority = 'low' +def stats(phenny, input): + commands = {} + users = {} + channels = {} + + ignore = set(['f_note', 'startup', 'message', 'noteuri']) + for (name, user), count in phenny.stats.iteritems(): + if name in ignore: continue + + if not user.startswith('#'): + try: users[user] += count + except KeyError: users[user] = count + else: + try: commands[name] += count + except KeyError: commands[name] = count + + try: channels[user] += count + except KeyError: channels[user] = count + + comrank = sorted([(b, a) for (a, b) in commands.iteritems()], reverse=True) + userank = sorted([(b, a) for (a, b) in users.iteritems()], reverse=True) + charank = sorted([(b, a) for (a, b) in channels.iteritems()], reverse=True) + + # most heavily used commands + creply = 'most used commands: ' + for count, command in comrank[:10]: + creply += '%s (%s), ' % (command, count) + phenny.say(creply.rstrip(', ')) + + # most heavy users + reply = 'power users: ' + for count, user in userank[:10]: + reply += '%s (%s), ' % (user, count) + phenny.say(reply.rstrip(', ')) + + # most heavy channels + chreply = 'power channels: ' + for count, channel in charank[:3]: + chreply += '%s (%s), ' % (channel, count) + phenny.say(chreply.rstrip(', ')) +stats.commands = ['stats'] +stats.priority = 'low' + if __name__ == '__main__': print __doc__.strip() |