3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 04:02:45 +01:00

plugin_example: document the arguments each hook / command function takes

This commit is contained in:
James Lu 2015-08-09 01:06:00 -07:00
parent 7b69ff4733
commit 005789e85a

View File

@ -13,6 +13,14 @@ import random
# Example PRIVMSG hook that returns "hi there!" when PyLink's nick is mentioned
# in a channel.
# irc: The IRC object where the hook was called.
# source: The UID/numeric of the sender.
# command: The true command name where the hook originates. This may or may not be
# the same as the name of the hook, depending on context.
# args: The hook data (a dict) associated with the command. The available data
# keys differ by hook name (see the hooks reference for a list of which can
# be used).
def hook_privmsg(irc, source, command, args):
channel = args['target']
text = args['text']
@ -21,9 +29,13 @@ def hook_privmsg(irc, source, command, args):
log.info('%s said my name on channel %s (PRIVMSG hook caught)' % (source, channel))
utils.add_hook(hook_privmsg, 'PRIVMSG')
# Example command function. @utils.add_cmd binds it to an IRC command of the same name,
# but you can also use a different name by specifying a second 'name' argument (see below).
@utils.add_cmd
# irc: The IRC object where the command was called.
# source: The UID/numeric of the calling user.
# args: A list of command args (excluding the command name) that the command was called with.
def randint(irc, source, args):
"""[<min>] [<max>]
Returns a random number between <min> and <max>. <min> and <max> default