]> jfr.im git - erebus.git/blame_incremental - modules/foo.py
fix error
[erebus.git] / modules / foo.py
... / ...
CommitLineData
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
6modinfo = {
7 'author': 'Erebus Team',
8 'license': 'public domain',
9 'compatible': [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
20import modlib
21lib = modlib.modlib(__name__)
22modstart = lib.modstart
23modstop = lib.modstop
24
25# module code
26@lib.hook(needchan=False, wantchan=True) #since no cmd= is provided, defaults to function name
27@lib.help('<args>', 'tells you what you said')
28def test(bot, user, chan, realtarget, *args):
29 if chan is not None: 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")
36def 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')
41def needchan(bot, user, chan, realtarget, *args):
42 bot.msg(user, "You did it!")
43
44@lib.hook(needchan=False, wantchan=True)
45@lib.help(None, 'a command which will consume a channel if given')
46 if chan is not None:
47 bot.msg(user, "Channel provided: %s" % (chan))
48 else:
49 bot.msg(user, "No channel provided")