Allow specifying the format of Owner.announce

Someone asked how to remove the owner's username from announcements,
so it may be useful to make this configurable instead of making them
edit a core plugin's code which is not the best idea,
or write another plugin.
This commit is contained in:
nyuszika7h 2017-01-22 12:34:54 +01:00
parent 260a511942
commit dab4737010
2 changed files with 13 additions and 1 deletions

View File

@ -45,6 +45,11 @@ Owner = conf.registerPlugin('Owner', True)
conf.registerGlobalValue(Owner, 'public', conf.registerGlobalValue(Owner, 'public',
registry.Boolean(True, """Determines whether this plugin is publicly registry.Boolean(True, """Determines whether this plugin is publicly
visible.""")) visible."""))
conf.registerGlobalValue(Owner, 'announceFormat',
registry.String('Announcement from my owner ($owner): $message',
"""Determines the format of messages sent by the @announce command.
$owner may be used for the username of the owner calling this command,
and $message for the announcement being made."""))
conf.registerGlobalValue(Owner, 'quitMsg', conf.registerGlobalValue(Owner, 'quitMsg',
registry.String('$version', """Determines what quit message will be used by default. registry.String('$version', """Determines what quit message will be used by default.
If the quit command is called without a quit message, this will be used. If If the quit command is called without a quit message, this will be used. If

View File

@ -33,6 +33,7 @@ import os
import sys import sys
import time import time
import socket import socket
import string
import linecache import linecache
import re import re
@ -282,11 +283,17 @@ class Owner(callbacks.Plugin):
lobotomized in. lobotomized in.
""" """
u = ircdb.users.getUser(msg.prefix) u = ircdb.users.getUser(msg.prefix)
text = 'Announcement from my owner (%s): %s' % (u.name, text)
template = self.registryValue('announceFormat')
text = ircutils.standardSubstitute(
irc, msg, template, env={'owner': u.name, 'message': text})
for channel in irc.state.channels: for channel in irc.state.channels:
c = ircdb.channels.getChannel(channel) c = ircdb.channels.getChannel(channel)
if not c.lobotomized: if not c.lobotomized:
irc.queueMsg(ircmsgs.privmsg(channel, text)) irc.queueMsg(ircmsgs.privmsg(channel, text))
irc.noReply() irc.noReply()
announce = wrap(announce, ['text']) announce = wrap(announce, ['text'])