mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-04-27 05:21:10 -05:00
parent
b2d800ce61
commit
2bd13fa068
@ -127,9 +127,9 @@ class RelayNext(callbacks.Plugin):
|
|||||||
s = ''
|
s = ''
|
||||||
nick = real_nick = msg.nick
|
nick = real_nick = msg.nick
|
||||||
userhost = ''
|
userhost = ''
|
||||||
noHighlight = self.registryValue('noHighlight', channel)
|
noHighlight = self.registryValue('noHighlight', channel=channel, network=irc.network)
|
||||||
useHostmask = self.registryValue('hostmasks', channel)
|
useHostmask = self.registryValue('hostmasks', channel=channel, network=irc.network)
|
||||||
color = self.registryValue('color', channel)
|
color = self.registryValue('color', channel=channel, network=irc.network)
|
||||||
netname = irc.network
|
netname = irc.network
|
||||||
|
|
||||||
# Adding a zero-width space to prevent being highlighted by clients
|
# Adding a zero-width space to prevent being highlighted by clients
|
||||||
@ -145,14 +145,14 @@ class RelayNext(callbacks.Plugin):
|
|||||||
if useHostmask and '.' not in nick:
|
if useHostmask and '.' not in nick:
|
||||||
try:
|
try:
|
||||||
userhost = ' (%s)' % msg.prefix.split('!', 1)[1]
|
userhost = ' (%s)' % msg.prefix.split('!', 1)[1]
|
||||||
except:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if isAnnouncement:
|
if isAnnouncement:
|
||||||
# Announcements use a special syntax
|
# Announcements use a special syntax
|
||||||
s = '*** %s' % msg.args[1]
|
s = '*** %s' % msg.args[1]
|
||||||
else:
|
else:
|
||||||
ignoreRegexp = self.registryValue("ignoreRegexp", channel)
|
ignoreRegexp = self.registryValue("ignoreRegexp", channel=channel, network=irc.network)
|
||||||
if msg.command == 'NICK':
|
if msg.command == 'NICK':
|
||||||
newnick = msg.args[0]
|
newnick = msg.args[0]
|
||||||
if noHighlight:
|
if noHighlight:
|
||||||
@ -168,7 +168,7 @@ class RelayNext(callbacks.Plugin):
|
|||||||
|
|
||||||
# Show status prefixes (@%+) in front of the nick if enabled,
|
# Show status prefixes (@%+) in front of the nick if enabled,
|
||||||
# but only the highest prefix.
|
# but only the highest prefix.
|
||||||
if self.registryValue("showPrefixes", channel):
|
if self.registryValue("showPrefixes", channel=channel, network=irc.network):
|
||||||
chobj = irc.state.channels[channel]
|
chobj = irc.state.channels[channel]
|
||||||
if chobj.isOp(real_nick):
|
if chobj.isOp(real_nick):
|
||||||
nick = '@' + nick
|
nick = '@' + nick
|
||||||
@ -242,16 +242,16 @@ class RelayNext(callbacks.Plugin):
|
|||||||
Run antiflood on the given network / channel / message, returning True if the given message
|
Run antiflood on the given network / channel / message, returning True if the given message
|
||||||
should be processed (i.e. it has not been blocked by antiflood).
|
should be processed (i.e. it has not been blocked by antiflood).
|
||||||
"""
|
"""
|
||||||
if self.registryValue("antiflood.enable", channel):
|
if self.registryValue("antiflood.enable", channel=channel, network=irc.network):
|
||||||
# Flood prevention timeout - how long commands of a certain type
|
# Flood prevention timeout - how long commands of a certain type
|
||||||
# should cease being relayed after flood prevention triggers
|
# should cease being relayed after flood prevention triggers
|
||||||
timeout = self.registryValue("antiflood.timeout", channel)
|
timeout = self.registryValue("antiflood.timeout", channel=channel, network=irc.network)
|
||||||
|
|
||||||
# If <maximum> messages of the same kind on one channel is
|
# If <maximum> messages of the same kind on one channel is
|
||||||
# received in <seconds> seconds, flood prevention timeout is
|
# received in <seconds> seconds, flood prevention timeout is
|
||||||
# triggered.
|
# triggered.
|
||||||
maximum = self.registryValue("antiflood.maximum", channel)
|
maximum = self.registryValue("antiflood.maximum", channel=channel, network=irc.network)
|
||||||
seconds = self.registryValue("antiflood.seconds", channel)
|
seconds = self.registryValue("antiflood.seconds", channel=channel, network=irc.network)
|
||||||
|
|
||||||
# Store the message in a counter, with the keys taking the
|
# Store the message in a counter, with the keys taking the
|
||||||
# form of (source channel@network, command name). If the counter
|
# form of (source channel@network, command name). If the counter
|
||||||
@ -263,10 +263,10 @@ class RelayNext(callbacks.Plugin):
|
|||||||
|
|
||||||
# Two different limits: one for messages and one for all others
|
# Two different limits: one for messages and one for all others
|
||||||
if msg.command == "PRIVMSG":
|
if msg.command == "PRIVMSG":
|
||||||
maximum = self.registryValue("antiflood.maximum", channel)
|
maximum = self.registryValue("antiflood.maximum", channel=channel, network=irc.network)
|
||||||
else:
|
else:
|
||||||
maximum = self.registryValue("antiflood.maximum.nonPrivmsgs",
|
maximum = self.registryValue("antiflood.maximum.nonPrivmsgs",
|
||||||
channel)
|
channel=channel, network=irc.network)
|
||||||
|
|
||||||
lastFloodTrigger = self.floodTriggered.get((source, msg.command))
|
lastFloodTrigger = self.floodTriggered.get((source, msg.command))
|
||||||
if lastFloodTrigger is not None and (time.time() - lastFloodTrigger) > timeout:
|
if lastFloodTrigger is not None and (time.time() - lastFloodTrigger) > timeout:
|
||||||
@ -300,7 +300,7 @@ class RelayNext(callbacks.Plugin):
|
|||||||
# Check for ignored events first. Checking for "'.' not in msg.nick" is for skipping
|
# Check for ignored events first. Checking for "'.' not in msg.nick" is for skipping
|
||||||
# ignore checks from servers.
|
# ignore checks from servers.
|
||||||
if not isAnnouncement:
|
if not isAnnouncement:
|
||||||
ignoredevents = map(str.upper, self.registryValue('events.userIgnored', channel))
|
ignoredevents = map(str.upper, self.registryValue('events.userIgnored', channel=channel, network=irc.network))
|
||||||
if msg.command in ignoredevents and msg.nick != irc.nick and '.' not in msg.nick and\
|
if msg.command in ignoredevents and msg.nick != irc.nick and '.' not in msg.nick and\
|
||||||
ircdb.checkIgnored(msg.prefix, channel):
|
ircdb.checkIgnored(msg.prefix, channel):
|
||||||
self.log.debug("RelayNext (%s): ignoring message from %s",
|
self.log.debug("RelayNext (%s): ignoring message from %s",
|
||||||
@ -353,12 +353,11 @@ class RelayNext(callbacks.Plugin):
|
|||||||
otherIrc.queueMsg(out_msg)
|
otherIrc.queueMsg(out_msg)
|
||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
self.relay(irc, msg, channel=msg.args[0])
|
self.relay(irc, msg, channel=msg.channel)
|
||||||
|
|
||||||
def doNonPrivmsg(self, irc, msg):
|
def doNonPrivmsg(self, irc, msg):
|
||||||
channel = msg.args[0]
|
if self.registryValue("events.relay%ss" % msg.command, channel=msg.channel, network=irc.network):
|
||||||
if self.registryValue("events.relay%ss" % msg.command, channel):
|
self.relay(irc, msg, channel=msg.channel)
|
||||||
self.relay(irc, msg, channel)
|
|
||||||
|
|
||||||
doTopic = doPart = doKick = doMode = doJoin = doNonPrivmsg
|
doTopic = doPart = doKick = doMode = doJoin = doNonPrivmsg
|
||||||
|
|
||||||
@ -366,12 +365,12 @@ class RelayNext(callbacks.Plugin):
|
|||||||
# of extra handling
|
# of extra handling
|
||||||
def doNick(self, irc, msg):
|
def doNick(self, irc, msg):
|
||||||
for channel in msg.tagged('channels'):
|
for channel in msg.tagged('channels'):
|
||||||
if self.registryValue("events.relaynicks", channel):
|
if self.registryValue("events.relaynicks", channel=channel, network=irc.network):
|
||||||
self.relay(irc, msg, channel)
|
self.relay(irc, msg, channel)
|
||||||
|
|
||||||
def doQuit(self, irc, msg):
|
def doQuit(self, irc, msg):
|
||||||
for channel in msg.tagged('channels'):
|
for channel in msg.tagged('channels'):
|
||||||
if self.registryValue("events.relayquits", channel):
|
if self.registryValue("events.relayquits", channel=channel, network=irc.network):
|
||||||
self.relay(irc, msg, channel)
|
self.relay(irc, msg, channel)
|
||||||
|
|
||||||
def outFilter(self, irc, msg):
|
def outFilter(self, irc, msg):
|
||||||
@ -379,10 +378,10 @@ class RelayNext(callbacks.Plugin):
|
|||||||
# 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 and \
|
if msg.command == 'PRIVMSG' and not msg.relayedMsg and \
|
||||||
self.registryValue("events.relaySelfMessages", msg.args[0]):
|
self.registryValue("events.relaySelfMessages", channel=msg.channel, network=irc.network):
|
||||||
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.channel)
|
||||||
except Exception:
|
except Exception:
|
||||||
# We want to log errors, but not block the bot's output
|
# We want to log errors, but not block the bot's output
|
||||||
log.exception("RelayNext: Caught error in outFilter:")
|
log.exception("RelayNext: Caught error in outFilter:")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user