mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-30 22:24:20 +01:00
Added Topic.replace.
This commit is contained in:
parent
f5bbd8cb51
commit
a4cec8c8be
@ -192,6 +192,15 @@ class Topic(callbacks.Privmsg):
|
||||
irc.queueMsg(ircmsgs.topic(channel, newTopic))
|
||||
irc.noReply()
|
||||
|
||||
def doJoin(self, irc, msg):
|
||||
if ircutils.strEqual(msg.nick, irc.nick):
|
||||
# We're joining a channel, let's watch for the topic.
|
||||
self.watchingFor332.add(msg.args[0])
|
||||
|
||||
def do332(self, irc, msg):
|
||||
if msg.args[1] in self.watchingFor332:
|
||||
self.watchingFor332.remove(msg.args[1])
|
||||
|
||||
def topic(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
|
||||
@ -213,6 +222,16 @@ class Topic(callbacks.Privmsg):
|
||||
self._sendTopics(irc, channel, topics)
|
||||
add = wrap(add, ['canChangeTopic', rest('topic')])
|
||||
|
||||
def replace(self, irc, msg, args, channel, i, topic):
|
||||
"""[<channel>] <number> <topic>
|
||||
|
||||
Replaces topic <number> with <topic>.
|
||||
"""
|
||||
topics = self._splitTopic(irc.state.getTopic(channel), channel)
|
||||
topics[i] = topic
|
||||
self._sendTopics(irc, channel, topics)
|
||||
replace = wrap(replace, ['canChangeTopic', 'topicNumber', rest('topic')])
|
||||
|
||||
def insert(self, irc, msg, args, channel, topic):
|
||||
"""[<channel>] <topic>
|
||||
|
||||
|
@ -42,6 +42,16 @@ class TopicTestCase(ChannelPluginTestCase, PluginDocumentation):
|
||||
self.assertNotError('topic remove 1')
|
||||
self.assertError('topic remove 1')
|
||||
|
||||
def testReplace(self):
|
||||
_ = self.getMsg('topic add foo')
|
||||
_ = self.getMsg('topic add bar')
|
||||
_ = self.getMsg('topic add baz')
|
||||
self.assertRegexp('topic replace 1 oof', 'oof.*bar.*baz')
|
||||
self.assertRegexp('topic replace -1 zab', 'oof.*bar.*zab')
|
||||
self.assertRegexp('topic replace 2 lorem ipsum',
|
||||
'oof.*lorem ipsum.*zab')
|
||||
self.assertRegexp('topic replace 2 rab', 'oof.*rab.*zab')
|
||||
|
||||
def testGet(self):
|
||||
self.assertError('topic get 1')
|
||||
_ = self.getMsg('topic add foo')
|
||||
|
Loading…
Reference in New Issue
Block a user