diff --git a/plugins/Topic.py b/plugins/Topic.py index 098f06334..9827acf3b 100644 --- a/plugins/Topic.py +++ b/plugins/Topic.py @@ -201,28 +201,28 @@ class Topic(callbacks.Privmsg): irc.reply(topic) topic = wrap(topic, ['inChannel']) - def add(self, irc, msg, args, channel, topic, insert=False): + def add(self, irc, msg, args, channel, topic): """[] Adds to the topics for . is only necessary if the message isn't sent in the channel itself. """ topics = self._splitTopic(irc.state.getTopic(channel), channel) - if insert: - topics.insert(0, topic) - else: - topics.append(topic) + topics.append(topic) self._sendTopics(irc, channel, topics) add = wrap(add, ['canChangeTopic', rest('topic')]) - def insert(self, irc, msg, args): + def insert(self, irc, msg, args, channel, topic): """[] Adds to the topics for at the beginning of the topics currently on . is only necessary if the message isn't sent in the channel itself. """ - self.add(irc, msg, args, insert=True) + topics = self._splitTopic(irc.state.getTopic(channel), channel) + topics.insert(0, topic) + self._sendTopics(irc, channel, topics) + insert = wrap(insert, ['canChangeTopic', rest('topic')]) def shuffle(self, irc, msg, args, channel): """[] diff --git a/test/test_Topic.py b/test/test_Topic.py index 9a5eb785a..9fab6cb3d 100644 --- a/test/test_Topic.py +++ b/test/test_Topic.py @@ -61,6 +61,12 @@ class TopicTestCase(ChannelPluginTestCase, PluginDocumentation): self.assertEqual(m.args[0], self.channel) self.assertEqual(m.args[1], 'foo (test) || bar (test)') + def testInsert(self): + m = self.getMsg('topic add foo') + self.assertEqual(m.args[1], 'foo (test)') + m = self.getMsg('topic insert bar') + self.assertEqual(m.args[1], 'bar (test) || foo (test)') + def testChange(self): _ = self.getMsg('topic add foo') _ = self.getMsg('topic add bar')