]>
jfr.im git - erebus.git/blob - modules/help.py
1 # Erebus IRC bot - Author: Erebus Team
3 # This file is released into the public domain; see http://unlicense.org/
7 'author': 'Erebus Team',
8 'license': 'public domain',
9 'compatible': [1], # compatible module API versions
10 'depends': [], # other modules required to work properly?
15 lib
= modlib
.modlib(__name__
)
16 modstart
= lib
.modstart
23 # ! this is part of this module's API, called from modlib.help()
24 # this function only handles the command name and aliases - the rest is passed directly to _reghelp()
25 def reghelp(func
, *args
, **kwargs
):
37 if 'syntax' in kwargs
:
38 syntax
= kwargs
['syntax']
39 if 'shorthelp' in kwargs
:
40 shorthelp
= kwargs
['shorthelp']
41 if 'longhelps' in kwargs
:
42 longhelps
= kwargs
['longhelps']
44 if syntax
is None: syntax
= ""
45 if shorthelp
is None: shorthelp
= ""
48 func
.shorthelp
= shorthelp
49 func
.longhelps
= longhelps
54 def dereghelp(func
, *args
, **kwargs
):
59 @lib.hook(needchan
=False)
60 @lib.help('[<command>]', 'lists commands or describes a command')
61 def help(bot
, user
, chan
, realtarget
, *args
):
63 for func
in helps
.itervalues():
64 if user
.glevel
>= func
.reqglevel
:
65 if func
.reqglevel
<= 0:
66 bot
.slowmsg(user
, "%-40s - %-50s" % (func
.cmd
[0]+' '+func
.syntax
, func
.shorthelp
))
68 bot
.slowmsg(user
, "%-40s - %-50s (%5s)" % (func
.cmd
[0]+' '+func
.syntax
, func
.shorthelp
, func
.reqglevel
))
70 for c
in func
.cmd
[1:]:
71 bot
.slowmsg(user
, "%-40s - Alias of %s" % (c
, func
.cmd
[0]))
73 cmd
= str(' '.join(args
))
74 if cmd
in cmds
and user
.glevel
>= cmds
[cmd
].reqglevel
:
76 if func
.reqglevel
<= 0:
77 bot
.slowmsg(user
, "%-40s - %-50s" % (func
.cmd
[0]+' '+func
.syntax
, func
.shorthelp
))
79 bot
.slowmsg(user
, "%-40s - %-50s (%5s)" % (func
.cmd
[0]+' '+func
.syntax
, func
.shorthelp
, func
.reqglevel
))
80 for line
in func
.longhelps
:
81 bot
.slowmsg(user
, " %s" % (line
))
84 bot
.slowmsg(user
, " Aliases: %s" % (' '.join(func
.cmd
[1:])))
86 bot
.slowmsg(user
, "No help found for %s" % (cmd
))