Skip to content

Commit

Permalink
Only write quit events on channels that actually had the user in it
Browse files Browse the repository at this point in the history
Should prevent the quit messages from showing up in all channel logs.
  • Loading branch information
FiXato committed Jun 8, 2012
1 parent 5cdb575 commit 3b878cc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions logbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ def format_event(self, name, event, params):

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:
Expand Down Expand Up @@ -352,7 +352,11 @@ def on_privmsg(self, c, e):
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)
Expand Down

0 comments on commit 3b878cc

Please sign in to comment.