RelayNext: add events.relaySelfMessages option to toggle relaying the bot's output

Closes #98.
This commit is contained in:
James Lu 2020-12-19 22:50:44 +01:00
parent 2baceb609e
commit 2e296b38ff
2 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,5 @@
### ###
# Copyright (c) 2015-2018 James Lu <james@overdrivenetworks.com> # Copyright (c) 2015-2020 James Lu <james@overdrivenetworks.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -95,5 +95,9 @@ for ev in _events:
conf.registerChannelValue(RelayNext.events, 'userIgnored', conf.registerChannelValue(RelayNext.events, 'userIgnored',
registry.SpaceSeparatedListOfStrings(['PRIVMSG', 'MODE'], ("""Determines what events registry.SpaceSeparatedListOfStrings(['PRIVMSG', 'MODE'], ("""Determines what events
the relay should ignore from ignored users. Ignores are added using the relay should ignore from ignored users. Ignores are added using
Supybot's global ignore system."""))) Limnoria's global ignore system.""")))
conf.registerChannelValue(RelayNext.events, 'relaySelfMessages',
registry.Boolean(True, ("""Determines whether the bot should relay its own messages.
You may wish to disable this if you are running plugins that announce to the same channel
on multiple networks (e.g. RSS).""")))
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

View File

@ -1,5 +1,5 @@
### ###
# Copyright (c) 2015-2018 James Lu <james@overdrivenetworks.com> # Copyright (c) 2015-2020 James Lu <james@overdrivenetworks.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -367,7 +367,8 @@ class RelayNext(callbacks.Plugin):
# Catch our own messages and send them into the relay (this is # Catch our own messages and send them into the relay (this is
# useful because Supybot is often a multi-purpose bot!) # useful because Supybot is often a multi-purpose bot!)
try: try:
if msg.command == 'PRIVMSG' and not msg.relayedMsg: if msg.command == 'PRIVMSG' and not msg.relayedMsg and \
self.registryValue("events.relaySelfMessages", msg.args[0]):
new_msg = deepcopy(msg) new_msg = deepcopy(msg)
new_msg.nick = irc.nick new_msg.nick = irc.nick
self.relay(irc, new_msg, channel=msg.args[0]) self.relay(irc, new_msg, channel=msg.args[0])