BT.antijoinflood.tcl 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #########################################################################
  2. ## BlackTools - The Ultimate Channel Control Script ##
  3. ## One TCL. One smart Eggdrop ##
  4. #########################################################################
  5. ####################### ANTIJOINFLOOD 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 joinflood:unlock {chan modes} {
  17. global black
  18. putquick "MODE $chan -$modes"
  19. if {[info exists black(floodjoin:on:$chan)]} {
  20. unset black(floodjoin:on:$chan)
  21. }
  22. }
  23. proc joinflood:unset {chan} {
  24. global black
  25. if {[info exists black(antijoinflood:$chan)]} {
  26. unset black(antijoinflood:$chan)
  27. }
  28. }
  29. proc joinflood:unset:host {chan host} {
  30. global black
  31. if {[info exists black(antijoinflood:$host:$chan)]} {
  32. unset black(antijoinflood:$host:$chan)
  33. }
  34. }
  35. proc joinflood:protect {nick host hand chan} {
  36. global black
  37. if {[setting:get $chan antijoinflood]} {
  38. if {[isbotnick $nick]} { return }
  39. set check_webchat [check:webchat $host]
  40. if {$check_webchat == "1"} {
  41. set ident [lindex [split $host "@"] 0]
  42. set host "*!$ident@*"
  43. }
  44. set user_getset [setting:get $chan antijoinflood-userset]
  45. set getset [setting:get $chan joinflood]
  46. if {$user_getset == ""} { set user_getset $black(antijoinflood_user_joins) }
  47. if {$getset == ""} { set getset $black(joinflood:protect) }
  48. set user_num [scan $user_getset %\[^:\]]
  49. set user_time [scan $user_getset %*\[^:\]:%s]
  50. set num [scan $getset %\[^:\]]
  51. set time [scan $getset %*\[^:\]:%s]
  52. set replace(%chan%) $chan
  53. if {![info exists black(floodjoin:on:$chan)]} {
  54. foreach tmr [utimers] {
  55. if {[string match "*joinflood:unset $chan*" [join [lindex $tmr 1]]]} {
  56. killutimer [lindex $tmr 2]
  57. }
  58. }
  59. if {![info exists black(antijoinflood:$chan)]} {
  60. set black(antijoinflood:$chan) 0
  61. }
  62. incr black(antijoinflood:$chan)
  63. utimer $time [list joinflood:unset $chan]
  64. if {$black(antijoinflood:$chan) >= "$num"} {
  65. if {![botisop $chan] && ![setting:get $chan xonly]} { return }
  66. set black(floodjoin:on:$chan) 1
  67. set modes [joinflood:getmodes $chan]
  68. if {$modes != ""} {
  69. putquick "MODE $chan +$modes" ; utimer $black(nomodetime) [list joinflood:unlock $chan $modes]
  70. }
  71. if {$black(fjoinhow) == "1"} {
  72. set getlang [string tolower [setting:get $chan lang]]
  73. if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
  74. set getmessage $black(say.$getlang.antijoinflood.2)
  75. set message [string map [array get replace] $getmessage]
  76. puthelp "NOTICE @$chan :$message"
  77. }
  78. }
  79. }
  80. foreach tmr [utimers] {
  81. if {[string match "*joinflood:unset:host $chan $host*" [join [lindex $tmr 1]]]} {
  82. killutimer [lindex $tmr 2]
  83. }
  84. }
  85. if {![info exists black(antijoinflood:$host:$chan)]} {
  86. set black(antijoinflood:$host:$chan) 0
  87. }
  88. incr black(antijoinflood:$host:$chan)
  89. utimer $user_time [list joinflood:unset:host $chan $host]
  90. if {$black(antijoinflood:$host:$chan) >= "$user_num"} {
  91. blacktools:banner:2 $nick "ANTIJOINFLOOD" $chan $chan $host "0" ""
  92. who:chan $chan
  93. if {[info exists black(antijoinflood:$host:$chan)]} {
  94. unset black(antijoinflood:$host:$chan)
  95. }
  96. }
  97. }
  98. }
  99. proc joinflood:getmodes {chan} {
  100. global black
  101. set current_modes [getchanmode $chan]
  102. set putmode ""
  103. set chanmodes [string map {"+" ""} [split [lindex $current_modes 0] ""]]
  104. foreach mod [split $black(modes) ""] {
  105. if {[lsearch $chanmodes $mod] < 0} {
  106. lappend putmode $mod
  107. }
  108. }
  109. return $putmode
  110. }
  111. ##############
  112. #########################################################################
  113. ## END ##
  114. #########################################################################