]>
jfr.im git - erebus.git/blob - modlib.py
1 # Erebus IRC bot - Author: John Runyon
2 # module helper functions, see modules/modtest.py for usage
3 # This file is released into the public domain; see http://unlicense.org/
6 def __init__(self
, desc
):
9 return False #object will test to False
11 return '<modlib.error %r>' % self
.errormsg
16 # default (global) access levels
23 # (channel) access levels
25 MASTER
= -8 #master is {-8,-9}
26 OP
= -5 #op is {-5,-6,-7}
29 PUBLIC
= -2 #anyone (use glevel to control auth-needed)
32 WRONGARGS
= "Wrong number of arguments."
34 def __init__(self
, name
):
40 def modstart(self
, parent
):
42 for cmd
, func
in self
.hooks
.iteritems():
43 self
.parent
.hook(cmd
, func
)
45 def modstop(self
, parent
):
46 for cmd
, func
in self
.hooks
.iteritems():
47 self
.parent
.unhook(cmd
, func
)
50 def hook(self
, cmd
, needchan
=True, glevel
=ANYONE
, clevel
=PUBLIC
):
52 func
.needchan
= needchan
53 func
.reqglevel
= glevel
54 func
.reqclevel
= clevel
56 self
.hooks
[cmd
] = func
57 if self
.parent
is not None:
58 self
.parent
.hook(cmd
, func
)
62 def argsEQ(self
, num
):
64 def checkargs(bot
, user
, chan
, realtarget
, *args
):
66 return func(bot
, user
, chan
, realtarget
, *args
)
68 bot
.msg(user
, self
.WRONGARGS
)
72 def argsGE(self
, num
):
74 def checkargs(bot
, user
, chan
, realtarget
, *args
):
76 return func(bot
, user
, chan
, realtarget
, *args
)
78 bot
.msg(user
, self
.WRONGARGS
)