]>
jfr.im git - erebus.git/blob - 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/
7 'author': 'Erebus Team',
8 'license': 'public domain',
9 'compatible': [0], # compatible module API versions
10 'depends': [], # other modules required to work properly?
11 'softdeps': ['help'], # modules which are preferred but not required
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.
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
21 lib
= modlib
.modlib(__name__
)
22 modstart
= lib
.modstart
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')
28 def test(bot
, user
, chan
, realtarget
, *args
):
29 if chan
is not None: replyto
= chan
32 bot
.msg(replyto
, "You said: %s" % (' '.join([str(arg
) for arg
in args
])))
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.")
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!")
44 @lib.hook(needchan
=False, wantchan
=True)
45 @lib.help(None, 'a command which will consume a channel if given')
47 bot
.msg(user
, "Channel provided: %s" % (chan
))
49 bot
.msg(user
, "No channel provided")