BT.nickflood.tcl 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #########################################################################
  2. ## BlackTools - The Ultimate Channel Control Script ##
  3. ## One TCL. One smart Eggdrop ##
  4. #########################################################################
  5. ########################## NICKFLOOD TCL ############################
  6. #########################################################################
  7. ## ##
  8. ## BlackTools : http://blacktools.tclscripts.net ##
  9. ## Bugs report : http://www.tclscripts.net/ ##
  10. ## GitHub page : https://github.com/tclscripts/BlackToolS-TCL ##
  11. ## Online Help : irc://irc.undernet.org/tcl-help ##
  12. ## #TCL-HELP / UnderNet ##
  13. ## You can ask in english or romanian ##
  14. ## ##
  15. #########################################################################
  16. proc nickflood:protect {nick host hand chan arg} {
  17. global black
  18. if {![validchan $chan]} { return }
  19. if {[setting:get $chan nickflood]} {
  20. set handle [nick2hand $nick]
  21. if {![botisop $chan] && ![setting:get $chan xonly]} { return }
  22. if {[matchattr $handle $black(exceptflags) $chan]} { return }
  23. if {[isbotnick $nick]} { return }
  24. set bl_protect [blacktools:protect $nick $chan]
  25. if {$bl_protect == "1"} { return }
  26. set getset [setting:get $chan nickflood-repeat]
  27. if {$getset == ""} { set getset "$black(nickfloodrepeats)" }
  28. set number [scan $getset %\[^:\]]
  29. set time [scan $getset %*\[^:\]:%s]
  30. if {![info exists black(nick:$host:$chan:flood)]} {
  31. set black(nick:$host:$chan:flood) 0
  32. }
  33. foreach tmr [utimers] {
  34. if {[string match "*nickflood:unset $host $chan*" [join [lindex $tmr 1]]]} {
  35. killutimer [lindex $tmr 2]
  36. }
  37. }
  38. incr black(nick:$host:$chan:flood)
  39. utimer $time [list nickflood:unset $host $chan]
  40. if {$black(nick:$host:$chan:flood) >= $number} {
  41. blacktools:banner:1 $nick "NICKFLOOD:$arg" $chan $host [get:banmethod "nickflood" $chan] [link:chan:get $chan]
  42. nickflood:unset $host $chan
  43. }
  44. }
  45. }
  46. proc nickflood:unset {host chan} {
  47. global black
  48. foreach tmr [utimers] {
  49. if {[string match "*nickflood:unset $host $chan*" [join [lindex $tmr 1]]]} {
  50. killutimer [lindex $tmr 2]
  51. }
  52. }
  53. if {[info exists black(nick:$host:$chan:flood)]} {
  54. unset black(nick:$host:$chan:flood)
  55. }
  56. }
  57. ##############
  58. #########################################################################
  59. ## END ##
  60. #########################################################################