mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-26 04:51:06 -05:00
Herald: Throttle default heralds.
Fixes https://github.com/ProgVal/Limnoria/issues/1372
This commit is contained in:
parent
138957676e
commit
9081f5678b
@ -87,31 +87,15 @@ class Herald(callbacks.Plugin):
|
|||||||
def doJoin(self, irc, msg):
|
def doJoin(self, irc, msg):
|
||||||
if ircutils.strEqual(irc.nick, msg.nick):
|
if ircutils.strEqual(irc.nick, msg.nick):
|
||||||
return # It's us.
|
return # It's us.
|
||||||
if msg.nick in self.splitters:
|
|
||||||
self.log.debug('Not heralding %s, recent split.', msg.nick)
|
|
||||||
return # Recently split.
|
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
irc = callbacks.SimpleProxy(irc, msg)
|
irc = callbacks.SimpleProxy(irc, msg)
|
||||||
if self.registryValue('heralding', channel, irc.network):
|
if self.registryValue('heralding', channel, irc.network):
|
||||||
try:
|
try:
|
||||||
id = ircdb.users.getUserId(msg.prefix)
|
id = ircdb.users.getUserId(msg.prefix)
|
||||||
if id in self.splitters:
|
|
||||||
self.log.debug('Not heralding id #%s, recent split.', id)
|
|
||||||
return
|
|
||||||
herald = self.db[channel, id]
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
default = self.registryValue('default', channel, irc.network)
|
id = msg.nick
|
||||||
if default:
|
if id in self.splitters:
|
||||||
default = ircutils.standardSubstitute(irc, msg, default)
|
self.log.debug('Not heralding id #%s, recent split.', id)
|
||||||
msgmaker = ircmsgs.privmsg
|
|
||||||
if self.registryValue('default.notice',
|
|
||||||
channel, irc.network):
|
|
||||||
msgmaker = ircmsgs.notice
|
|
||||||
target = msg.nick
|
|
||||||
if self.registryValue('default.public',
|
|
||||||
channel, irc.network):
|
|
||||||
target = channel
|
|
||||||
irc.queueMsg(msgmaker(target, default))
|
|
||||||
return
|
return
|
||||||
now = time.time()
|
now = time.time()
|
||||||
throttle = self.registryValue('throttle',
|
throttle = self.registryValue('throttle',
|
||||||
@ -122,16 +106,34 @@ class Herald(callbacks.Plugin):
|
|||||||
channel, irc.network)
|
channel, irc.network)
|
||||||
if now - self.lastParts[channel, id] < i:
|
if now - self.lastParts[channel, id] < i:
|
||||||
return
|
return
|
||||||
self.lastHerald[channel, id] = now
|
try:
|
||||||
herald = ircutils.standardSubstitute(irc, msg, herald)
|
herald = self.db[channel, id]
|
||||||
irc.reply(herald, prefixNick=False)
|
except KeyError:
|
||||||
|
herald = self.registryValue('default', channel, irc.network)
|
||||||
|
if herald:
|
||||||
|
herald = ircutils.standardSubstitute(irc, msg, herald)
|
||||||
|
msgmaker = ircmsgs.privmsg
|
||||||
|
if self.registryValue('default.notice',
|
||||||
|
channel, irc.network):
|
||||||
|
msgmaker = ircmsgs.notice
|
||||||
|
target = msg.nick
|
||||||
|
if self.registryValue('default.public',
|
||||||
|
channel, irc.network):
|
||||||
|
target = channel
|
||||||
|
self.lastHerald[channel, id] = now
|
||||||
|
irc.queueMsg(msgmaker(target, herald))
|
||||||
|
return
|
||||||
|
if herald:
|
||||||
|
self.lastHerald[channel, id] = now
|
||||||
|
herald = ircutils.standardSubstitute(irc, msg, herald)
|
||||||
|
irc.reply(herald, prefixNick=False)
|
||||||
|
|
||||||
def doPart(self, irc, msg):
|
def doPart(self, irc, msg):
|
||||||
try:
|
try:
|
||||||
id = self._getId(irc, msg.prefix)
|
id = self._getId(irc, msg.prefix)
|
||||||
self.lastParts[msg.args[0], id] = time.time()
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
id = msg.nick
|
||||||
|
self.lastParts[msg.args[0], id] = time.time()
|
||||||
|
|
||||||
def _getId(self, irc, userNickHostmask):
|
def _getId(self, irc, userNickHostmask):
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user