Fix bug #1031277, exception in some Topic commands when trying to modify a

topic in a channel that the bot is not in.
This commit is contained in:
James Vega 2004-09-20 19:24:15 +00:00
parent e48b78787a
commit 535f4a164f
2 changed files with 5 additions and 1 deletions

View File

@ -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)

View File

@ -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')