summaryrefslogtreecommitdiffstats
path: root/modules/info.py
diff options
context:
space:
mode:
authorSean B. Palmer <http://inamidst.com/sbp/>2008-02-21 12:06:33 +0000
committerSean B. Palmer <http://inamidst.com/sbp/>2008-02-21 12:06:33 +0000
commit7931fab14599b739c18c8f1ebcc24b75688dbc09 (patch)
treebf4df9757f10c155e3b6f78aed48f15884ebbbe6 /modules/info.py
downloadbot-7931fab14599b739c18c8f1ebcc24b75688dbc09.tar.gz
bot-7931fab14599b739c18c8f1ebcc24b75688dbc09.tar.bz2
bot-7931fab14599b739c18c8f1ebcc24b75688dbc09.zip
Phenny2, now being tested on Freenode as the main phenny.
Diffstat (limited to 'modules/info.py')
-rw-r--r--modules/info.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/modules/info.py b/modules/info.py
new file mode 100644
index 0000000..a70c823
--- /dev/null
+++ b/modules/info.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+"""
+info.py - Phenny Information Module
+Copyright 2008, Sean B. Palmer, inamidst.com
+Licensed under the Eiffel Forum License 2.
+
+http://inamidst.com/phenny/
+"""
+
+def doc(phenny, input):
+ """Shows a command's documentation, and possibly an example."""
+ name = input.group(1)
+ name = name.lower()
+
+ if phenny.doc.has_key(name):
+ phenny.reply(phenny.doc[name][0])
+ if phenny.doc[name][1]:
+ phenny.say('e.g. ' + phenny.doc[name][1])
+doc.rule = ('$nick', '(?i)help +([A-Za-z]+)(?:\?+)?$')
+doc.example = '$nickname: help tell?'
+doc.priority = 'low'
+
+def commands(phenny, input):
+ # This function only works in private message
+ if input.startswith('#'): return
+ names = ', '.join(sorted(phenny.doc.iterkeys()))
+ phenny.say('Commands I recognise: ' + names + '.')
+ phenny.say(("For help, do '%s: help example?' where example is the " +
+ "name of the command you want help for.") % phenny.nick)
+commands.commands = ['commands']
+commands.priority = 'low'
+
+def help(phenny, input):
+ response = (
+ 'Hi, I\'m a bot. Say ".commands" to me in private for a list ' +
+ 'of my commands, or see http://inamidst.com/phenny/ for more ' +
+ 'general details. My owner is %s.'
+ ) % phenny.config.owner
+ phenny.reply(response)
+help.rule = ('$nick', r'(?i)help(?:[?!]+)?$')
+help.priority = 'low'
+
+if __name__ == '__main__':
+ print __doc__.strip()