pubmsg handler, uses most admin commands so far (may do all of them soon, after i add bot prefixing)

This commit is contained in:
Brian S. Stephan 2010-07-25 08:20:58 -05:00
parent 934e8e3fe8
commit 51659c6078

View File

@ -118,6 +118,29 @@ def on_privmsg(connection, event):
sub_quit_channel(connection, event, nick, userhost, replypath, what, admin_unlocked)
sub_autojoin_manipulate(connection, event, nick, userhost, replypath, what, admin_unlocked)
#####
# on_pubmsg
# public messages in a channel where the bot is
#####
def on_pubmsg(connection, event):
nick = irclib.nm_to_n(event.source())
userhost = irclib.nm_to_uh(event.source())
replypath = event.target()
what = event.arguments()[0]
admin_unlocked = False
try:
if userhost == config.get('admin', 'userhost'):
admin_unlocked = True
except NoOptionError: pass
# admin commands
sub_join_channel(connection, event, nick, userhost, replypath, what, admin_unlocked)
sub_part_channel(connection, event, nick, userhost, replypath, what, admin_unlocked)
sub_autojoin_manipulate(connection, event, nick, userhost, replypath, what, admin_unlocked)
#####
# init
#####
@ -151,6 +174,7 @@ server = irc.server().connect(server, port, nick, ircname)
# install handlers
server.add_global_handler("welcome", on_connect)
server.add_global_handler('privmsg', on_privmsg)
server.add_global_handler('pubmsg', on_pubmsg)
# loop forever
irc.process_forever()