From 226ad6709e4b5c071bb9f4e8e9497895339346fb Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Sun, 25 Jul 2010 10:09:48 -0500 Subject: [PATCH] command to save the config file without quitting. mostly using for debugging, but probably interesting in general --- dr.botzo.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dr.botzo.py b/dr.botzo.py index 70d4e71..22699b2 100755 --- a/dr.botzo.py +++ b/dr.botzo.py @@ -97,6 +97,17 @@ def sub_report_seen(connection, event, nick, userhost, replypath, what, admin_un connection.privmsg(replypath, 'last saw ' + query + ' at ' + converted.strftime("%Y/%m/%d %H:%M:%S") + ' saying \'' + seendata[2] + '\'') except NoOptionError: pass +##### +# sub_save_config +# save the config file +##### + +def sub_save_config(connection, event, nick, userhost, replypath, what, admin_unlocked): + if what.split(' ')[0] == 'save' and admin_unlocked: + with open('dr.botzo.cfg', 'w') as cfg: + config.write(cfg) + connection.privmsg(replypath, 'saved config file') + ##### # on_connect # handler for when the bot has connected to IRC @@ -140,6 +151,7 @@ def on_privmsg(connection, event): sub_part_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_save_config(connection, event, nick, userhost, replypath, what, admin_unlocked) # standard commands sub_report_seen(connection, event, nick, userhost, replypath, what, admin_unlocked) @@ -178,6 +190,7 @@ def on_pubmsg(connection, event): sub_part_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_save_config(connection, event, nick, userhost, replypath, what, admin_unlocked) # standard commands sub_report_seen(connection, event, nick, userhost, replypath, what, admin_unlocked)