RelayNext: allow toggling relaying of non-privmsg events

This commit is contained in:
James Lu 2015-01-05 18:32:17 -08:00
parent 1451bf2614
commit 91f039f5b5
2 changed files with 15 additions and 3 deletions

View File

@ -61,5 +61,11 @@ conf.registerChannelValue(RelayNext, 'noHighlight',
registry.Boolean(False, _("""Determines whether the bot should prefix nicks registry.Boolean(False, _("""Determines whether the bot should prefix nicks
with a hyphen (-) to prevent excess highlights (in PRIVMSGs and actions)."""))) with a hyphen (-) to prevent excess highlights (in PRIVMSGs and actions).""")))
conf.registerGroup(RelayNext, 'events')
_events = ('quit', 'join', 'part', 'nick', 'mode', 'kick')
for ev in _events:
conf.registerChannelValue(RelayNext.events, 'relay%ss' % ev,
registry.Boolean(True, """Determines whether the bot should relay %ss.""" % ev))
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

View File

@ -231,19 +231,25 @@ class RelayNext(callbacks.Plugin):
def doPrivmsg(self, irc, msg): def doPrivmsg(self, irc, msg):
self.relay(irc, msg) self.relay(irc, msg)
doJoin = doPart = doKick = doMode = doPrivmsg def doJoin(self, irc, msg):
if self.registryValue("events.relay%ss" % msg.command, msg.args[0]):
self.relay(irc, msg)
doPart = doKick = doMode = doJoin
# NICK and QUIT aren't channel specific, so they require a bit # NICK and QUIT aren't channel specific, so they require a bit
# of extra handling # of extra handling
def doNick(self, irc, msg): def doNick(self, irc, msg):
newnick = msg.args[0] newnick = msg.args[0]
for channel in self._getAllRelaysForNetwork(irc): for channel in self._getAllRelaysForNetwork(irc):
if newnick in irc.state.channels[channel].users: if self.registryValue("events.relaynicks", channel) and \
newnick in irc.state.channels[channel].users:
self.relay(irc, msg, channel=channel) self.relay(irc, msg, channel=channel)
def doQuit(self, irc, msg): def doQuit(self, irc, msg):
for channel in self._getAllRelaysForNetwork(irc): for channel in self._getAllRelaysForNetwork(irc):
try: try:
if msg.nick in self.ircstates[irc].channels[channel].users: if self.registryValue("events.relayquits", channel) and \
msg.nick in self.ircstates[irc].channels[channel].users:
self.relay(irc, msg, channel=channel) self.relay(irc, msg, channel=channel)
except Exception as e: except Exception as e:
self.log.debug("RelayNext: something happened while handling a quit:" self.log.debug("RelayNext: something happened while handling a quit:"