X-Git-Url: https://jfr.im/git/erebus.git/blobdiff_plain/a62d0d18bbb5926d22df18db5eba53eb21a10817..85267bc7ef709a102fbc2b2998ab29940538ead8:/modules/foo.py diff --git a/modules/foo.py b/modules/foo.py index bb56be0..f6e430c 100644 --- a/modules/foo.py +++ b/modules/foo.py @@ -1,4 +1,5 @@ # Erebus IRC bot - Author: Erebus Team +# vim: fileencoding=utf-8 # simple module example # This file is released into the public domain; see http://unlicense.org/ @@ -6,7 +7,7 @@ modinfo = { 'author': 'Erebus Team', 'license': 'public domain', - 'compatible': [1,2], # compatible module API versions + 'compatible': [0], # compatible module API versions 'depends': [], # other modules required to work properly? 'softdeps': ['help'], # modules which are preferred but not required } @@ -23,10 +24,10 @@ modstart = lib.modstart modstop = lib.modstop # module code -@lib.hook(needchan=False) #since no cmd= is provided, defaults to function name +@lib.hook(needchan=False, wantchan=True) #since no cmd= is provided, defaults to function name @lib.help('', 'tells you what you said') def test(bot, user, chan, realtarget, *args): - if chan is not None and realtarget == chan.name: replyto = chan + if chan is not None: replyto = chan else: replyto = user bot.msg(replyto, "You said: %s" % (' '.join([str(arg) for arg in args]))) @@ -40,3 +41,11 @@ def foobar(bot, user, chan, realtarget, *args): @lib.help(None, 'a command that does nothing but requires you specify a channel') def needchan(bot, user, chan, realtarget, *args): bot.msg(user, "You did it!") + +@lib.hook(needchan=False, wantchan=True) +@lib.help(None, 'a command which will consume a channel if given') +def wantchan(bot, user, chan, realtarget, *args): + if chan is not None: + bot.msg(user, "Channel provided: %s" % (chan)) + else: + bot.msg(user, "No channel provided")