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