Added topic command.

This commit is contained in:
Jeremy Fincher 2004-09-16 18:43:31 +00:00
parent 556f9ccaeb
commit 324ab71db4
2 changed files with 28 additions and 1 deletions

View File

@ -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):
"""[<channel>]
Returns the topic for <channel>. <channel> 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):
"""[<channel>] <topic>

View File

@ -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: