Fixed bug #1091927, Topic.insert was doing the same thing as Topic.add.

This commit is contained in:
Jeremy Fincher 2004-12-28 01:10:31 +00:00
parent 6002089619
commit 11c12e9062
2 changed files with 13 additions and 7 deletions

View File

@ -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):
"""[<channel>] <topic>
Adds <topic> to the topics for <channel>. <channel> 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):
"""[<channel>] <topic>
Adds <topic> to the topics for <channel> at the beginning of the topics
currently on <channel>. <channel> 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):
"""[<channel>]

View File

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