Skip to content

Commit 677cdbf

Browse files
authored
Merge pull request #2129 from sopel-irc/remove-bot.privileges
bot, coretasks: remove redundant `bot.privileges` data structure
2 parents ab59a36 + f01d622 commit 677cdbf

File tree

3 files changed

+1
-102
lines changed

3 files changed

+1
-102
lines changed

sopel/bot.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,6 @@ def __init__(self, config, daemon=False):
7878
For servers that do not support IRCv3, this will be an empty set.
7979
"""
8080

81-
self.privileges = dict()
82-
"""A dictionary of channels to their users and privilege levels.
83-
84-
The value associated with each channel is a dictionary of
85-
:class:`sopel.tools.Identifier`\\s to a bitwise integer value,
86-
determined by combining the appropriate constants from
87-
:mod:`sopel.plugin`.
88-
89-
.. deprecated:: 6.2.0
90-
Use :attr:`channels` instead. Will be removed in Sopel 8.
91-
"""
92-
9381
self.channels = tools.SopelIdentifierMemory()
9482
"""A map of the channels that Sopel is in.
9583

sopel/coretasks.py

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,6 @@ def handle_names(bot, trigger):
444444
if not channels:
445445
return
446446
channel = Identifier(channels.group(1))
447-
if channel not in bot.privileges:
448-
bot.privileges[channel] = {}
449447
if channel not in bot.channels:
450448
bot.channels[channel] = target.Channel(channel)
451449

@@ -479,7 +477,6 @@ def handle_names(bot, trigger):
479477
priv = priv | value
480478

481479
nick = Identifier(name.lstrip(''.join(mapping.keys())))
482-
bot.privileges[channel][nick] = priv
483480
user = bot.users.get(nick)
484481
if user is None:
485482
# The username/hostname will be included in a NAMES reply only if
@@ -593,31 +590,12 @@ def _parse_modes(bot, args, clear=False):
593590
# User privs modes, always have a param
594591
nick = Identifier(params[param_idx])
595592
priv = channel.privileges.get(nick, 0)
596-
# Log a warning if the two privilege-tracking data structures
597-
# get out of sync. That should never happen.
598-
# This is a good place to verify that bot.channels is doing
599-
# what it's supposed to do before ultimately removing the old,
600-
# deprecated bot.privileges structure completely.
601-
ppriv = bot.privileges[channel_name].get(nick, 0)
602-
if priv != ppriv:
603-
LOGGER.warning(
604-
(
605-
"Privilege data error! Please share Sopel's "
606-
"raw log with the developers, if enabled. "
607-
"(Expected %s == %s for %r in %r)"
608-
),
609-
priv,
610-
ppriv,
611-
nick,
612-
channel,
613-
)
614593
value = mapping.get(char)
615594
if value is not None:
616595
if sign == "+":
617596
priv = priv | value
618597
else:
619598
priv = priv & ~value
620-
bot.privileges[channel_name][nick] = priv
621599
channel.privileges[nick] = priv
622600
param_idx += 1
623601
else:
@@ -652,7 +630,7 @@ def track_nicks(bot, trigger):
652630
old = trigger.nick
653631
new = Identifier(trigger)
654632

655-
# Give debug mssage, and PM the owner, if the bot's own nick changes.
633+
# Give debug message, and PM the owner, if the bot's own nick changes.
656634
if old == bot.nick and new != bot.nick:
657635
privmsg = (
658636
"Hi, I'm your bot, %s. Something has made my nick change. This "
@@ -669,12 +647,6 @@ def track_nicks(bot, trigger):
669647
bot.say(privmsg, bot.config.core.owner)
670648
return
671649

672-
for channel in bot.privileges:
673-
channel = Identifier(channel)
674-
if old in bot.privileges[channel]:
675-
value = bot.privileges[channel].pop(old)
676-
bot.privileges[channel][new] = value
677-
678650
for channel in bot.channels.values():
679651
channel.rename_user(old, new)
680652
if old in bot.users:
@@ -715,7 +687,6 @@ def track_kick(bot, trigger):
715687

716688
def _remove_from_channel(bot, nick, channel):
717689
if nick == bot.nick:
718-
bot.privileges.pop(channel, None)
719690
bot.channels.pop(channel, None)
720691

721692
lost_users = []
@@ -726,8 +697,6 @@ def _remove_from_channel(bot, nick, channel):
726697
for nick_ in lost_users:
727698
bot.users.pop(nick_, None)
728699
else:
729-
bot.privileges[channel].pop(nick, None)
730-
731700
user = bot.users.get(nick)
732701
if user and channel in user.channels:
733702
bot.channels[channel].clear_user(nick)
@@ -793,7 +762,6 @@ def track_join(bot, trigger):
793762

794763
# is it a new channel?
795764
if channel not in bot.channels:
796-
bot.privileges[channel] = {}
797765
bot.channels[channel] = target.Channel(channel)
798766

799767
# did *we* just join?
@@ -812,8 +780,6 @@ def track_join(bot, trigger):
812780
str(channel), trigger.nick)
813781

814782
# set initial values
815-
bot.privileges[channel][trigger.nick] = 0
816-
817783
user = bot.users.get(trigger.nick)
818784
if user is None:
819785
user = target.User(trigger.nick, trigger.user, trigger.host)
@@ -832,8 +798,6 @@ def track_join(bot, trigger):
832798
@plugin.priority('medium')
833799
def track_quit(bot, trigger):
834800
"""Track when users quit channels."""
835-
for chanprivs in bot.privileges.values():
836-
chanprivs.pop(trigger.nick, None)
837801
for channel in bot.channels.values():
838802
channel.clear_user(trigger.nick)
839803
bot.users.pop(trigger.nick, None)
@@ -1384,9 +1348,6 @@ def _record_who(bot, channel, user, host, nick, account=None, away=None, modes=N
13841348
if channel not in bot.channels:
13851349
bot.channels[channel] = target.Channel(channel)
13861350
bot.channels[channel].add_user(usr, privs=priv)
1387-
if channel not in bot.privileges:
1388-
bot.privileges[channel] = {}
1389-
bot.privileges[channel][nick] = priv
13901351

13911352

13921353
@plugin.event(events.RPL_WHOREPLY)

test/test_regression.py

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)