Skip to content

Commit

Permalink
coretasks: prevent KeyError when untracked user leaves
Browse files Browse the repository at this point in the history
Fixes #1005
  • Loading branch information
thomastanck authored and maxpowa committed May 25, 2016
1 parent 0ce0b17 commit 20eda29
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions sopel/coretasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ def track_join(bot, trigger):
user = bot.users.get(trigger.nick)
if user is None:
user = User(trigger.nick, trigger.user, trigger.host)
bot.users[trigger.nick] = user
bot.channels[trigger.sender].add_user(user)

if len(trigger.args) > 1 and trigger.args[1] != '*' and (
Expand Down
8 changes: 4 additions & 4 deletions sopel/tools/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ def __init__(self, name):
"""The topic of the channel."""

def clear_user(self, nick):
user = self.users[nick]
user.channels.pop(self.name, None)
del self.users[nick]
del self.privileges[nick]
user = self.users.pop(nick, None)
self.privileges.pop(nick, None)
if user != None:
user.channels.pop(self.name, None)

def add_user(self, user):
assert isinstance(user, User)
Expand Down

0 comments on commit 20eda29

Please sign in to comment.