command to change the bot's nick, refer to that rather than the original config option when needed

This commit is contained in:
Brian S. Stephan 2010-07-25 10:24:15 -05:00
parent 226ad6709e
commit 93c86257a0
1 changed files with 14 additions and 1 deletions

View File

@ -108,6 +108,17 @@ def sub_save_config(connection, event, nick, userhost, replypath, what, admin_un
config.write(cfg)
connection.privmsg(replypath, 'saved config file')
#####
# sub_change_nick
# change the bot's nickname
#####
def sub_change_nick(connection, event, nick, userhost, replypath, what, admin_unlocked):
if what.split(' ')[0] == 'nick' and admin_unlocked:
newnick = what.split(' ')[1]
connection.nick(newnick)
connection.privmsg(replypath, 'changed nickname')
#####
# on_connect
# handler for when the bot has connected to IRC
@ -152,6 +163,7 @@ 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)
sub_save_config(connection, event, nick, userhost, replypath, what, admin_unlocked)
sub_change_nick(connection, event, nick, userhost, replypath, what, admin_unlocked)
# standard commands
sub_report_seen(connection, event, nick, userhost, replypath, what, admin_unlocked)
@ -177,7 +189,7 @@ def on_pubmsg(connection, event):
sub_add_to_seen(connection, event, nick, userhost, what)
# only do commands if the bot has been addressed directly
addressed_pattern = '^' + botnick + '[:,]?\s+'
addressed_pattern = '^' + connection.get_nickname() + '[:,]?\s+'
addressed_re = re.compile(addressed_pattern)
if not addressed_re.match(what):
@ -191,6 +203,7 @@ def on_pubmsg(connection, event):
sub_quit_channel(connection, event, nick, userhost, replypath, what, admin_unlocked)
sub_autojoin_manipulate(connection, event, nick, userhost, replypath, what, admin_unlocked)
sub_save_config(connection, event, nick, userhost, replypath, what, admin_unlocked)
sub_change_nick(connection, event, nick, userhost, replypath, what, admin_unlocked)
# standard commands
sub_report_seen(connection, event, nick, userhost, replypath, what, admin_unlocked)