From 0143a41e4fbd7bd3fa67a63c74a496fdf482823c Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 24 Aug 2004 23:06:16 +0000 Subject: [PATCH] Changed the topic command to be topic.set-with-no-number. --- plugins/Topic.py | 23 ++++++++++------------- test/test_Topic.py | 6 ++---- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/plugins/Topic.py b/plugins/Topic.py index fb425a6ee..b6e6c8e3b 100644 --- a/plugins/Topic.py +++ b/plugins/Topic.py @@ -152,15 +152,6 @@ class Topic(callbacks.Privmsg): except (ValueError, IndexError): irc.error('That\'s not a valid topic number.', Raise=True) - def topic(self, irc, msg, args, channel): - """[] - - Sets the topic of to . - """ - topic = privmsgs.getArgs(args) - self._sendTopics(irc, channel, [topic]) - topic = privmsgs.channel(topic) - def add(self, irc, msg, args, channel, insert=False): """[] @@ -299,14 +290,20 @@ class Topic(callbacks.Privmsg): change = privmsgs.channel(change) def set(self, irc, msg, args, channel): - """[] + """[] [] - Sets the topic to be . is only necessary if - the message isn't sent in the channel itself. + Sets the topic to be . If no is given, this + sets the entire topic. is only necessary if the message + isn't sent in the channel itself. """ self._canChangeTopic(irc, channel) - (i, topic) = privmsgs.getArgs(args, required=2) + (i, topic) = privmsgs.getArgs(args, optional=1) topics = self._splitTopic(irc.state.getTopic(channel), channel) + try: + int(i) # If this isn't a number, do something else. + except ValueError: + self._sendTopics(irc, channel, [privmsgs.getArgs(args)]) + return i = self._topicNumber(irc, i, topics=topics) topic = self._formatTopic(irc, msg, channel, topic) topics[i] = topic diff --git a/test/test_Topic.py b/test/test_Topic.py index 34f02e398..7fa51d245 100644 --- a/test/test_Topic.py +++ b/test/test_Topic.py @@ -115,15 +115,13 @@ class TopicTestCase(ChannelPluginTestCase, PluginDocumentation): _ = self.getMsg('topic add foo') self.assertRegexp('topic set -1 bar', 'bar') self.assertNotRegexp('topic set -1 baz', 'bar') - - def testTopic(self): - self.assertResponse('topic foo bar baz', 'foo bar baz') + self.assertResponse('topic set foo bar baz', 'foo bar baz') def testUndo(self): try: original = conf.supybot.plugins.Topic.format() conf.supybot.plugins.Topic.format.setValue('$topic') - self.assertResponse('topic ""', '') + self.assertResponse('topic set ""', '') self.assertResponse('topic add foo', 'foo') self.assertResponse('topic add bar', 'foo || bar') self.assertResponse('topic add baz', 'foo || bar || baz')