mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 20:52:42 +01:00
Added topic command.
This commit is contained in:
parent
556f9ccaeb
commit
324ab71db4
@ -168,6 +168,21 @@ 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>]
|
||||||
|
|
||||||
|
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):
|
def add(self, irc, msg, args, channel, insert=False):
|
||||||
"""[<channel>] <topic>
|
"""[<channel>] <topic>
|
||||||
|
|
||||||
|
@ -154,8 +154,8 @@ class TopicTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
conf.supybot.plugins.Topic.format.setValue(original)
|
conf.supybot.plugins.Topic.format.setValue(original)
|
||||||
|
|
||||||
def testSwap(self):
|
def testSwap(self):
|
||||||
try:
|
|
||||||
original = conf.supybot.plugins.Topic.format()
|
original = conf.supybot.plugins.Topic.format()
|
||||||
|
try:
|
||||||
conf.supybot.plugins.Topic.format.setValue('$topic')
|
conf.supybot.plugins.Topic.format.setValue('$topic')
|
||||||
self.assertResponse('topic set ""', '')
|
self.assertResponse('topic set ""', '')
|
||||||
self.assertResponse('topic add foo', 'foo')
|
self.assertResponse('topic add foo', 'foo')
|
||||||
@ -180,6 +180,18 @@ class TopicTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
finally:
|
finally:
|
||||||
conf.supybot.plugins.Topic.default.setValue(original)
|
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:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user