From 005789e85afd316e66abb083829d6cf29ca913fc Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 9 Aug 2015 01:06:00 -0700 Subject: [PATCH] plugin_example: document the arguments each hook / command function takes --- docs/technical/plugin_example.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/technical/plugin_example.py b/docs/technical/plugin_example.py index 130a9c8..1a174b2 100644 --- a/docs/technical/plugin_example.py +++ b/docs/technical/plugin_example.py @@ -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): """[] [] Returns a random number between and . and default