This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

help in clone scan tcl

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

help in clone scan tcl

Post by Arnold_X-P »

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: Select all

[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: Select all

[15:12] <@sedition> .clones
[15:12] <Kantuta> Starting clonescan for #ReQuesT...
and at partyline I get the error:

Code: Select all

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: 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
    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!"
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

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.
Last edited by caesar on Tue Feb 06, 2018 2:38 am, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

it gives a mistake in partyline

Code: Select all

[18:47:11] Tcl error [::clonescan::commands]: can't read "u1": no such variable
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Try replace

Code: Select all

if {[checknick $u1]} continue
With

Code: Select all

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
.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

new error

Code: Select all

<JulieTh> [20:05:26] Tcl error [::clonescan::commands]: expected boolean value but got ""
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

try to use other variants but for the time being the error persists.

:wink:
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Ah. A little fix for that:

Code: Select all

   proc checknick {nick} {
      set skip [list "S" "Q"]
      if {[isbotnick $nick] || [expr [lsearch -nocase $skip $nick]] > -1} return 0
      return 1
   }
with:

Code: Select all

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: Select all

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: Select all

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.
<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: Select all

set len [llength $userList]
we add:

Code: Select all

set bh [lindex [split $::botname @] 1]
and under:

Code: Select all

set h2 [lindex [split [getchanhost $u2 $chan] @] 1]
we add:

Code: Select all

if {[string equal -nocase $bh $h2]} continue
and then the result will be:
<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.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

now it works without giving failures.

Code: Select all

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: Select all

[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: Select all

[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.
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

it does not work it still has failures..
:shock:
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Don't know why I complicated things so much when things can be a lot simpler.

Code: Select all

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.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

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: Select all

[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: Select all

[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: Select all

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
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Ah, i see where i did wrong. Give this a try:

Code: Select all

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. :roll:
Last edited by caesar on Mon Nov 19, 2018 3:56 pm, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

the error in the data keeps coming
old tcl

Code: Select all

[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: Select all

 
[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.
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

/facepalm

Forgot to replace this line:

Code: Select all

set p(c) [expr {$len > 0 ? [format %.1f [expr ($count.0 * 100.0) / $len.0]] : "0.0"}] 
with:

Code: Select all

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.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

almost perfect but it lacks something else to work right
old tcl

Code: Select all

[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: Select all

[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%)
Last edited by Arnold_X-P on Tue Nov 20, 2018 1:24 am, edited 1 time in total.
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
Post Reply