3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 04:02:45 +01:00

utils: simplify prefix modes handling in applyModes

This commit is contained in:
James Lu 2016-03-19 17:47:23 -07:00
parent e8b0018585
commit d84cfbcda1

View File

@ -297,16 +297,15 @@ def applyModes(irc, target, changedmodes):
# if the IRCd supports this mode and it is the one being set, add/remove # if the IRCd supports this mode and it is the one being set, add/remove
# the person from the corresponding prefix mode list (e.g. c.prefixmodes['op'] # the person from the corresponding prefix mode list (e.g. c.prefixmodes['op']
# for ops). # for ops).
for pmode in ('owner', 'admin', 'op', 'halfop', 'voice'): for pmode, pmodelist in irc.channels[target].prefixmodes.items():
if pmode in irc.cmodes and real_mode[0] == irc.cmodes[pmode]: if pmode in irc.cmodes and real_mode[0] == irc.cmodes[pmode]:
pmodelist = irc.channels[target].prefixmodes[pmode] log.debug('(%s) Initial prefixmodes list: %s', irc.name, pmodelist)
log.debug('(%s) Initial prefixmodes list: %s', irc.name, irc.channels[target].prefixmodes)
if mode[0][0] == '+': if mode[0][0] == '+':
pmodelist.add(mode[1]) pmodelist.add(mode[1])
else: else:
pmodelist.discard(mode[1]) pmodelist.discard(mode[1])
log.debug('(%s) Final prefixmodes list: %s', irc.name, irc.channels[target].prefixmodes) log.debug('(%s) Final prefixmodes list: %s', irc.name, pmodelist)
if real_mode[0] in irc.prefixmodes: if real_mode[0] in irc.prefixmodes:
# Don't add prefix modes to IrcChannel.modes; they belong in the # Don't add prefix modes to IrcChannel.modes; they belong in the