diff --git a/bot.py b/bot.py index a56856e..6066049 100755 --- a/bot.py +++ b/bot.py @@ -18,7 +18,8 @@ bot = Bot() print 'Loading plugins' # bootstrap the reloader -eval(compile(open('core/reload.py', 'U').read(), 'core/reload.py', 'exec')) +eval(compile(open(os.path.join('core', 'reload.py'), 'U').read(), + os.path.join('core', 'reload.py'), 'exec')) reload(init=True) print 'Connecting to IRC' diff --git a/core/reload.py b/core/reload.py index dadec02..80510bf 100644 --- a/core/reload.py +++ b/core/reload.py @@ -1,7 +1,8 @@ -import glob import collections -import traceback +import glob +import os import sys +import traceback if 'mtimes' not in globals(): mtimes = {} @@ -19,7 +20,7 @@ def reload(init=False): if init: bot.plugs = collections.defaultdict(lambda: []) - for filename in glob.glob("core/*.py"): + for filename in glob.glob(os.path.join("core", "*.py")): mtime = os.stat(filename).st_mtime if mtime != mtimes.get(filename): mtimes[filename] = mtime @@ -32,11 +33,11 @@ def reload(init=False): sys.exit() # script on startup continue - if filename == 'core/reload.py': + if filename == os.path.join('core', 'reload.py'): reload(init=init) return - fileset = set(glob.glob("plugins/*py")) + fileset = set(glob.glob(os.path.join('plugins', '*py'))) for name, data in bot.plugs.iteritems(): # remove deleted/moved plugins bot.plugs[name] = filter(lambda x: x[0][0] in fileset, data) diff --git a/plugins/log.py b/plugins/log.py index ce27906..339fdf3 100644 --- a/plugins/log.py +++ b/plugins/log.py @@ -33,6 +33,8 @@ irc_color_re = re.compile(r'(\x03(\d+,\d+|\d)|[\x0f\x02\x16\x1f])') def get_log_filename(dir, server, chan): + if chan.startswith(':'): + chan = chan[1:] return os.path.join(dir, 'log', gmtime('%Y'), server, gmtime('%%s.%m-%d.log') % chan).lower() @@ -53,7 +55,6 @@ def beautify(input): args['msg'] = irc_color_re.sub('', args['msg']) if input.command == 'PRIVMSG' and input.msg.count('\x01') >= 2: - #ctcp ctcp = input.msg.split('\x01', 2)[1].split(' ', 1) if len(ctcp) == 1: ctcp += ['']