mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
commit
6483fa7a98
@ -515,6 +515,8 @@ class Topic(callbacks.Plugin):
|
|||||||
irc.errorNoCapability(capabilities, Raise=True)
|
irc.errorNoCapability(capabilities, Raise=True)
|
||||||
try:
|
try:
|
||||||
topics = self.lastTopics[channel]
|
topics = self.lastTopics[channel]
|
||||||
|
if not topics:
|
||||||
|
raise KeyError
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error(format(_('I haven\'t yet set the topic in %s.'),
|
irc.error(format(_('I haven\'t yet set the topic in %s.'),
|
||||||
channel))
|
channel))
|
||||||
@ -522,6 +524,31 @@ class Topic(callbacks.Plugin):
|
|||||||
self._sendTopics(irc, channel, topics)
|
self._sendTopics(irc, channel, topics)
|
||||||
restore = wrap(restore, ['canChangeTopic'])
|
restore = wrap(restore, ['canChangeTopic'])
|
||||||
|
|
||||||
|
@internationalizeDocstring
|
||||||
|
def refresh(self, irc, msg, args, channel):
|
||||||
|
"""[<channel>]
|
||||||
|
Refreshes current topic set by anyone. Restores topic if empty.
|
||||||
|
<channel> is only necessary if the message isn't sent in the channel
|
||||||
|
itself.
|
||||||
|
"""
|
||||||
|
if not self._checkManageCapabilities(irc, msg, channel):
|
||||||
|
capabilities = self.registryValue('requireManageCapability')
|
||||||
|
irc.errorNoCapability(capabilities, Raise=True)
|
||||||
|
topic = irc.state.channels[channel].topic
|
||||||
|
if topic:
|
||||||
|
self._sendTopics(irc, channel, topic)
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
topics = self.lastTopics[channel]
|
||||||
|
if not topics:
|
||||||
|
raise KeyError
|
||||||
|
except KeyError:
|
||||||
|
irc.error(format(_('I haven\'t yet set the topic in %s.'),
|
||||||
|
channel))
|
||||||
|
return
|
||||||
|
self._sendTopics(irc, channel, topics)
|
||||||
|
refresh = wrap(refresh, ['canChangeTopic'])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
def undo(self, irc, msg, args, channel):
|
def undo(self, irc, msg, args, channel):
|
||||||
"""[<channel>]
|
"""[<channel>]
|
||||||
|
@ -162,6 +162,20 @@ class TopicTestCase(ChannelPluginTestCase):
|
|||||||
finally:
|
finally:
|
||||||
conf.supybot.plugins.Topic.format.setValue(orig)
|
conf.supybot.plugins.Topic.format.setValue(orig)
|
||||||
|
|
||||||
|
def testRestore(self):
|
||||||
|
self.getMsg('topic set foo')
|
||||||
|
self.assertResponse('topic restore', 'foo')
|
||||||
|
self.getMsg('topic remove 1')
|
||||||
|
restoreError = 'Error: I haven\'t yet set the topic in #test.'
|
||||||
|
self.assertResponse('topic restore', restoreError)
|
||||||
|
|
||||||
|
def testRefresh(self):
|
||||||
|
self.getMsg('topic set foo')
|
||||||
|
self.assertResponse('topic refresh', 'foo')
|
||||||
|
self.getMsg('topic remove 1')
|
||||||
|
refreshError = 'Error: I haven\'t yet set the topic in #test.'
|
||||||
|
self.assertResponse('topic refresh', refreshError)
|
||||||
|
|
||||||
def testUndo(self):
|
def testUndo(self):
|
||||||
try:
|
try:
|
||||||
original = conf.supybot.plugins.Topic.format()
|
original = conf.supybot.plugins.Topic.format()
|
||||||
|
Loading…
Reference in New Issue
Block a user