-
Notifications
You must be signed in to change notification settings - Fork 3
veiset edited this page Mar 28, 2012
·
4 revisions
To get a module to be run it has to listen to some action. The main method can only be defined as taking one parameter, where the parameter name can be defined by the linking of the developers. Assuming that the main method is defined as:
def main(data):
... logic
Reference Description
data['type'] Returns the type of listener that invoked the data object.
data['channel'] Returns a string of the channel name, e.g. #brunobot.
data['nick'] The username (nick) of the user that invoked the listener.
data['ident'] The ident of the user that invoked the listener.
data['host'] The host of the user that invoked the listener.
listen = ['cmd']
Reference Description
data['type'] Returns the string 'cmd'.
data['cmd'] The command that was invoked.
data['argv'] Command arguments in a list splitted by space, or None if none was given.
listen = ['privmsg']
Reference Description
data['type'] Returns the string 'privmsg'.
data['msg'] The message that invoked the listener.
Using multiple listeners If you want to listen to both commands and to privmsgs, you have to firstly define that you are listening to both cmd and privmsgs.
listen = ['cmd','privmsg']
Then you have to check what kind of type the data object is of. To check what type of a data object is of, you can check the parameter data['type']
.
def main(data):
if data['type'] == 'cmd':
... code for handeling if its command
elif data['type'] == 'privmsg':
... code for handelig privmsgs