From 930cd6bc11ffd05f92889232051ad851ae4892db Mon Sep 17 00:00:00 2001 From: "Filip H.F. \"FiXato\" Slagter" Date: Sat, 9 Jun 2012 01:17:08 +0200 Subject: Force channel log filenames to be lowercase when appending to logs In some rare cases a logfile with a different capitalisation was still being created. --- logbot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/logbot.py b/logbot.py index 298782b..322031d 100755 --- a/logbot.py +++ b/logbot.py @@ -249,6 +249,9 @@ class Logbot(SingleServerIRCBot): def append_log_msg(self, channel, msg): print "%s >>> %s" % (channel, msg) + #Make sure the channel is always lowercase to prevent logs with other capitalisations to be created + channel_title = channel + channel = channel.lower() # Create the channel path if necessary chan_path = "%s/%s" % (LOG_FOLDER, channel) @@ -256,7 +259,7 @@ class Logbot(SingleServerIRCBot): os.makedirs(chan_path) # Create channel index - write_string("%s/index.html" % chan_path, html_header.replace("%title%", "%s | Logs" % channel)) + write_string("%s/index.html" % chan_path, html_header.replace("%title%", "%s | Logs" % channel_title)) # Append channel to log index append_line("%s/index.html" % LOG_FOLDER, '%s' % (channel.replace("#", "%23"), channel)) @@ -268,7 +271,7 @@ class Logbot(SingleServerIRCBot): # Create the log date index if it doesnt exist if not os.path.exists(log_path): - write_string(log_path, html_header.replace("%title%", "%s | Logs for %s" % (channel, date))) + write_string(log_path, html_header.replace("%title%", "%s | Logs for %s" % (channel_title, date))) # Append date log append_line("%s/index.html" % chan_path, '%s' % (date, date)) -- cgit v1.2.3-70-g09d2