Admin: allow specifying a default part message in plugins.admin.partmsg (Closes ProgVal#391)

Cherry-picked from commit GLolol@f69c789.
This commit is contained in:
GLolol 2015-02-04 21:10:18 -08:00
parent 681bd5d85d
commit d844b1d19c
2 changed files with 12 additions and 5 deletions

View File

@ -43,8 +43,11 @@ def configure(advanced):
Admin = conf.registerPlugin('Admin') Admin = conf.registerPlugin('Admin')
# This is where your configuration variables (if any) should go. For example:
# conf.registerGlobalValue(Admin, 'someConfigVariableName', conf.registerChannelValue(Admin, 'partMsg',
# registry.Boolean(False, """Help for someConfigVariableName.""")) 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: # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -238,7 +238,9 @@ class Admin(callbacks.Plugin):
Tells the bot to part the list of channels you give it. <channel> is Tells the bot to part the list of channels you give it. <channel> is
only necessary if you want the bot to part a channel other than the only necessary if you want the bot to part a channel other than the
current channel. If <reason> is specified, use it as the part current channel. If <reason> 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 channel is None:
if irc.isChannel(msg.args[0]): if irc.isChannel(msg.args[0]):
@ -252,7 +254,9 @@ class Admin(callbacks.Plugin):
pass pass
if channel not in irc.state.channels: if channel not in irc.state.channels:
irc.error(_('I\'m not in %s.') % channel, Raise=True) 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: if msg.nick in irc.state.channels[channel].users:
irc.noReply() irc.noReply()
else: else: