Skip to content

Commit

Permalink
Use bot.channels in lieu of removed bot.privileges attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
dgw committed Jun 21, 2024
1 parent 01467cf commit 272091d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions sopel_chanlogs/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ def log_quit(bot, trigger):
"""Log quits"""
tpl = bot.config.chanlogs.quit_template or QUIT_TPL
logline = _format_template(tpl, bot, trigger)
# make a copy of bot.privileges that we can safely iterate over
privcopy = list(bot.privileges.items())
# make a copy of Sopel's channel list that we can safely iterate over
channels_copy = list(bot.channels.values())
# write logline to *all* channels that the user was present in
for channel, privileges in privcopy:
if trigger.nick in privileges:
fpath = get_fpath(bot, trigger, channel)
for channel in channels_copy:
if trigger.nick in channel.users:
fpath = get_fpath(bot, trigger, channel.name)
with bot.memory['chanlog_locks'][fpath]:
with open(fpath, "ab") as f:
f.write(logline.encode('utf8'))
Expand All @@ -204,12 +204,12 @@ def log_nick_change(bot, trigger):
logline = _format_template(tpl, bot, trigger)
old_nick = trigger.nick
new_nick = trigger.sender
# make a copy of bot.privileges that we can safely iterate over
privcopy = list(bot.privileges.items())
# make a copy of Sopel's channel list that we can safely iterate over
channels_copy = list(bot.channels.values())
# 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, trigger, channel)
for channel in channels_copy:
if old_nick in channel.users or new_nick in channel.users:
fpath = get_fpath(bot, trigger, channel.name)
with bot.memory['chanlog_locks'][fpath]:
with open(fpath, "ab") as f:
f.write(logline.encode('utf8'))
Expand Down

0 comments on commit 272091d

Please sign in to comment.