Improve a few minor things.

Prevents "Unhandled command <stuff>" 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.
This commit is contained in:
Vgr E.Barry 2015-01-04 18:48:25 -05:00
parent 4cc26e3ac2
commit cecf1c6fc5
3 changed files with 6 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import imp
from tools import logger from tools import logger
log = logger("errors.log") log = logger("errors.log")
alog = logger(None)
def on_privmsg(cli, rawnick, chan, msg, notice = False): def on_privmsg(cli, rawnick, chan, msg, notice = False):
currmod = ld.MODULES[ld.CURRENT_MODULE] currmod = ld.MODULES[ld.CURRENT_MODULE]
@ -73,7 +74,7 @@ def __unhandled__(cli, prefix, cmd, *args):
log(traceback.format_exc()) log(traceback.format_exc())
cli.msg(botconfig.CHANNEL, "An error has occurred and has been logged.") cli.msg(botconfig.CHANNEL, "An error has occurred and has been logged.")
elif botconfig.VERBOSE_MODE or botconfig.DEBUG_MODE: 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 = {} COMMANDS = {}

View File

@ -278,6 +278,7 @@ def mass_mode(cli, md):
def pm(cli, target, message): # message either privmsg or notice, depending on user settings def pm(cli, target, message): # message either privmsg or notice, depending on user settings
if is_fake_nick(target) and botconfig.DEBUG_MODE: if is_fake_nick(target) and botconfig.DEBUG_MODE:
debuglog("would message fake nick {0}: {1}".format(target, message))
return return
if is_user_notice(target): if is_user_notice(target):
@ -5416,6 +5417,7 @@ def start(cli, nick, chan, forced = False):
return return
else: else:
cli.msg(chan, "This role has been skipped for this game.") cli.msg(chan, "This role has been skipped for this game.")
var.ROLES[template] = []
continue continue
var.ROLES[template] = random.sample(possible, len(var.ROLES[template])) var.ROLES[template] = random.sample(possible, len(var.ROLES[template]))

View File

@ -20,6 +20,8 @@ def get_timestamp():
return tmf.format(tzname=tz, tzoffset=offset).upper() return tmf.format(tzname=tz, tzoffset=offset).upper()
def logger(file, write=True, display=True): 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): def log(*output, write=write, display=display):
output = " ".join([str(x) for x in output]) output = " ".join([str(x) for x in output])
if botconfig.DEBUG_MODE: if botconfig.DEBUG_MODE: