From f8ca65cabc1eb92e2f3f3971d1fb07e85255517f Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 5 Jul 2016 00:41:15 -0700 Subject: [PATCH] Irc: warn when applyModes target doesn't exist This can happen when a network disconnects while spawnClient is setting modes on a newly spawned client, for example... --- classes.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/classes.py b/classes.py index d3e8753..0ee1a4b 100644 --- a/classes.py +++ b/classes.py @@ -644,10 +644,13 @@ class Irc(): else: modelist.discard(real_mode) log.debug('(%s) Final modelist: %s', self.name, modelist) - if usermodes: - self.users[target].modes = modelist - else: - self.channels[target].modes = modelist + try: + if usermodes: + self.users[target].modes = modelist + else: + self.channels[target].modes = modelist + except KeyError: + log.warning("(%s) Invalid MODE target %s (usermodes=%s)", self.name, target, usermodes) @staticmethod def _flip(mode):