BT.CloneScan.tcl 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #########################################################################
  2. ## BlackTools - The Ultimate Channel Control Script ##
  3. ## One TCL. One smart Eggdrop ##
  4. #########################################################################
  5. ########################### CLONESCAN 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 scanner:process {nick host hand chan chan1 type} {
  17. global botnick black
  18. set cmd_status [btcmd:status $chan $hand "clonescan" 0]
  19. if {$cmd_status == "1"} {
  20. return
  21. }
  22. array set clones [list]
  23. if {$chan == ""} {
  24. switch $type {
  25. 0 {
  26. blacktools:tell $nick $host $hand $chan $chan1 gl.instr "clonescan"
  27. }
  28. 1 {
  29. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "clonescan"
  30. }
  31. 2 {
  32. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "clonescan"
  33. }
  34. }
  35. return 0
  36. }
  37. if {![validchan $chan]} {
  38. blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
  39. return
  40. }
  41. if {![onchan $botnick $chan]} {
  42. blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
  43. return
  44. }
  45. blacktools:tell $nick $host $hand $chan $chan1 clonescan.11 none
  46. clonescan:act $chan $nick $host $hand $chan1 0 0
  47. }
  48. proc clonescan:timer {chans} {
  49. global black
  50. set type 1
  51. foreach chan $chans {
  52. if {[validchan $chan]} {
  53. lappend channels $chan
  54. }
  55. }
  56. if {$channels != ""} {
  57. clonescan:act $channels "nick" "" "" "chan1" $type 0
  58. }
  59. }
  60. proc clonescan:act {channels nick h hand chan1 type counter} {
  61. global black
  62. set chan [lindex $channels $counter]
  63. set cc [expr $counter + 1]
  64. set found_clones 0
  65. set found_mask ""
  66. set theclones ""
  67. array set clones [list]
  68. if {$chan != ""} {
  69. set replace(%chan%) $chan
  70. set getlang [string tolower [setting:get $chan lang]]
  71. if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
  72. if {[setting:get $chan clonescan-maxclone] == "0" || [setting:get $chan clonescan-maxclone] == ""} {
  73. set maxclone $black(maxclone)
  74. } else { set maxclone [setting:get $chan clonescan-maxclone] }
  75. if {$maxclone < "2"} { return }
  76. foreach user [chanlist $chan] {
  77. set host [string tolower [lindex [split [getchanhost $user $chan] @] 1]]
  78. set findword [prot:findword $chan "CLONESCAN-EXCEPT" $host]
  79. if {$findword == "1"} {
  80. continue
  81. }
  82. if {[string match "*undernet.org*" $host]} {
  83. continue
  84. }
  85. set replace(%host%) $host
  86. lappend clones($host) $user
  87. }
  88. foreach clone [array names clones] {
  89. set userlist [join $clones($clone)]
  90. if {[llength [split $userlist]] >= $maxclone} {
  91. set found_clones 1
  92. lappend found_mask $clone
  93. lappend theclones $clones($clone)
  94. if {$type == "0"} {
  95. blacktools:tell $nick $h $hand $chan $chan1 clonescan.10 "[llength [split $userlist]] $clone [join $clones($clone) ", "]"
  96. }
  97. }
  98. }
  99. if {$found_clones == "1"} {
  100. if {$type == "1"} {
  101. set replace(%msg.1%) [llength [split $theclones]]
  102. set replace(%msg.2%) $found_mask
  103. set replace(%msg.7%) [join $theclones " ,"]
  104. set replace(%chan%) $chan
  105. set text [black:color:set "" $black(say.$getlang.clonescan.10)]
  106. set message [string map [array get replace] $text]
  107. putserv "NOTICE @$chan :$message"
  108. foreach m $found_mask {
  109. set mask "*!*@$m"
  110. blacktools:banner:2 $nick "CLONESCAN" $chan $chan1 $mask "0" ""
  111. }
  112. who:chan $chan
  113. }
  114. }
  115. }
  116. if {([lindex $channels $cc] != "") && ($type == "1")} {
  117. utimer 5 [list clonescan:act $channels $nick $h $hand $chan1 $type $cc]
  118. }
  119. if {($type == "0") && ($found_clones == "0")} {
  120. blacktools:tell $nick $h $hand $chan $chan1 clonescan.2 none
  121. }
  122. }
  123. ##############
  124. #########################################################################
  125. ## END ##
  126. #########################################################################