LinkRelay: rename config variable noticeNonPrivmsgs to nonPrivmsgs and add 'nothing' mode.

master
Valentin Lorentz 2011-05-13 17:47:20 +02:00
parent 2913551333
commit e2c276d478
2 changed files with 14 additions and 7 deletions

View File

@ -71,10 +71,14 @@ conf.registerChannelValue(LinkRelay, 'includeNetwork',
registry.Boolean(True, _("""Determines whether the bot will include the
network in Relayed PRIVMSGs; if you're only Relaying between two networks,
it's somewhat redundant, and you may wish to save the space.""")))
conf.registerChannelValue(LinkRelay, 'noticeNonPrivmsgs',
registry.Boolean(False, _("""Determines whether the bot will used NOTICEs
rather than PRIVMSGs for non-PRIVMSG Relay messages (i.e., joins, parts,
nicks, quits, modes, etc.)""")))
class ValidNonPrivmsgsHandling(registry.OnlySomeStrings):
validStrings = ('privmsg', 'notice', 'nothing')
conf.registerChannelValue(LinkRelay, 'nonPrivmsgs',
registry.Boolean('privmsg', _("""Determines whether the bot will use
PRIVMSGs (privmsg), NOTICEs (notice), for non-PRIVMSG Relay messages
(i.e., joins, parts, nicks, quits, modes, etc.), or whether it won't relay
such messages (nothing)""")))
conf.registerGlobalValue(LinkRelay, 'relays',
registry.String('', _("""You shouldn't edit this configuration variable

View File

@ -267,11 +267,14 @@ class LinkRelay(callbacks.Plugin):
self.log.info('LinkRelay: I\'m not in in %s on %s' %
(relay.targetChannel, relay.targetNetwork))
else:
if isPrivmsg or not \
self.registryValue('noticeNonPrivmsgs', channel):
if isPrivmsg or \
self.registryValue('nonPrivmsgs', channel) == 'privmsg':
msg = ircmsgs.privmsg(relay.targetChannel, s)
else:
elif self.registryValue('nonPrivmsgs', channel) == 'notice':
msg = ircmsgs.notice(relay.targetChannel, s)
else:
# nothing
pass
msg.tag('relayedMsg')
relay.targetIRC.sendMsg(msg)