Coders-IRC


IRC for Coders

Simple One Man Spam Prevention Bot


image
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
  }
}




Comments 0