add some anti-flood protection stuff
this throttles multi-line messages in a way that probably doesn't affect the normal cases much, and scales fairly well to far longer text. for some reason long ascii art still triggers the flood detection, but with this code at least it happens later in the process. so, success, for now? i can fix the ascii art at some future point if i ever hit it practically closes bss/dr.botzo#23
This commit is contained in:
@@ -872,6 +872,7 @@ class IRCBot(irc.client.SimpleIRCClient):
|
||||
if recursing:
|
||||
return replystr
|
||||
else:
|
||||
lines = 0
|
||||
replies = replystr.split('\n')
|
||||
for reply in replies:
|
||||
# split messages that are too long. max length is 512, but we also need to
|
||||
@@ -886,6 +887,10 @@ class IRCBot(irc.client.SimpleIRCClient):
|
||||
reply = self.splitter + ' ' + reply[splitpos + 1:]
|
||||
self.privmsg(replypath, splittext)
|
||||
|
||||
# antiflood
|
||||
lines += 1
|
||||
time.sleep(int(0.5 * lines))
|
||||
|
||||
# done splitting, or it was never necessary
|
||||
self.privmsg(replypath, reply)
|
||||
if stop:
|
||||
|
||||
Reference in New Issue
Block a user