diff --git a/plugins/Topic.py b/plugins/Topic.py index f25cc70e1..cd6fcbad5 100644 --- a/plugins/Topic.py +++ b/plugins/Topic.py @@ -142,7 +142,10 @@ class Topic(callbacks.Privmsg): irc.queueMsg(ircmsgs.topic(channel, newTopic)) def _canChangeTopic(self, irc, channel): - c = irc.state.channels[channel] + try: + c = irc.state.channels[channel] + except KeyError: + irc.error('I\'m not currently in %s.' % channel, Raise=True) if irc.nick not in c.ops and 't' in c.modes: irc.error('I can\'t change the topic, I\'m not opped and %s ' 'is +t.' % channel, Raise=True) diff --git a/test/test_Topic.py b/test/test_Topic.py index 9357e6e4e..7801bd9bf 100644 --- a/test/test_Topic.py +++ b/test/test_Topic.py @@ -58,6 +58,7 @@ class TopicTestCase(ChannelPluginTestCase, PluginDocumentation): m = self.getMsg('topic add bar') self.assertEqual(m.command, 'TOPIC') self.assertEqual(m.args[0], self.channel) + self.assertError('topic add #floorgle') def testChange(self): _ = self.getMsg('topic add foo')