Hi ppl.
Can someone write script that will scan chann for clones?
It should react on "!clone".When someone write that on channel,bot should scan clones and say results in that channel..
Regards,
Darko.
Code: Select all
namespace eval clonescan {
variable copyright "[lindex [split [info script] /] end] - v1.0.0.0 - r0t3n"
variable clones
array set clones {}
variable trigger "!"
bind pub m|o "${trigger}clone" [namespace current]::commands
}
proc clonescan::commands {nickname hostname handle channel text} {
putquick "PRIVMSG $channel :Starting clonescan for $channel..."
set start [clock clicks]
foreach user [chanlist $channel] {
if {[clonescan::checknick $user]} { continue }
foreach user1 [chanlist $channel] {
if {[clonescan::checknick $user1]} { continue }
set host [lindex [split [getchanhost $user $channel] @] 1]
set host1 [lindex [split [getchanhost $user1 $channel] @] 1]
if {![string equal -nocase $user1 $user]} {
if {[string equal -nocase $host $host1]} {
if {[info exists clonescan::clones($channel:$host)]} {
set list $clonescan::clones($channel:$host)
set add ""
if {[lsearch -exact "$list" $user] == "-1"} {
if {$add == ""} {
set add "$user"
} else {
set add "$add $user"
}
}
if {([lsearch -exact "$list" $user1] == "-1") && ([lsearch -exact "$add" $user1] == "-1")} {
if {$add == ""} {
set add "$user1"
} else {
set add "$add $user1"
}
}
if {$add != ""} {
set clonescan::clones($channel:$host) "$list $add"
}
} else {
set clonescan::clones($channel:$host) "$user $user1"
}
}
}
}
}
set end [clock clicks]
set count "0"
foreach clone [array names clonescan::clones $channel:*] {
if {$clone == ""} { return }
set host [lindex [split $clone :] 1]
set nicklist [join "[lsort -unique $clonescan::clones($channel:$host)]" ", "]
set i [expr {[clonescan::string2llength $nicklist] - 1}]
putserv "PRIVMSG $channel :\($host\) Nicklist: $nicklist - Clones: $i"
incr count $i
}
foreach variable [array names clonescan::clones $channel:*] {
unset clonescan::clones($variable)
}
putserv "PRIVMSG $channel :Clones: $count ([set p [format %.1f [expr ($count.0 * 100.0) / [set c [llength [chanlist $channel]]].0]]]%) Realusers: [expr ($c - $count)] ([expr (100.0 - $p)]%) - Took: [expr ($end-$start)/1000.0]ms."
}
proc clonescan::checknick {nickname} {
global botnick
if {[string equal -nocase $botnick $nickname] || $nickname == "Q" || $nickname == "S"} {
return 1
} else {
return 0
}
}
proc clonescan::string2llength {str} {
set i "0"
foreach x $str {
incr i 1
}
return "$i"
}
putlog "$clonescan::copyright - loaded!"