From a85fbead23c3b9e074f9ed2428870b312a612733 Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 10 Feb 2015 01:38:29 -0500 Subject: [PATCH] Seen: prevent KeyError when calling commands on channels that the bot is not in This fixes a bug introdiced by 38ff1a1137. --- plugins/Seen/plugin.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/Seen/plugin.py b/plugins/Seen/plugin.py index 55e9c15c5..77fb08e2e 100644 --- a/plugins/Seen/plugin.py +++ b/plugins/Seen/plugin.py @@ -236,6 +236,8 @@ class Seen(callbacks.Plugin): if name and ircutils.strEqual(name, irc.nick): irc.reply(_("You've found me!")) return + if channel not in irc.state.channels: + irc.error(_("I'm not in %s." % channel), Raise=True) if msg.nick not in irc.state.channels[channel].users: irc.error(format('You must be in %s to use this command.', channel)) return @@ -256,6 +258,8 @@ class Seen(callbacks.Plugin): if name and ircutils.strEqual(name, irc.nick): irc.reply(_("You've found me!")) return + if channel not in irc.state.channels: + irc.error(_("I'm not in %s." % channel), Raise=True) if msg.nick not in irc.state.channels[channel].users: irc.error(format('You must be in %s to use this command.', channel)) return @@ -295,6 +299,8 @@ class Seen(callbacks.Plugin): Returns the last thing said in . is only necessary if the message isn't sent in the channel itself. """ + if channel not in irc.state.channels: + irc.error(_("I'm not in %s." % channel), Raise=True) if msg.nick not in irc.state.channels[channel].users: irc.error(format('You must be in %s to use this command.', channel)) return @@ -327,6 +333,8 @@ class Seen(callbacks.Plugin): is only necessary if the message isn't sent in the channel itself. """ + if channel not in irc.state.channels: + irc.error(_("I'm not in %s." % channel), Raise=True) if msg.nick not in irc.state.channels[channel].users: irc.error(format('You must be in %s to use this command.', channel)) return