I started working on a bot and after some reading I saw that there was a 20 message limit in a 30 second time period before getting locked out for 8 hours. That didn’t seem like a lot of messages, so I made a buffer in my code. I’ll post the code below, but basically instead of writing to my channel directly, I call writeToBuffer MESSAGE. Then a timer that runs every second prints out one line of my buffer. Whenever I reach my buffer max size, it wraps around to the beginning of the list. I was pretty happy that I got it working, but then I saw that for mods, it is a 100 message limit in 30 seconds and you only get disconnected rather than banned. That seems like a pretty hard limit to hit, so maybe this buffer thing isn’t needed. How do people with thousands of viewers handle the message limit?
My Code
alias -l writeToBuffer {
if ($1 != $null) {
set %buffer. $+ %bufferNext $1-
inc %bufferNext
if (%bufferNext == %bufferMax) {
set %bufferNext 0
}
}
}
alias -l writeFromBuffer {
if ($($+(%,buffer.,%bufferCurrent),2) != $null) {
msg %channel $($+(%,buffer.,%bufferCurrent),2)
set %buffer. $+ %bufferCurrent $null
inc %bufferCurrent
if (%bufferCurrent == %bufferMax) {
set %bufferCurrent 0
}
}
}
timerBufferWriter 0 1 writeFromBuffer
Edit: using the preformatted blocks now