diff --git a/plugins/Topic.py b/plugins/Topic.py index d75b672ee..772c2d51d 100644 --- a/plugins/Topic.py +++ b/plugins/Topic.py @@ -168,6 +168,21 @@ 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): + """[] + + Returns the topic for . is only necessary if the + message isn't sent in the channel itself. + """ + if args: + raise callbacks.ArgumentError + try: + topic = irc.state.channels[channel].topic + irc.reply(topic) + except KeyError: + irc.error('I\'m not current in %s.' % channel) + topic = privmsgs.channel(topic) + def add(self, irc, msg, args, channel, insert=False): """[] diff --git a/test/test_Topic.py b/test/test_Topic.py index 0bf90cd10..78e68612c 100644 --- a/test/test_Topic.py +++ b/test/test_Topic.py @@ -154,8 +154,8 @@ class TopicTestCase(ChannelPluginTestCase, PluginDocumentation): conf.supybot.plugins.Topic.format.setValue(original) def testSwap(self): + original = conf.supybot.plugins.Topic.format() try: - original = conf.supybot.plugins.Topic.format() conf.supybot.plugins.Topic.format.setValue('$topic') self.assertResponse('topic set ""', '') self.assertResponse('topic add foo', 'foo') @@ -179,6 +179,18 @@ class TopicTestCase(ChannelPluginTestCase, PluginDocumentation): self.assertResponse('topic default', 'foo bar baz') finally: conf.supybot.plugins.Topic.default.setValue(original) + + def testTopic(self): + original = conf.supybot.plugins.Topic.format() + try: + conf.supybot.plugins.Topic.format.setValue('$topic') + self.assertError('topic addd') # Error to send too many args. + self.assertResponse('topic add foo', 'foo') + self.assertResponse('topic add bar', 'foo || bar') + self.assertResponse('topic', 'foo || bar') + finally: + conf.supybot.plugins.Topic.format.setValue(original) + # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: