Simple One Man Spam Prevention Bot - 09/12/18 11:16 PM
Can anyone please provide me with a code that automatically times someone out after a certain amount of messages is sent within a set amount of seconds on Twitch.
on *:TEXT:*:#*:{ $flood_counter } on *:ACTION:*:#*:{ $flood_counter } on *:NICK:{ var %table flood , %timeframe 300 , %wilditem $+(*!,$fulladdress) while ($hfind(%table,%wilditem,1,w)) { hdel %table $v1 hadd -u $+ %timeframe %table $puttok($v1,$newnick,3,33) } } alias flood_counter { var %timeframe 300 , %max.messages 5 , %table flood if (!$hget(%table)) { hmake %table 101 | hadd %table counter 1 } var %counter $hget(%table,counter) | hinc %table counter 1 var %item $+(%counter,!,$chan,!,$fulladdress) , %wilditem $+(*!,$chan,!,$fulladdress) hadd -u $+ %timeframe %table %item | var %msg_count $hfind(%table,%wilditem,0,w) echo -s debug message: $nick has %msg_count messages in the last %timeframe seconds. You can delete this line if (%msg_count >= %max.messages) { echo -s action to take against $nick in $chan goes inside these brackets. This is where the time-out command goes } }
on @*:TEXT:*:#*:{ noop $flood_counter $repeat_counter($1-) } on @*:ACTION:*:#*:{ noop $flood_counter $repeat_counter($1-) } on *:NICK:{ var %table flood , %timeframe 300 , %wilditem $+(*!,$fulladdress) while ($hfind(%table,%wilditem,1,w)) { hdel %table $v1 hadd -u $+ %timeframe %table $puttok($v1,$newnick,3,33) } var %timeframe2 300 , %table1 repeat.text , %table2 repeat.count , %wilditem $+(*!,$fulladdress) while ($hfind(%table1,%wilditem,1,w)) { var %a $puttok($v1,$newnick,2,33) hadd -u $+ %timeframe2 %table1 %a $hget(%table1,$v1) hadd -u $+ %timeframe2 %table2 %a $hget(%table2,$v1) hdel %table1 $v1 hdel %table2 $v1 } } alias -l repeat_counter { var %timeframe2 300 , %kill.at.repeats 3 , %table1 repeat.text , %table2 repeat.count var %text $lower($strip($1)) if (!$hget(%table1)) { hmake %table1 101 } if (!$hget(%table2)) { hmake %table2 101 } var %item $+($chan,!,$fulladdress) var %a $hget(%table1,%item) if ((%a == $null) || (%a != %text)) { hadd -u $+ %timeframe2 %table1 %item %text hadd -u $+ %timeframe2 %table2 %item 1 return } var %secs $hget(%table1,%item).unset | if (!%secs) var %secs %timeframe2 hinc -u $+ %timeframe2 %table2 %item var %count $hget(%table2,%item) if (%count >= %kill.at.repeats) { echo 4 -a $nick has repeated %count times within %timeframe2 seconds. Action goes in here } } alias -l flood_counter { var %timeframe 300 , %max.messages 5 , %table flood if (!$hget(%table)) { hmake %table 101 | hadd %table counter 1 } var %counter $hget(%table,counter) | hinc %table counter 1 var %item $+(%counter,!,$chan,!,$fulladdress) , %wilditem $+(*!,$chan,!,$fulladdress) hadd -u $+ %timeframe %table %item | var %msg_count $hfind(%table,%wilditem,0,w) echo -s debug message: $nick has %msg_count messages in the last %timeframe seconds if (%msg_count >= %max.messages) { echo 4 -s action to take against $nick in $chan goes inside these brackets } }
//echo -a $chr(55357) $+ $chr(56369)
from: if (%msg_count >= %max.messages) { to: if ((%msg_count >= %max.messages) || ($len($eventparms) >= 60)) {