From 32988ee3a3d59f723d850485196cc9ff9e28baa1 Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 27 Feb 2015 18:27:58 -0800 Subject: [PATCH] Channel.cycle: allow specifying part message + defaults to plugins.Channel.partMsg Closes #1062. --- plugins/Channel/plugin.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/Channel/plugin.py b/plugins/Channel/plugin.py index 1450fdfb6..d4e425013 100644 --- a/plugins/Channel/plugin.py +++ b/plugins/Channel/plugin.py @@ -258,17 +258,22 @@ class Channel(callbacks.Plugin): any('nickInChannel')]) @internationalizeDocstring - def cycle(self, irc, msg, args, channel): + def cycle(self, irc, msg, args, channel, reason): """[] If you have the #channel,op capability, this will cause the bot to "cycle", or PART and then JOIN the channel. is only necessary - if the message isn't sent in the channel itself. + if the message isn't sent in the channel itself. If is not + specified, the default part message specified in + supybot.plugins.Channel.partMsg will be used. No part message will be + used if neither a cycle reason nor a default part message is given. """ - self._sendMsg(irc, ircmsgs.part(channel, msg.nick)) + reason = (reason or self.registryValue("partMsg", channel)) + reason = ircutils.standardSubstitute(irc, msg, reason) + self._sendMsg(irc, ircmsgs.part(channel, reason)) networkGroup = conf.supybot.networks.get(irc.network) self._sendMsg(irc, networkGroup.channels.join(channel)) - cycle = wrap(cycle, ['op']) + cycle = wrap(cycle, ['op', additional('text')]) @internationalizeDocstring def kick(self, irc, msg, args, channel, nicks, reason):