From dab4737010fbdad367f6050227dfbd26c07b43f6 Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Sun, 22 Jan 2017 12:34:54 +0100 Subject: [PATCH] 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. --- plugins/Owner/config.py | 5 +++++ plugins/Owner/plugin.py | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/Owner/config.py b/plugins/Owner/config.py index 243e4ee07..61183c0f9 100644 --- a/plugins/Owner/config.py +++ b/plugins/Owner/config.py @@ -45,6 +45,11 @@ Owner = conf.registerPlugin('Owner', True) conf.registerGlobalValue(Owner, 'public', registry.Boolean(True, """Determines whether this plugin is publicly 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', 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 diff --git a/plugins/Owner/plugin.py b/plugins/Owner/plugin.py index 879b98e36..a83941823 100644 --- a/plugins/Owner/plugin.py +++ b/plugins/Owner/plugin.py @@ -33,6 +33,7 @@ import os import sys import time import socket +import string import linecache import re @@ -282,11 +283,17 @@ class Owner(callbacks.Plugin): lobotomized in. """ 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: c = ircdb.channels.getChannel(channel) if not c.lobotomized: irc.queueMsg(ircmsgs.privmsg(channel, text)) + irc.noReply() announce = wrap(announce, ['text'])