Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

92 lines (77 sloc) 2.99 KB
#!/usr/bin/env python
""" - Jenni Information Module
Copyright 2008, Sean B. Palmer,
Licensed under the Eiffel Forum License 2.
def doc(jenni, input):
"""Shows a command's documentation, and possibly an example."""
name =
name = name.lower()
if jenni.doc.has_key(name):
if jenni.doc[name][1]:
jenni.say('e.g. ' + jenni.doc[name][1])
doc.rule = ('$nick', '(?i)(?:help|doc) +([A-Za-z]+)(?:\?+)?$')
doc.example = '$nickname: doc tell?'
doc.priority = 'low'
def commands(jenni, input):
# This function only works in private message
#if input.sender.startswith('#'): return
names = ', '.join(sorted(jenni.doc.iterkeys()))
jenni.reply("I am sending you a private message of all my commands!")
jenni.msg(input.nick, 'Commands I recognise: ' + names + '.')
jenni.msg(input.nick, ("For help, do '%s: help example?' where example is the " +
"name of the command you want help for.") % jenni.nick)
commands.commands = ['commands', 'help']
commands.priority = 'low'
def help(jenni, input):
response = (
'Hi, I\'m a bot. Say ".commands" to me in private for a list ' +
'of my commands, or see for more ' +
'general details. My owner is %s.'
) % jenni.config.owner
help.rule = ('$nick', r'(?i)help(?:[?!]+)?$')
help.priority = 'low'
def stats(jenni, input):
"""Show information on command usage patterns."""
commands = {}
users = {}
channels = {}
ignore = set(['f_note', 'startup', 'message', 'noteuri',
'say_it', 'collectlines'])
for (name, user), count in jenni.stats.iteritems():
if name in ignore: continue
if not user: continue
if not user.startswith('#'):
try: users[user] += count
except KeyError: users[user] = count
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)
jenni.say(creply.rstrip(', '))
# most heavy users
reply = 'power users: '
for count, user in userank[:10]:
reply += '%s (%s), ' % (user, count)
jenni.say(reply.rstrip(', '))
# most heavy channels
chreply = 'power channels: '
for count, channel in charank[:3]:
chreply += '%s (%s), ' % (channel, count)
jenni.say(chreply.rstrip(', '))
stats.commands = ['stats']
stats.priority = 'low'
if __name__ == '__main__':
print __doc__.strip()
Jump to Line
Something went wrong with that request. Please try again.