Current version
Git/Latestdiff: 1.5.6
Latest Snapshots
Produced after each commit or rebase to new upstream version
GIT
RSBAC source code, can be unstable sometimes
No events planned
This shows you the differences between two versions of the page.
team:kang:bot [2005/11/08 21:41] kang added colors |
team:kang:bot [2006/05/02 15:40] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Module registration ===== | ||
- | <code python> | ||
- | # Module loading file | ||
- | # Add the lines with YOURMODULE, your module should also be present | ||
- | # in the module loader path (best is in './modules') | ||
- | # | ||
- | # Skeleton: | ||
- | # __import__("YOURMODULE", globals(), locals(), []) | ||
- | # mod_list = ["mantis", "YOURMODULE"] | ||
- | import sys | ||
- | sys.path.append('./modules') | ||
- | |||
- | __import__("mantis", globals(), locals(), []) | ||
- | __import__("roulette", globals(), locals(), []) | ||
- | |||
- | |||
- | mod_list = ["mantis", "roulette"] | ||
- | </code> | ||
- | |||
- | ===== Module itself ===== | ||
- | |||
- | Skeleton: | ||
- | |||
- | <code python> | ||
- | import os, sys | ||
- | |||
- | __info__ = { 'author': 'kang', | ||
- | 'email': 'kang@insecure.ws', | ||
- | 'version': '1', | ||
- | 'date': '07-11-2005' } | ||
- | |||
- | chan_handlers = [] | ||
- | msg_handlers = [] | ||
- | |||
- | def init(): | ||
- | |||
- | def chanmsg_handler(nick, cmd, args): | ||
- | |||
- | def privmsg_handler(nick, msg): | ||
- | |||
- | def die(): | ||
- | |||
- | |||
- | </code> | ||
- | |||
- | |||
- | Module Sample: | ||
- | |||
- | <code python> | ||
- | import os, sys | ||
- | import random | ||
- | __info__ = { 'author': 'kang', | ||
- | 'email': 'kang@insecure.ws', | ||
- | 'version': '1', | ||
- | 'date': '07-11-2005' } | ||
- | |||
- | chan_handlers = ['!roulette'] | ||
- | msg_handlers = [] | ||
- | |||
- | gun_max_load = 6 | ||
- | gun_bullet_slot = random.randint(1, gun_max_load) | ||
- | gun_current_slot = 0 | ||
- | |||
- | |||
- | def init(): | ||
- | gun_max_load = 6 | ||
- | gun_bullet_slot = random.randint(1, gun_max_load) | ||
- | gun_current_slot = 0 | ||
- | |||
- | def chanmsg_handler(channel, nick, cmd, args): | ||
- | r = sys.modules['roulette'] | ||
- | r.gun_current_slot = r.gun_current_slot + 1 | ||
- | if r.gun_current_slot == r.gun_bullet_slot: | ||
- | action = 'PRIVMSG %s :*BANG*. %s is lying on the floor.\r\n' % (channel, nick) | ||
- | r.gun_bullet_slot = random.randint(1, r.gun_max_load) | ||
- | r.gun_current_slot = 0 | ||
- | else: | ||
- | action = 'PRIVMSG %s :*clic*\r\n' % (channel) | ||
- | return action | ||
- | |||
- | </code> |