From d844b1d19ceea0ec516d06e6508c7030edb45637 Mon Sep 17 00:00:00 2001 From: GLolol Date: Wed, 4 Feb 2015 21:10:18 -0800 Subject: [PATCH] Admin: allow specifying a default part message in plugins.admin.partmsg (Closes ProgVal#391) Cherry-picked from commit GLolol@f69c789. --- plugins/Admin/config.py | 9 ++++++--- plugins/Admin/plugin.py | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/plugins/Admin/config.py b/plugins/Admin/config.py index 49a018483..bab52ad1e 100644 --- a/plugins/Admin/config.py +++ b/plugins/Admin/config.py @@ -43,8 +43,11 @@ def configure(advanced): Admin = conf.registerPlugin('Admin') -# This is where your configuration variables (if any) should go. For example: -# conf.registerGlobalValue(Admin, 'someConfigVariableName', -# registry.Boolean(False, """Help for someConfigVariableName.""")) + +conf.registerChannelValue(Admin, 'partMsg', + registry.String('%version%', _("""Determines what part message should be + used by default. If the part command is called without a part message, + this will be used. If this value is empty, then no part message will + be used (they are optional in the IRC protocol)."""))) # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/plugins/Admin/plugin.py b/plugins/Admin/plugin.py index 44e5a437d..fe9281f5a 100644 --- a/plugins/Admin/plugin.py +++ b/plugins/Admin/plugin.py @@ -238,7 +238,9 @@ class Admin(callbacks.Plugin): Tells the bot to part the list of channels you give it. is only necessary if you want the bot to part a channel other than the current channel. If is specified, use it as the part - message. + message. Otherwise, the default part message specified in + supybot.plugins.Admin.partMsg will be used. No part message will be + used if no default is configured. """ if channel is None: if irc.isChannel(msg.args[0]): @@ -252,7 +254,9 @@ class Admin(callbacks.Plugin): pass if channel not in irc.state.channels: irc.error(_('I\'m not in %s.') % channel, Raise=True) - irc.queueMsg(ircmsgs.part(channel, reason or msg.nick)) + reason = (reason or self.registryValue("partMsg", channel)) + reason = reason.replace("%version%", "Supybot %s" % conf.version) + irc.queueMsg(ircmsgs.part(channel, reason)) if msg.nick in irc.state.channels[channel].users: irc.noReply() else: