64 lines
1.9 KiB
Python
64 lines
1.9 KiB
Python
|
"""
|
||
|
Help - handle !help commands by interrogating modules for help text
|
||
|
Copyright (C) 2011 Mike Bloy <mike@bloy.org>
|
||
|
|
||
|
This program is free software: you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation, either version 3 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
"""
|
||
|
|
||
|
import re
|
||
|
import sqlite3
|
||
|
|
||
|
from Module import Module
|
||
|
|
||
|
__author__ = "Mike Bloy <mike@bloy.org>"
|
||
|
__date__ = "2011-01-08"
|
||
|
|
||
|
class Help(Module):
|
||
|
|
||
|
def __init__(self, irc, config, server):
|
||
|
"""
|
||
|
Upon creation, determine the save file location
|
||
|
"""
|
||
|
|
||
|
Module.__init__(self, irc, config, server)
|
||
|
|
||
|
self.helpre = re.compile('^!help(\s+(\S+)(\s+(.+))?)?\s*$')
|
||
|
|
||
|
def do(self, connection, event, nick, userhost, what, admin_unlocked):
|
||
|
"""look for karma strings at the start of messages"""
|
||
|
|
||
|
match = self.helpre.search(what)
|
||
|
if (match):
|
||
|
(module, key) = match.group(2,4)
|
||
|
if (module == None):
|
||
|
return self.help_descriptions()
|
||
|
elif (key == None):
|
||
|
return self.help_module(module)
|
||
|
else:
|
||
|
return self.help_detail(module, key)
|
||
|
|
||
|
def help_descriptions(self):
|
||
|
return "asked for general help"
|
||
|
|
||
|
def help_module(self, module):
|
||
|
return "asked for help on module %s" % (module)
|
||
|
|
||
|
def help_detail(self, module, key):
|
||
|
return "asked for help on module %s detail %s" % (module, key)
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
print "Hello World"
|
||
|
|
||
|
# vi:tabstop=4:expandtab:autoindent
|