3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-30 14:49:28 +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.""" The target can be either a channel or a user; this is handled automatically."""
usermodes = not isChannel(target) usermodes = not isChannel(target)
log.debug('(%s) Using usermodes for this query? %s', irc.name, usermodes) log.debug('(%s) Using usermodes for this query? %s', irc.name, usermodes)
if usermodes:
old_modelist = irc.users[target].modes try:
supported_modes = irc.umodes if usermodes:
else: old_modelist = irc.users[target].modes
old_modelist = irc.channels[target].modes supported_modes = irc.umodes
supported_modes = irc.cmodes 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) modelist = set(old_modelist)
log.debug('(%s) Applying modes %r on %s (initial modelist: %s)', irc.name, changedmodes, target, modelist) log.debug('(%s) Applying modes %r on %s (initial modelist: %s)', irc.name, changedmodes, target, modelist)
for mode in changedmodes: for mode in changedmodes: