From cecf1c6fc5024cea777214d66bec887358c138df Mon Sep 17 00:00:00 2001 From: "Vgr E.Barry" Date: Sun, 4 Jan 2015 18:48:25 -0500 Subject: [PATCH] Improve a few minor things. Prevents "Unhandled command " from writing to file, add back weird piece of code to prevent too many templates and "would send message to fake nick" message and creates file on startup if it doesn't exist. --- modules/common.py | 3 ++- modules/wolfgame.py | 2 ++ tools/__init__.py | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/common.py b/modules/common.py index 94ef372..5b12ec2 100644 --- a/modules/common.py +++ b/modules/common.py @@ -11,6 +11,7 @@ import imp from tools import logger log = logger("errors.log") +alog = logger(None) def on_privmsg(cli, rawnick, chan, msg, notice = False): currmod = ld.MODULES[ld.CURRENT_MODULE] @@ -73,7 +74,7 @@ def __unhandled__(cli, prefix, cmd, *args): log(traceback.format_exc()) cli.msg(botconfig.CHANNEL, "An error has occurred and has been logged.") elif botconfig.VERBOSE_MODE or botconfig.DEBUG_MODE: - log('Unhandled command {0}({1})'.format(cmd, [arg.decode('utf_8') for arg in args if isinstance(arg, bytes)]), write=False) + alog('Unhandled command {0}({1})'.format(cmd, [arg.decode('utf_8') for arg in args if isinstance(arg, bytes)])) COMMANDS = {} diff --git a/modules/wolfgame.py b/modules/wolfgame.py index 2fe570f..82def5e 100644 --- a/modules/wolfgame.py +++ b/modules/wolfgame.py @@ -278,6 +278,7 @@ def mass_mode(cli, md): def pm(cli, target, message): # message either privmsg or notice, depending on user settings if is_fake_nick(target) and botconfig.DEBUG_MODE: + debuglog("would message fake nick {0}: {1}".format(target, message)) return if is_user_notice(target): @@ -5416,6 +5417,7 @@ def start(cli, nick, chan, forced = False): return else: cli.msg(chan, "This role has been skipped for this game.") + var.ROLES[template] = [] continue var.ROLES[template] = random.sample(possible, len(var.ROLES[template])) diff --git a/tools/__init__.py b/tools/__init__.py index ee6a35b..bfc8047 100644 --- a/tools/__init__.py +++ b/tools/__init__.py @@ -20,6 +20,8 @@ def get_timestamp(): return tmf.format(tzname=tz, tzoffset=offset).upper() def logger(file, write=True, display=True): + if file is not None: + open(file, "a").close() # create the file if it doesn't exist def log(*output, write=write, display=display): output = " ".join([str(x) for x in output]) if botconfig.DEBUG_MODE: