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
, shutdown
10 def on_topic(conn
, origin
, parv
):
11 '''Handle the TOPIC command.'''
13 who
= origin
.split('!')[0] # the nick of the person who set the topic
14 where
= parv
[0] # which channel the topic was set in
15 what
= ' '.join(parv
[1:]) # the new topic of the channel
17 # the bot will have to be in #spying for this to work..
18 conn
.privmsg('#spying', '%s set the topic of %s to %r!' % (who
, where
, what
))
20 def chan_example(conn
, (nick
, user
, host
), target
, message
):
21 '''Handle the .example channel command.'''
23 conn
.privmsg(target
, '%s: Example chan command succeeded.' % nick
)
26 def chanme_example(conn
, (nick
, user
, host
), target
, message
):
27 '''Handle the example channel command where the bot is addressed.'''
29 conn
.privmsg(target
, '%s: Example chanme command succeeded.' % nick
)
30 shutdown(0, 'testing')
33 '''Module entry point.'''
35 # There are several types of commands you may create.
36 # The following are available:
38 # irc -- Raw IRC commands. AWAY, KICK, etc.
39 # chan -- Channel commands, for example: '.register'.
40 # chanme -- Same as chan, except the bot's nick is prepended. Example: <user> synarere: register
41 # priv -- Private message commands.
42 # ctcp -- CTCP commands.
44 # NOTE: For irc, these are top priority, so you should use command.add_first() instead of command.add()!
46 command
.add_first('TOPIC', on_topic
, command
.irc
)
47 command
.add('.example', chan_example
, command
.chan
)
48 command
.add('example', chanme_example
, command
.chanme
)
51 '''Module exit point.'''
53 # NOTE: You must destroy all you created, else memory will be used unnecessarily!
55 command
.delete_first('TOPIC', on_topic
, command
.irc
)
56 command
.delete('.example', chan_example
, command
.chan
)
57 command
.delete('example', chanme_example
, command
.chanme
)