BT.repetitivechars.tcl 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #########################################################################
  2. ## BlackTools - The Ultimate Channel Control Script ##
  3. ## One TCL. One smart Eggdrop ##
  4. #########################################################################
  5. ####################### RepetitiveChars 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 repetitivechars:protect {nick host hand chan arg} {
  17. global black
  18. if {![validchan $chan]} { return }
  19. set handle [nick2hand $nick]
  20. if {![botisop $chan] && ![setting:get $chan xonly]} { return }
  21. if {[matchattr $handle $black(exceptflags) $chan]} { return }
  22. if {[isbotnick $nick]} { return }
  23. set bl_protect [blacktools:protect $nick $chan]
  24. if {$bl_protect == "1"} { return }
  25. set getnum [setting:get $chan repetitivechars-char]
  26. if {$getnum == ""} { set getnum "$black(repetitivechars:num)" }
  27. set llength_chars [string length $arg]
  28. set chars [split $arg ""]
  29. set counter 0
  30. set current_char ""
  31. for {set i 0 } { $i < $llength_chars } { set i [expr $i + 1] } {
  32. set char [lindex $chars $i]
  33. if {$current_char == ""} {
  34. set current_char $char
  35. set counter [expr $counter + 1]
  36. } else {
  37. if {$char != "$current_char"} {
  38. set current_char $char
  39. set counter 1
  40. } else {
  41. set counter [expr $counter + 1]
  42. }
  43. }
  44. }
  45. if {$counter >= $getnum} {
  46. blacktools:banner:1 $nick "repetitivechars" $chan $host [get:banmethod "repetitivechars" $chan] [link:chan:get $chan]
  47. return 1
  48. }
  49. }