]> jfr.im git - erebus.git/blob - modules/foo.py
added softdeps to modinfo - bumped APIVERSION
[erebus.git] / modules / foo.py
1 # Erebus IRC bot - Author: Erebus Team
2 # simple module example
3 # This file is released into the public domain; see http://unlicense.org/
4
5 # module info
6 modinfo = {
7 'author': 'Erebus Team',
8 'license': 'public domain',
9 'compatible': [1,2], # compatible module API versions
10 'depends': [], # other modules required to work properly?
11 'softdeps': ['help'], # modules which are preferred but not required
12 }
13 # note: softdeps will be loaded before this module, IF not disabled in the configuration (autoload.module = 0) (and if it exists)
14 # however, if it is disabled it will be silently ignored, and if it is unloaded at runtime it won't cause this one to unload.
15 #
16 # basically, softdeps are things this module will use if available, but does not require (no errors will occur if it's not loaded)
17 # for example, @lib.help() will attempt to use the help module, but swallow errors if it is not loaded
18
19 # preamble
20 import modlib
21 lib = modlib.modlib(__name__)
22 modstart = lib.modstart
23 modstop = lib.modstop
24
25 # module code
26 @lib.hook(needchan=False) #since no cmd= is provided, defaults to function name
27 @lib.help('<args>', 'tells you what you said')
28 def test(bot, user, chan, realtarget, *args):
29 if chan is not None and realtarget == chan.name: replyto = chan
30 else: replyto = user
31
32 bot.msg(replyto, "You said: %s" % (' '.join([str(arg) for arg in args])))
33
34 @lib.hook(('foo', 'bar'), needchan=False) #hooks !foo and !bar as aliases
35 @lib.help(None, 'replies with nonsense.', "it's a very non-sensical command", "more lines")
36 def foobar(bot, user, chan, realtarget, *args):
37 bot.msg(user, "Foo bar baz.")
38
39 @lib.hook()
40 @lib.help(None, 'a command that does nothing but requires you specify a channel')
41 def needchan(bot, user, chan, realtarget, *args):
42 bot.msg(user, "You did it!")