]> jfr.im git - z_archive/Ophion.git/blob - modules/autoload/help.py
Initialize repo
[z_archive/Ophion.git] / modules / autoload / help.py
1 from classes import *
2 from util import *
3
4 name = 'help'
5 def init(cache):
6 cache.currmod = __name__
7 cache.hookcmd('HELP', 0, dohelp, 0, helphelp, isadmin=True)
8 cache.hookcmd('SHOWCOMMANDS', 0, showcommands, 0, helpshowcommands, isadmin=True)
9 def deinit(cache, reloading=False):
10 cache.currmod = __name__
11 cache.unhookcmd('HELP')
12 cache.unhookcmd('SHOWCOMMANDS')
13
14 def dohelp(nick, target, params, bot, cache):
15 if len(params) == 0: showcommands(nick, target, params, bot, cache)
16 else:
17 thehelp = cache.gethelp(params.upper(), nick)
18 if thehelp is not None:
19 bot.msg(nick, '-- HELP for %s' % (params))
20 bot.msg(nick, 'Syntax: %s' % (thehelp[0]))
21 for theline in thehelp[1:]:
22 bot.msg(nick, theline)
23 bot.msg(nick, '-- End of HELP for %s' % (params))
24 else:
25 bot.msg(nick, "HELP for %s not available: no such command or not enough access." % (params))
26
27 def showcommands(nick, target, params, bot, cache):
28 helps = []
29 if nick in cache.users:
30 access = cache.users[nick].access
31 else:
32 access = 0
33 bot.msg(nick, '-- COMMAND LIST')
34 for key in sorted(cache.cmds):
35 cmd = cache.cmds[key]
36 if access >= cmd['level']:
37 cmdhelp = cmd['helpfunc']()
38 if len(cmdhelp) == 3 and access >= 1:
39 bot.msg(nick, "%-20s %s [module: %s]" % (cmdhelp[0], cmdhelp[1], cmdhelp[2]))
40 else:
41 bot.msg(nick, "%-20s %s" % (cmdhelp[0], cmdhelp[1]))
42 bot.msg(nick, '-- End of COMMAND LIST')
43
44 def helphelp(): return ['HELP [<command>]', 'Requests help for a command, or shows a command list.']
45 def helpshowcommands(): return ['SHOWCOMMANDS', 'Shows a command list.']