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