3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 21:19:31 +01:00

utils: also don't crash in applyModes for bad mode targets

This commit is contained in:
James Lu 2016-03-26 18:14:53 -07:00
parent e70dfb0811
commit 305db9f754

View File

@ -285,12 +285,18 @@ def applyModes(irc, target, changedmodes):
The target can be either a channel or a user; this is handled automatically."""
usermodes = not isChannel(target)
log.debug('(%s) Using usermodes for this query? %s', irc.name, usermodes)
if usermodes:
old_modelist = irc.users[target].modes
supported_modes = irc.umodes
else:
old_modelist = irc.channels[target].modes
supported_modes = irc.cmodes
try:
if usermodes:
old_modelist = irc.users[target].modes
supported_modes = irc.umodes
else:
old_modelist = irc.channels[target].modes
supported_modes = irc.cmodes
except KeyError:
log.warning('(%s) Possible desync? Mode target %s is unknown.', irc.name, target)
return
modelist = set(old_modelist)
log.debug('(%s) Applying modes %r on %s (initial modelist: %s)', irc.name, changedmodes, target, modelist)
for mode in changedmodes: