From 66be8ffab9d9a279546ddf199512f9e78069c1bd Mon Sep 17 00:00:00 2001 From: Andrew Herbig Date: Wed, 21 Jul 2010 02:18:25 -0400 Subject: [PATCH] oh yeah, this.. still a wip though. --- modules/list.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 modules/list.py diff --git a/modules/list.py b/modules/list.py new file mode 100755 index 0000000..c1c02eb --- /dev/null +++ b/modules/list.py @@ -0,0 +1,51 @@ +# synarere -- a highly modular and stable IRC bot. +# Copyright (C) 2010 Michael Rodriguez. +# Rights to this code are documented in docs/LICENSE. + +'''Example module.''' + +# Import required source module. +from core import command, shutdown +import pprint + +def list_end(conn, origin, parv): + '''Handle the TOPIC command.''' + global channels + pprint.pprint(channels) + del channels + +def list_chan(conn, origin, parv): + global channels + groups = re.match(r'^(.+) (\d+) :(.*)', parv[1]).groups() + channels.append(groups) + +def cmd_list(conn, (nick, user, host), target, message): + '''Handle the .example channel command.''' + global channels + channels = [] + command.add('323', list_end, command.irc) + command.add('322', list_chan, command.irc) + conn.push('LIST') + +def module_init(): + '''Module entry point.''' + + # There are several types of commands you may create. + # The following are available: + # + # irc -- Raw IRC commands. AWAY, KICK, etc. + # chan -- Channel commands, for example: '.register'. + # chanme -- Same as chan, except the bot's nick is prepended. Example: synarere: register + # priv -- Private message commands. + # ctcp -- CTCP commands. + # + # NOTE: For irc, these are top priority, so you should use command.add_first() instead of command.add()! + + command.add('.list', cmd_list, command.chan) + +def module_fini(): + '''Module exit point.''' + + # NOTE: You must destroy all you created, else memory will be used unnecessarily! + + command.delete('.list', cmd_list, command.chan) -- 2.11.4.GIT