pubmsg handler, uses most admin commands so far (may do all of them soon, after i add bot prefixing)
This commit is contained in:
parent
934e8e3fe8
commit
51659c6078
24
dr.botzo.py
24
dr.botzo.py
@ -118,6 +118,29 @@ def on_privmsg(connection, event):
|
|||||||
sub_quit_channel(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
sub_quit_channel(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||||
sub_autojoin_manipulate(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
|
# init
|
||||||
#####
|
#####
|
||||||
@ -151,6 +174,7 @@ server = irc.server().connect(server, port, nick, ircname)
|
|||||||
# install handlers
|
# install handlers
|
||||||
server.add_global_handler("welcome", on_connect)
|
server.add_global_handler("welcome", on_connect)
|
||||||
server.add_global_handler('privmsg', on_privmsg)
|
server.add_global_handler('privmsg', on_privmsg)
|
||||||
|
server.add_global_handler('pubmsg', on_pubmsg)
|
||||||
|
|
||||||
# loop forever
|
# loop forever
|
||||||
irc.process_forever()
|
irc.process_forever()
|
||||||
|
Loading…
Reference in New Issue
Block a user