1 # synarere -- a highly modular and stable IRC bot.
2 # Copyright (C) 2010 Michael Rodriguez.
3 # Rights to this code are documented in docs/LICENSE.
7 # Import required source module.
8 from core
import command
10 def on_topic(conn
, origin
, parv
):
11 '''Handle the TOPIC command.'''
15 dictionary
['who'] = origin
.split('!')[0] # the nick of the person who set the topic
16 dictionary
['where'] = parv
[0] # which channel the topic was set in
17 dictionary
['what'] = ' '.join(parv
[1:]) # the new topic of the channel
19 # the bot will have to be in #spying for this to work..
20 conn
.privmsg('#spying', '%(who)s set the topic of %(where)s to %(what)r!' % dictionary
)
22 def chan_example(conn
, (nick
, user
, host
), target
, message
):
23 '''Handle the .example channel command.'''
25 conn
.privmsg(target
, '%s: Example chan command succeeded.' % nick
)
27 def chanme_example(conn
, (nick
, user
, host
), target
, message
):
28 '''Handle the example channel command where the bot is addressed.'''
30 conn
.privmsg(target
, '%s: Example chanme command succeeded.' % nick
)
34 '''Module entry point.'''
36 # There are several types of commands you may create.
37 # The following are available:
39 # irc -- Raw IRC commands. AWAY, KICK, etc.
40 # chan -- Channel commands, for example: '.register'.
41 # chanme -- Same as chan, except the bot's nick is prepended. Example: <user> synarere: register
42 # priv -- Private message commands.
43 # ctcp -- CTCP commands.
45 # NOTE: For irc, these are top priority, so you should use command.add_first() instead of command.add()!
47 command
.add_first('TOPIC', on_topic
, command
.irc
)
48 command
.add('.example', chan_example
, command
.chan
)
49 command
.add('example', chanme_example
, command
.chanme
)
52 '''Module exit point.'''
54 # NOTE: You must destroy all you created, else memory will be used unnecessarily!
56 command
.delete_first('TOPIC', on_topic
, command
.irc
)
57 command
.delete('.example', chan_example
, command
.chan
)
58 command
.delete('example', cmdme_currtopic
, command
.chanme
)