From 5cdb5750858bb344f86d5dada08614f91c63dcb1 Mon Sep 17 00:00:00 2001 From: "Filip H.F. \"FiXato\" Slagter" Date: Fri, 8 Jun 2012 23:44:16 +0200 Subject: Only write the nick change event on channels that actually have the nick on the channel This should prevent nick changes appearing in logs that don't have the user on the channel. --- logbot.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) mode change 100644 => 100755 logbot.py (limited to 'logbot.py') diff --git a/logbot.py b/logbot.py old mode 100644 new mode 100755 index 8691d9d..d7010b5 --- a/logbot.py +++ b/logbot.py @@ -199,7 +199,10 @@ class Logbot(SingleServerIRCBot): def write_event(self, name, event, params={}): # Format the event properly - chans = event.target() + if name == 'nick': + chans = params["%chan%"] + else: + chans = event.target() msg = self.format_event(name, event, params) msg = urlify2(msg) @@ -323,10 +326,15 @@ class Logbot(SingleServerIRCBot): }) def on_nick(self, c, e): - self.write_event("nick", e, - {"%old%" : nm_to_n(e.source()), - "%new%" : e.target(), - }) + old_nick = nm_to_n(e.source()) + # Only write the event on channels that actually had the user in the channel + for chan in self.channels: + if old_nick in [x.lstrip('~%&@+') for x in self.channels[chan].users()]: + self.write_event("nick", e, + {"%old%" : old_nick, + "%new%" : e.target(), + "%chan%": chan, + }) def on_part(self, c, e): self.write_event("part", e) -- cgit v1.2.3-70-g09d2 From 3b878cc2ccaa3bec6dcd0ecf545baae0e3cce800 Mon Sep 17 00:00:00 2001 From: "Filip H.F. \"FiXato\" Slagter" Date: Sat, 9 Jun 2012 00:16:24 +0200 Subject: Only write quit events on channels that actually had the user in it Should prevent the quit messages from showing up in all channel logs. --- logbot.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'logbot.py') diff --git a/logbot.py b/logbot.py index d7010b5..298782b 100755 --- a/logbot.py +++ b/logbot.py @@ -199,14 +199,14 @@ class Logbot(SingleServerIRCBot): def write_event(self, name, event, params={}): # Format the event properly - if name == 'nick': + if name == 'nick' or name == 'quit': chans = params["%chan%"] else: chans = event.target() msg = self.format_event(name, event, params) msg = urlify2(msg) - # Quit goes across all channels + # In case there are still events that don't supply a channel name (like /quit and /nick did) if not chans or not chans.startswith("#"): chans = self.chans else: @@ -352,7 +352,11 @@ class Logbot(SingleServerIRCBot): c.privmsg(nm_to_n(e.source()), self.format["help"]) def on_quit(self, c, e): - self.write_event("quit", e) + nick = nm_to_n(e.source()) + # Only write the event on channels that actually had the user in the channel + for chan in self.channels: + if nick in [x.lstrip('~%&@+') for x in self.channels[chan].users()]: + self.write_event("quit", e, {"%chan%" : chan}) def on_topic(self, c, e): self.write_event("topic", e) -- cgit v1.2.3-70-g09d2 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(-) (limited to 'logbot.py') 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 From 9b30109af83121b675b03c9b27dc895fc8426fe4 Mon Sep 17 00:00:00 2001 From: "Filip H.F. \"FiXato\" Slagter" Date: Sat, 9 Jun 2012 01:37:15 +0200 Subject: Use the channel_title in one more position Update for the lowercase channelname fix. --- logbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'logbot.py') diff --git a/logbot.py b/logbot.py index 322031d..3e54ec8 100755 --- a/logbot.py +++ b/logbot.py @@ -262,7 +262,7 @@ class Logbot(SingleServerIRCBot): 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)) + append_line("%s/index.html" % LOG_FOLDER, '%s' % (channel.replace("#", "%23"), channel_title)) # Current log time = strftime("%H:%M:%S") -- cgit v1.2.3-70-g09d2