Skip to content

Commit

Permalink
Iterate over a copy of bot.privileges instead of the real thing
Browse files Browse the repository at this point in the history
  • Loading branch information
singingwolfboy committed Mar 17, 2014
1 parent af8cb99 commit 0459a95
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions chanlogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,10 @@ def log_part(bot, trigger):
def log_quit(bot, trigger):
tpl = bot.config.chanlogs.quit_template or QUIT_TPL
logline = _format_template(tpl, bot, trigger=trigger)
# write it to *all* channels that the user was present in
for channel, privileges in bot.privileges.items():
# make a copy of bot.privileges that we can safely iterate over
privcopy = list(bot.privileges.items())
# write logline to *all* channels that the user was present in
for channel, privileges in privcopy:
if bot.origin.nick in privileges:
fpath = get_fpath(bot, channel)
with bot.memory['chanlog_locks'][fpath]:
Expand All @@ -153,8 +155,10 @@ def log_nick_change(bot, trigger):
logline = _format_template(tpl, bot, trigger=trigger)
old_nick = bot.origin.nick
new_nick = bot.origin.sender
# write it to *all* channels that the user is present in
for channel, privileges in bot.privileges.items():
# make a copy of bot.privileges that we can safely iterate over
privcopy = list(bot.privileges.items())
# write logline to *all* channels that the user is present in
for channel, privileges in privcopy:
if old_nick in privileges or new_nick in privileges:
fpath = get_fpath(bot, channel)
with bot.memory['chanlog_locks'][fpath]:
Expand Down

0 comments on commit 0459a95

Please sign in to comment.