Changed the topic command to be topic.set-with-no-number.

This commit is contained in:
Jeremy Fincher 2004-08-24 23:06:16 +00:00
parent 30f93fdc8f
commit 0143a41e4f
2 changed files with 12 additions and 17 deletions

View File

@ -152,15 +152,6 @@ class Topic(callbacks.Privmsg):
except (ValueError, IndexError): except (ValueError, IndexError):
irc.error('That\'s not a valid topic number.', Raise=True) irc.error('That\'s not a valid topic number.', Raise=True)
def topic(self, irc, msg, args, channel):
"""[<channel>] <topic>
Sets the topic of <channel> to <topic>.
"""
topic = privmsgs.getArgs(args)
self._sendTopics(irc, channel, [topic])
topic = privmsgs.channel(topic)
def add(self, irc, msg, args, channel, insert=False): def add(self, irc, msg, args, channel, insert=False):
"""[<channel>] <topic> """[<channel>] <topic>
@ -299,14 +290,20 @@ class Topic(callbacks.Privmsg):
change = privmsgs.channel(change) change = privmsgs.channel(change)
def set(self, irc, msg, args, channel): def set(self, irc, msg, args, channel):
"""[<channel>] <number> <topic> """[<channel>] [<number>] <topic>
Sets the topic <number> to be <text>. <channel> is only necessary if Sets the topic <number> to be <text>. If no <number> is given, this
the message isn't sent in the channel itself. sets the entire topic. <channel> is only necessary if the message
isn't sent in the channel itself.
""" """
self._canChangeTopic(irc, channel) 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) 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) i = self._topicNumber(irc, i, topics=topics)
topic = self._formatTopic(irc, msg, channel, topic) topic = self._formatTopic(irc, msg, channel, topic)
topics[i] = topic topics[i] = topic

View File

@ -115,15 +115,13 @@ class TopicTestCase(ChannelPluginTestCase, PluginDocumentation):
_ = self.getMsg('topic add foo') _ = self.getMsg('topic add foo')
self.assertRegexp('topic set -1 bar', 'bar') self.assertRegexp('topic set -1 bar', 'bar')
self.assertNotRegexp('topic set -1 baz', 'bar') self.assertNotRegexp('topic set -1 baz', 'bar')
self.assertResponse('topic set foo bar baz', 'foo bar baz')
def testTopic(self):
self.assertResponse('topic foo bar baz', 'foo bar baz')
def testUndo(self): def testUndo(self):
try: try:
original = conf.supybot.plugins.Topic.format() original = conf.supybot.plugins.Topic.format()
conf.supybot.plugins.Topic.format.setValue('$topic') conf.supybot.plugins.Topic.format.setValue('$topic')
self.assertResponse('topic ""', '') self.assertResponse('topic set ""', '')
self.assertResponse('topic add foo', 'foo') self.assertResponse('topic add foo', 'foo')
self.assertResponse('topic add bar', 'foo || bar') self.assertResponse('topic add bar', 'foo || bar')
self.assertResponse('topic add baz', 'foo || bar || baz') self.assertResponse('topic add baz', 'foo || bar || baz')