diff --git a/plugins/Topic.py b/plugins/Topic.py index 310f47b2b..4bcde203b 100644 --- a/plugins/Topic.py +++ b/plugins/Topic.py @@ -192,6 +192,15 @@ class Topic(callbacks.Privmsg): irc.queueMsg(ircmsgs.topic(channel, newTopic)) irc.noReply() + def doJoin(self, irc, msg): + if ircutils.strEqual(msg.nick, irc.nick): + # We're joining a channel, let's watch for the topic. + self.watchingFor332.add(msg.args[0]) + + def do332(self, irc, msg): + if msg.args[1] in self.watchingFor332: + self.watchingFor332.remove(msg.args[1]) + def topic(self, irc, msg, args, channel): """[] @@ -213,6 +222,16 @@ class Topic(callbacks.Privmsg): self._sendTopics(irc, channel, topics) add = wrap(add, ['canChangeTopic', rest('topic')]) + def replace(self, irc, msg, args, channel, i, topic): + """[] + + Replaces topic with . + """ + topics = self._splitTopic(irc.state.getTopic(channel), channel) + topics[i] = topic + self._sendTopics(irc, channel, topics) + replace = wrap(replace, ['canChangeTopic', 'topicNumber', rest('topic')]) + def insert(self, irc, msg, args, channel, topic): """[] diff --git a/test/test_Topic.py b/test/test_Topic.py index 9fab6cb3d..d71f47aa7 100644 --- a/test/test_Topic.py +++ b/test/test_Topic.py @@ -42,6 +42,16 @@ class TopicTestCase(ChannelPluginTestCase, PluginDocumentation): self.assertNotError('topic remove 1') self.assertError('topic remove 1') + def testReplace(self): + _ = self.getMsg('topic add foo') + _ = self.getMsg('topic add bar') + _ = self.getMsg('topic add baz') + self.assertRegexp('topic replace 1 oof', 'oof.*bar.*baz') + self.assertRegexp('topic replace -1 zab', 'oof.*bar.*zab') + self.assertRegexp('topic replace 2 lorem ipsum', + 'oof.*lorem ipsum.*zab') + self.assertRegexp('topic replace 2 rab', 'oof.*rab.*zab') + def testGet(self): self.assertError('topic get 1') _ = self.getMsg('topic add foo')