| View previous topic :: View next topic |
| Author |
Message |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Thu Jan 25, 2018 3:38 pm Post subject: help in clone scan tcl |
|
|
I found a tcl that gives in percentage a list of real users
and which are clones, the tcl works well when the channel has only 40 users online;
| Code: | [15:09] <@sedition> .clones
[15:09] <@Kantuta> Starting clonescan for #Beni...
[15:09] <@Kantuta> (scz-181-114-110-00033.wimaxtigo.bo) Nicklist: Mster, sedition - Clones: 1
[15:09] <@Kantuta> Clones: 1 (25.0%) Realusers: 3 (75.0%) - Took: 0.894ms. |
but note that the tcl has a failure
when the channel has more than 50 users including clones and real
then give this ruling
| Code: | [15:12] <@sedition> .clones
[15:12] <Kantuta> Starting clonescan for #ReQuesT... |
and at partyline I get the error:
| Code: | | Tcl error [::clonescan::commands]: can't read "clonescan::clones(#ReQuesT:2604)": no such element in array |
the detail seems to be when the channel has more than 50 users
is where the error causes and the tcl does not work well
| Code: | 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
bind pub m|o "${trigger}clones" [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!" |
_________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon Jan 29, 2018 5:43 am Post subject: |
|
|
| Code: |
namespace eval clonescan {
variable trigger "."
bind pub m|o "${trigger}clone" [namespace current]::commands
bind pub m|o "${trigger}clones" [namespace current]::commands
proc checknick {nick} {
set skip [list "S" "Q"]
set test [expr {[lsearch -nocase $skip $nick] > -1 ? "1" : "0"}]
}
proc commands {nick uhost hand chan text} {
putquick "PRIVMSG $chan :Starting clonescan for $chan..."
set start [clock clicks]
set chanlist [chanlist $chan]
foreach user $chanlist {
if {[checknick $user]} continue
lappend userList $user
}
set len [llength $userList]
while {$len > 0} {
set u1 [lindex [split $userList] 0]
set h1 [lindex [split [getchanhost $u1 $chan] @] 1]
set userList [lreplace $userList 0 0]
foreach u2 $userList {
set h2 [lindex [split [getchanhost $u2 $chan] @] 1]
if {[string equal -nocase $h1 $h2]} {
if {[expr [lsearch -nocase [array names clones] $h1]] > -1} {
lappend clones($h1) $u2
} else {
lappend clones($h1) [list $u1 $u2]
}
}
}
incr len -1
}
set end [clock clicks]
set count 0
foreach host [array names clones] {
set nickList [join [join $clones($host)] ", "]
set len [llength $nickList]
puthelp "PRIVMSG $chan :\($host\) Nick list: $nickList - Clones: $len"
incr $count $len
}
set p(c) [expr {$len > 0 ? [format %.1f [expr ($count.0 * 100.0) / $len.0]] : "0.0"}]
set p(u) [expr (100.0 - $p(c))]
puthelp "PRIVMSG $chan :Clones: $count ($p(c)%) Real users: [expr ($len - $count)] ($p(u)%) - Took: [expr ($end-$start)/1000.0]ms."
}
}
|
Haven't tested it so let me know if get any errors.
Edit: Typo and bug fixes. _________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Tue Feb 06, 2018 2:38 am; edited 1 time in total |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Tue Jan 30, 2018 7:48 pm Post subject: |
|
|
it gives a mistake in partyline
| Code: |
[18:47:11] Tcl error [::clonescan::commands]: can't read "u1": no such variable |
_________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Tue Jan 30, 2018 7:58 pm Post subject: |
|
|
Try replace | Code: | | if {[checknick $u1]} continue |
With | Code: | | if {[checknick $user]} continue |
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Tue Jan 30, 2018 8:05 pm Post subject: |
|
|
new error
| Code: | | <JulieTh> [20:05:26] Tcl error [::clonescan::commands]: expected boolean value but got "" |
_________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Mon Feb 05, 2018 9:43 pm Post subject: |
|
|
try to use other variants but for the time being the error persists.
 _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Feb 06, 2018 2:10 am Post subject: |
|
|
Ah. A little fix for that:
| Code: |
proc checknick {nick} {
set skip [list "S" "Q"]
if {[isbotnick $nick] || [expr [lsearch -nocase $skip $nick]] > -1} return 0
return 1
}
|
with:
| Code: |
proc checknick {nick} {
set skip [list "S" "Q"]
set test [expr {[lsearch -nocase $skip $nick] > -1 ? "1" : "0"}]
}
|
If the amount of clones is 0 then:
| Code: |
set p(c) [format %.1f [expr ($count.0 * 100.0) / $len.0]]
|
will give an error so to fix that as well replace this line with:
| Code: |
set p(c) [expr {$len > 0 ? [format %.1f [expr ($count.0 * 100.0) / $len.0]] : "0.0"}]
|
If there's another user on the same host as the bot then the user and that user will show up as clones.
| Quote: |
<cez> .clones
<@bot> Starting clonescan for #channel...
<@bot> (x.x.x.x) Nick list: bot, cez - Clones: 2
<@bot> Clones: 0 (0.0%) Real users: 2 (100.0%) - Took: 0.088ms.
|
If you want to "fix" this as well then under:
| Code: |
set len [llength $userList]
|
we add:
| Code: |
set bh [lindex [split $::botname @] 1]
|
and under:
| Code: |
set h2 [lindex [split [getchanhost $u2 $chan] @] 1]
|
we add:
| Code: |
if {[string equal -nocase $bh $h2]} continue
|
and then the result will be:
| Quote: |
<cez> .clones
<@bot> Starting clonescan for #channel...
<@bot> Clones: 0 (0.0%) Realusers: 0 (100.0%) - Took: 0.086ms.
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Tue Feb 06, 2018 11:12 am Post subject: |
|
|
now it works without giving failures.
| Code: |
namespace eval clonescan {
variable trigger "."
bind pub m|o "${trigger}clone" [namespace current]::commands
bind pub m|o "${trigger}clones" [namespace current]::commands
proc checknick {nick} {
set skip [list "S" "Q"]
set test [expr {[lsearch -nocase $skip $nick] > -1 ? "1" : "0"}]
}
proc commands {nick uhost hand chan text} {
putquick "PRIVMSG $chan :Starting clonescan for $chan..."
set start [clock clicks]
set chanlist [chanlist $chan]
foreach user $chanlist {
if {[checknick $user]} continue
lappend userList $user
}
set len [llength $userList]
set bh [lindex [split $::botname @] 1]
while {$len > 0} {
set u1 [lindex [split $userList] 0]
set h1 [lindex [split [getchanhost $u1 $chan] @] 1]
set userList [lreplace $userList 0 0]
foreach u2 $userList {
set h2 [lindex [split [getchanhost $u2 $chan] @] 1]
if {[string equal -nocase $bh $h2]} continue
if {[string equal -nocase $h1 $h2]} {
if {[expr [lsearch -nocase [array names clones] $h1]] > -1} {
lappend clones($h1) $u2
} else {
lappend clones($h1) [list $u1 $u2]
}
}
}
incr len -1
}
set end [clock clicks]
set count 0
foreach host [array names clones] {
set nickList [join [join $clones($host)] ", "]
set len [llength $nickList]
puthelp "PRIVMSG $chan :\($host\) Nick list: $nickList - Clones: $len"
incr $count $len
}
set p(c) [expr {$len > 0 ? [format %.1f [expr ($count.0 * 100.0) / $len.0]] : "0.0"}]
set p(u) [expr (100.0 - $p(c))]
puthelp "PRIVMSG $chan :Clones: $count ($p(c)%) Real users: [expr ($len - $count)] ($p(u)%) - Took: [expr ($end-$start)/1000.0]ms."
}
} |
caesar the corrected tcl only shows all zero until the second calculation puts it to zero and I do not think it's real..
something is wrong because it should not give zero if there are real users connected.
| Code: | [11:09] <@sedition> .clone
[11:09] <@JulieTh> Starting clonescan for #tcls...
[11:09] <@JulieTh> Clones: 0 (0.0%) Real users: 0 (100.0%) - Took: 0.0ms. |
the right thing would be like that:
| Code: | [11:10] <@sedition> .clone
[11:10] <@JulieTh> Starting clonescan for #tcls...
[11:10] <@JulieTh> Clones: 0 (0.0%) Real users: 3 (100.0%) - Took: 3.0ms. |
_________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Thu Nov 15, 2018 9:47 pm Post subject: |
|
|
it does not work it still has failures..
 _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Nov 16, 2018 2:54 am Post subject: |
|
|
Don't know why I complicated things so much when things can be a lot simpler.
| Code: |
namespace eval clonescan {
variable trigger "."
bind pub m|o "${trigger}clone" [namespace current]::clonescan
bind pub m|o "${trigger}clones" [namespace current]::clonescan
proc checknick {nick} {
set skip [list "S" "Q"]
set test [expr {[lsearch -nocase $skip $nick] > -1 ? "1" : "0"}]
}
proc clonescan {nick uhost hand chan text} {
putquick "PRIVMSG $chan :Starting clonescan for $chan..."
set start [clock clicks]
foreach user [chanlist $chan] {
if {[checknick $user] || [isbotnick $user]} continue
set host [lindex [split [getchanhost $user $chan] @] 1]
lappend clones($host) $user
}
set count 0
foreach host [array names clones] {
set len [llength $clones($host)]
if {$len > 1} {
set nickList [join [join $clones($host)] ", "]
puthelp "PRIVMSG $chan :\($host\) Nick list: $nickList | Clones: $len"
incr count $len
}
}
set p(c) [expr {$len > 0 ? [format %.1f [expr ($count.0 * 100.0) / $len.0]] : "0.0"}]
set p(u) [expr (100.0 - $p(c))]
set end [clock clicks]
puthelp "PRIVMSG $chan :Clones: $count ($p(c)%) | Real users: [expr ($len - $count)] ($p(u)%) | Took: [expr ($end-$start)/1000.0]ms."
}
}
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Mon Nov 19, 2018 11:31 am Post subject: |
|
|
but note that the data you give is not correct
I will give an example of a report that gives the old tcl
here (old tcl)
| Code: |
[22:59] <@Arnold_X-P> .clones
[22:59] <xsedition> Starting clon escan for #lapaz ...
[22:59] <xsedition> (127.0.0.1) Nick list: Guest37056, ddrt - Clones: 1
[22:59] <xsedition> Clones: 1 (25.0%) Real users: 3 (75.0%) -Took: 0.977ms. |
I put here a report that generates the current tcl (new tcl)
| Code: |
[22:47] <@Arnold_X-P> .clone
[22:47] <xsedition> Starting clonescan for #lapaz ...
[22:47] <xsedition> (127.0.0.1) Nick list: Guest37056, ddrt | Clones: 2
[22:47] <xsedition> Clones: 2 (200.0%) | Real users: -1 (-100.0%) | Took: 0.0ms. |
the detail is that the current tcl does not generate a correct report compared to the old tcl I mean Clones: 2 (200.0%) | Real users: -1 (-100.0%)
| Code: |
namespace eval clonescan {
variable trigger "."
bind pub m|o "${trigger}clone" [namespace current]::clonescan
bind pub m|o "${trigger}clones" [namespace current]::clonescan
proc checknick {nick} {
set skip [list "S" "Q"]
set test [expr {[lsearch -nocase $skip $nick] > -1 ? "1" : "0"}]
}
proc clonescan {nick uhost hand chan text} {
putquick "PRIVMSG $chan :Starting clonescan for $chan..."
set start [clock clicks]
foreach user [chanlist $chan] {
if {[checknick $user] || [isbotnick $user]} continue
set host [lindex [split [getchanhost $user $chan] @] 1]
lappend clones($host) $user
}
set count 0
foreach host [array names clones] {
set len [llength $clones($host)]
if {$len > 1} {
set nickList [join [join $clones($host)] ", "]
puthelp "PRIVMSG $chan :\($host\) Nick list: $nickList | Clones: $len"
incr count $len
}
}
set p(c) [expr {$len > 0 ? [format %.1f [expr ($count.0 * 100.0) / $len.0]] : "0.0"}]
set p(u) [expr (100.0 - $p(c))]
set end [clock clicks]
puthelp "PRIVMSG $chan :Clones: $count ($p(c)%) | Real users: [expr ($len - $count)] ($p(u)%) | Took: [expr ($end-$start)/1000.0]ms."
}
}
|
if you notice the examples they are different and they should be the same and if you notice the second tcl the reports are very exaggerated _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon Nov 19, 2018 12:28 pm Post subject: |
|
|
Ah, i see where i did wrong. Give this a try:
| Code: |
namespace eval clonescan {
variable trigger "."
bind pub m|o "${trigger}clone" [namespace current]::clonescan
bind pub m|o "${trigger}clones" [namespace current]::clonescan
proc checknick {nick} {
set skip [list "S" "Q"]
set test [expr {[lsearch -nocase $skip $nick] > -1 ? "1" : "0"}]
}
proc clonescan {nick uhost hand chan text} {
puthelp "PRIVMSG $chan :Starting clonescan for $chan..."
set start [clock clicks]
foreach user [chanlist $chan] {
if {[checknick $user] || [isbotnick $user]} continue
set host [lindex [split [getchanhost $user $chan] @] 1]
lappend clones($host) $user
}
set total 0
set count 0
foreach host [array names clones] {
set len [llength $clones($host)]
if {$len > 1} {
set nickList [join [join $clones($host)] ", "]
puthelp "PRIVMSG $chan :\($host\) Nick list: $nickList | Clones: $len"
incr count $len
}
incr total $len
}
set p(c) [expr {$total > 0 ? [format %.1f [expr ($count.0 * 100.0) / $total.0]] : "0.0"}]
set p(u) [expr (100.0 - $p(c))]
set end [clock clicks]
puthelp "PRIVMSG $chan :Clones: $count ($p(c)%) | Real users: [expr ($total - $count)] ($p(u)%) | Took: [expr ($end-$start)/1000.0]ms."
}
}
|
Edit: Fixed. I hope.  _________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Mon Nov 19, 2018 3:56 pm; edited 1 time in total |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Mon Nov 19, 2018 2:38 pm Post subject: |
|
|
the error in the data keeps coming
old tcl
| Code: |
[14:31] <@rashino> .clones
[14:31] <@xsedition> Starting clonescan for #lapaz ...
[14:31] <@xsedition> (127.0.0.1) Nick list: Lara22, ddrt - Clones: 1
[14:31] <@xsedition> Clones: 1 (25.0%) | Real users: 3 (75.0%) - Took: 0.977ms.
|
new tcl
| Code: |
[14:32] <@rashino> .clone
[14:32] <@xsedition> Starting clonescan for #lapaz...
[14:32] <@xsedition> (127.0.0.1) Nick list: ddrt, Lara22 | Clones: 2
[14:32] <@xsedition> Clones: 2 (200.0%) | Real users: 1 (-100.0%) | Took: 0.0ms. |
the detail is here [14:32] <@xsedition> Clones: 2 (200.0%) | Real users: 1 (-100.0%) | Took: 0.0ms. _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon Nov 19, 2018 3:55 pm Post subject: |
|
|
/facepalm
Forgot to replace this line:
| Code: |
set p(c) [expr {$len > 0 ? [format %.1f [expr ($count.0 * 100.0) / $len.0]] : "0.0"}]
|
with:
| Code: |
set p(c) [expr {$total > 0 ? [format %.1f [expr ($count.0 * 100.0) / $total.0]] : "0.0"}]
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Mon Nov 19, 2018 4:20 pm Post subject: |
|
|
almost perfect but it lacks something else to work right
old tcl
| Code: |
[15:58] <@rashino> .clones
[15:58] <xsedition> Starting clonescan for #lapaz ...
[15:58] <xsedition> (localhost) NickClones: Guest37056, supr - Clones: 1
[15:58] <xsedition> Clones: 1 (25.0%) Real users: 3 (75.0%) - Took: 0.0ms.
|
new tcl
| Code: |
[16:04] <@rashino> .clone
[16:04] <xsedition> Starting clonescan for #lapaz...
[16:04] <xsedition> (localhost) Nick list: Guest37056, supr | Clones: 2
[16:04] <xsedition> Clones: 2 (66.7%) | Real users: 1 (33.3%) | Took: 0.0ms. |
the total of users online are 3 where and 1 is clone....
the correct is clones: 1 (25.0%) real user 3 (75.0%) _________________
thanks to that they help, that others learn 
Last edited by Arnold_X-P on Tue Nov 20, 2018 1:24 am; edited 1 time in total |
|
| Back to top |
|
 |
|