BT.antirepeat.tcl 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #########################################################################
  2. ## BlackTools - The Ultimate Channel Control Script ##
  3. ## One TCL. One smart Eggdrop ##
  4. #########################################################################
  5. ######################## ANTIREPEAT 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 antirepeat:protect {nick host hand chan arg} {
  17. global black botnick
  18. set arg [color:filter [join [split $arg]]]
  19. set handle [nick2hand $nick]
  20. if {![validchan $chan]} { return }
  21. if {![botisop $chan] && ![setting:get $chan xonly]} { return }
  22. if {[matchattr $handle $black(exceptflags) $chan]} { return }
  23. set bl_protect [blacktools:protect $nick $chan]
  24. if {$bl_protect == "1"} { return }
  25. if {[isbotnick $nick]} { return }
  26. set repeatset [setting:get $chan antirepeat-setting]
  27. if {$repeatset == ""} { set repeatset "$black(antirepeat:repeats)" }
  28. set number [scan $repeatset %\[^:\]]
  29. set time [scan $repeatset %*\[^:\]:%s]
  30. foreach tmr [utimers] {
  31. if {[string match "*antirepeat:remove $host $chan $arg*" [join [lindex $tmr 1]]]} {
  32. killutimer [lindex $tmr 2]
  33. }
  34. }
  35. if {![info exists black(repeat:$host:$chan:$arg)]} {
  36. set black(repeat:$host:$chan:$arg) 0
  37. }
  38. incr black(repeat:$host:$chan:$arg)
  39. utimer $time [list antirepeat:remove $host $chan $arg]
  40. if {$black(repeat:$host:$chan:$arg) >= $number} {
  41. blacktools:banner:1 $nick "ANTIREPEAT" $chan $host [get:banmethod "antirepeat" $chan] [link:chan:get $chan]
  42. antirepeat:remove $host $chan $arg
  43. return 1
  44. }
  45. }
  46. proc antirepeat:remove {host chan arg} {
  47. global black
  48. foreach tmr [utimers] {
  49. if {[string match "*antirepeat:remove $host $chan $arg*" [join [lindex $tmr 1]]]} {
  50. killutimer [lindex $tmr 2]
  51. }
  52. }
  53. if {[info exists black(repeat:$host:$chan:$arg)]} {
  54. unset black(repeat:$host:$chan:$arg)
  55. }
  56. }
  57. proc antirepeat:protect:me {nick host hand chan keyword arg} {
  58. antirepeat:protect $nick $host $hand $chan $arg
  59. }
  60. ##############
  61. #########################################################################
  62. ## END ##
  63. #########################################################################