BT.CloneScan.tcl 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. ## Online Help : irc://irc.undernet.org/tcl-help ##
  11. ## #TCL-HELP / UnderNet ##
  12. ## You can ask in english or romanian ##
  13. ## ##
  14. #########################################################################
  15. proc clonescan:module {nick host hand chan arg} {
  16. global black lastbind
  17. set return [blacktools:mychar $lastbind $hand]
  18. if {$return == "0"} {
  19. return
  20. }
  21. set why [lindex [split $arg] 0]
  22. set type 0
  23. if {[matchattr $hand nmo|M $chan] && ($why != "") && ![regexp {^[&#]} $why]} {
  24. set chan1 "$chan"
  25. set clone [join [lrange [split $arg] 1 end]]
  26. set number [lindex [split $arg] 1]
  27. if {[regexp {^[&#]} $why]} {
  28. set chan "$why"
  29. set why [lindex [split $arg] 1]
  30. set clone [join [lrange [split $arg] 2 end]]
  31. set number [lindex [split $arg] 2]
  32. }
  33. prot:module:process $nick $host $hand $chan $chan1 $why $clone $type $number "clonescan"
  34. return
  35. }
  36. set c [lindex [split $arg] 0]
  37. set type 0
  38. set chan1 "$chan"
  39. if {[regexp {^[&#]} $c] && [matchattr $hand nmo|M $c]} {
  40. set chan "$c"
  41. }
  42. scanner:process $nick $host $hand $chan $chan1 $type
  43. }
  44. proc scanner:process {nick host hand chan chan1 type} {
  45. global botnick black
  46. set cmd_status [btcmd:status $chan $hand "clonescan" 0]
  47. if {$cmd_status == "1"} {
  48. return
  49. }
  50. array set clones [list]
  51. if {$chan == ""} {
  52. switch $type {
  53. 0 {
  54. blacktools:tell $nick $host $hand $chan $chan1 gl.instr "clonescan"
  55. }
  56. 1 {
  57. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "clonescan"
  58. }
  59. 2 {
  60. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "clonescan"
  61. }
  62. }
  63. return 0
  64. }
  65. if {![validchan $chan]} {
  66. blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
  67. return
  68. }
  69. if {![onchan $botnick $chan]} {
  70. blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
  71. return
  72. }
  73. blacktools:tell $nick $host $hand $chan $chan1 clonescan.11 none
  74. clonescan:act $chan $nick $hand $chan1 $type 0
  75. }
  76. proc clonescan:timer {} {
  77. global black
  78. set channels ""
  79. set type 1
  80. foreach chan [channels] {
  81. if {[validchan $chan]} {
  82. if {[setting:get $chan clonescan]} {
  83. lappend channels $chan
  84. }
  85. }
  86. }
  87. if {$channels != ""} {
  88. clonescan:act $channels "nick" "" "chan1" $type 0
  89. set clonescan_time [time_return_minute $black(clonescantime)]
  90. timer $clonescan_time clonescan:timer
  91. }
  92. }
  93. proc clonescan:act {channels nick hand chan1 type counter} {
  94. global black
  95. set chan [lindex $channels $counter]
  96. set cc [expr $counter + 1]
  97. set found_clones 0
  98. array set clones [list]
  99. if {$chan != ""} {
  100. set replace(%chan%) $chan
  101. set getlang [string tolower [setting:get $chan lang]]
  102. if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
  103. if {[setting:get $chan clonescan-maxclone] == "0" || [setting:get $chan clonescan-maxclone] == ""} {
  104. set maxclone $black(maxclone)
  105. } else { set maxclone [setting:get $chan clonescan-maxclone] }
  106. if {$maxclone < "2"} { return }
  107. putlog "\[BT\] Scaning for clones on $chan.."
  108. foreach user [chanlist $chan] {
  109. set host [string tolower [lindex [split [getchanhost $user $chan] @] 1]]
  110. set findword [prot:findword $chan "CLONESCAN-EXCEPT" $host]
  111. if {$findword == "1"} {
  112. continue
  113. }
  114. if {[string match "*undernet.org*" $host]} {
  115. continue
  116. }
  117. set replace(%host%) $host
  118. lappend clones($host) $user
  119. }
  120. foreach clone [array names clones] {
  121. set userlist [join $clones($clone)]
  122. if {[llength [split $userlist]] >= $maxclone} {
  123. set found_clones 1
  124. if {$type == "0"} {
  125. blacktools:tell $nick "" $hand $chan $chan1 clonescan.10 "[llength [split $userlist]] $clone [join $clones($clone) ", "]"
  126. }
  127. if {$type == "1"} {
  128. set replace(%msg.1%) [llength [split $userlist]]
  129. set replace(%msg.2%) $clone
  130. set replace(%msg.7%) [join $clones($clone) ", "]
  131. set replace(%chan%) $chan
  132. set message [string map [array get replace] $black(say.$getlang.clonescan.10)]
  133. putserv "NOTICE @$chan :$message"
  134. set mask "*!*@$clone"
  135. blacktools:banner:2 $nick "CLONESCAN" $chan $chan1 $mask "0"
  136. }
  137. }
  138. }
  139. }
  140. if {([lindex $channels $cc] != "") && ($type == "1")} {
  141. utimer 5 [list clonescan:act $channels $nick $hand $chan1 $type $cc]
  142. }
  143. if {($type == "0") && ($found_clones == "0")} {
  144. blacktools:tell $nick "" $hand $chan $chan1 clonescan.2 none
  145. }
  146. }
  147. ##############
  148. #########################################################################
  149. ## END ##
  150. #########################################################################