-@lib.hook('test')
-def cmd_test(bot, user, chan, realtarget, *args):
- bot.msg(chan, "You said: !test %s" % (' '.join([str(arg) for arg in args])))
+@lib.hook(needchan=False, wantchan=True) #since no cmd= is provided, defaults to function name
+@lib.help('<args>', 'tells you what you said')
+def test(bot, user, chan, realtarget, *args):
+ if chan is not None: replyto = chan
+ else: replyto = user
+
+ bot.msg(replyto, "You said: %s" % (' '.join([str(arg) for arg in args])))
+
+@lib.hook(('foo', 'bar'), needchan=False) #hooks !foo and !bar as aliases
+@lib.help(None, 'replies with nonsense.', "it's a very non-sensical command", "more lines")
+def foobar(bot, user, chan, realtarget, *args):
+ bot.msg(user, "Foo bar baz.")
+
+@lib.hook()
+@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')
+ if chan is not None:
+ bot.msg(user, "Channel provided: %s" % (chan))
+ else:
+ bot.msg(user, "No channel provided")