egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CloneScanner Showing Too Many results

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
ComputerTech
Op


Joined: 22 Feb 2020
Posts: 140
Location: Northern Ireland

PostPosted: Sun May 24, 2020 9:19 pm    Post subject: CloneScanner Showing Too Many results Reply with quote

Hello all me and my friend made this script it's a simple clonescanner that has two options pm/notices the user of what clones there is or simply kickbans the clones so far it's been good, but there is a problem once the clones are kickbanned i remove the ban and make the clone return the bot kicks the clone right away without me typing !clonescan

Geo on freenode #eggdrop told me to put this line

Code:

putlog $cloneslist


before the kick and it gave these results

http://paste.tclhelp.net/?id=6jd6

by the way my two test clones are kai and black

so here is the script



Code:
set sect "1"

namespace eval ::CloneScan {

   bind pub o|o !clonescan ::CloneScan::clonescan

   proc areClones { user other chan } {
      if {$user == $other} {
         return 0
      }
      if {[getchanhost $user $chan] == [getchanhost $other $chan]} {
         return 1
      }
      return 0
   }
   proc listClones { user chan } {
      set clones {}
      foreach other [chanlist $chan] {
         if {[areClones $user $other $chan]} {
            lappend clones $other
         }
      }
      if {[llength $clones]} {
         lappend clones $user
      }
      return $clones ;
   }

   proc clonescan {nick host hand chan arg} {
      global sect
      set userlist [chanlist $chan]
      set cloneslist {}
      set banlist {}
      foreach user $userlist {
         # if user has been detected as clone before, no need to check again!
         if {[lsearch -exact $cloneslist $user] != -1} {
            continue
         }
         set clones [listClones $user $chan]
         foreach clone $clones {
            lappend cloneslist $clone
         }
         lappend banlist [lindex $clones 0]
      }
      if {$sect == "1"} {
         foreach nik $banlist {
            set uhost [getchanhost $nick $chan]
            set mask $host
            foreach nick $cloneslist {
               putlog $cloneslist
                               pushmode $chan +b $host; after 200 putkick $chan $nick <3
         
                           }
         }
      }
      if {$sect == "0"} {
         set realusers {}
         foreach user $userlist {
            if {[lsearch -exact $cloneslist $user] == -1} {
               lappend realusers $user
            }
         }
         set numreal [llength $realusers]
         set numclones [llength $cloneslist]
         putserv "PRIVMSG $chan :CloneScan: There are $numreal real users on $chan ($numclones clones found)."
         putserv "PRIVMSG $chan :CloneScan: The clones are: [join $cloneslist]"

      }
   }
} ;#end namspace CloneScan


cheers all who help me with this in advanced Smile
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3645
Location: Mint Factory

PostPosted: Mon May 25, 2020 12:45 am    Post subject: Reply with quote

See if this taken from another topic (link) works:
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: [expr $len - 1]"
            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."
   }
}

and we can add the punishment later.
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
ComputerTech
Op


Joined: 22 Feb 2020
Posts: 140
Location: Northern Ireland

PostPosted: Mon May 25, 2020 7:26 am    Post subject: Reply with quote

Alright so i tested the script you provided me and here is the results.

Code:

<Techy> Starting clonescan for ##computertech123...
<Techy> (bitcoinshell.mooo.com) Nick list: Kai, BLACK - Clones: 1
<Techy> (unaffiliated/computertech) Nick list: CT123, ComputerTech - Clones: 1
<Techy> Clones: 4 (12.1%) | Real users: 29 (87.9%) | Took: 0.427ms.


seems to work pretty good


my not need the percentage info %

but it seems awesome Very Happy

maybe this would need changed
Code:

<Techy> (bitcoinshell.mooo.com) Nick list: Kai, BLACK - Clones: 1

Code:

since there was Two clones the results would need to be Clones: 2

prehaps we could change that to my liking hehe Wink
and add a punishment as you mentioned above

also cheers caesar in advanced appreciate your help Very Happy
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3645
Location: Mint Factory

PostPosted: Mon May 25, 2020 9:35 am    Post subject: Reply with quote

In the original topic first was considered "human" and the second one was the clone, hence the numbers says 1 clone.

Anyway, so, basically you want on-command to scan and punish clones if are more than specified amount? I've linked to this old code cos I found the percentage interesting. Smile
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
ComputerTech
Op


Joined: 22 Feb 2020
Posts: 140
Location: Northern Ireland

PostPosted: Mon May 25, 2020 10:34 am    Post subject: Reply with quote

yeah i do like the percentage thing thats cool
so i'll keep it

what i want is for me to be able to set two options

to scan for clones and if over set amount privmsg me

and for the other option


to simply kickban all clones if over set amount Very Happy

and also dont want this script to scan for clones when they join, i want this script to simply only activate on command Smile
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ComputerTech
Op


Joined: 22 Feb 2020
Posts: 140
Location: Northern Ireland

PostPosted: Mon May 25, 2020 10:05 pm    Post subject: Reply with quote

now i tried to edit the clonescanner you gave me and here's as far as i got so far

Code:


       set trigger "!"
       
       set ghz "1"     
 
       bind pub -|- "${trigger}clones" [namespace current]::clonescan
       
   
       proc clonescan {nick uhost hand chan text} {
          global ghz
          puthelp "NOTICE $nick :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
          if {$ghz == "0"} {
           foreach host [array names clones] {
             set len [llength $clones($host)]
             if {$len > 1} {
                set nickList [join [join $clones($host)] ", "]
                puthelp "NOTICE $nick :\($host\) Nick list: $nickList - Clones: [expr $len - 1]"
                 }
             if {$ghz == "1"} {
            foreach cloneXz $nickList {putnow "kick $chan $cloneXz"}
          }

                incr count $len
             }
             incr total $len

  }
}


not sure if you see what i'm trying to do, but i hope you can help me out what i'm doing wrong

if i set

Code:

set ghz "1"


it privmsg's me of the clones which is good but when i set it to 0 it just stays at

-Techy- Starting clonescan for ###789...

so not sure what i'm doing wrong hehe cheers Very Happy

and after i get this going i will tidy the script up hehe
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3645
Location: Mint Factory

PostPosted: Tue May 26, 2020 5:57 am    Post subject: Reply with quote

Untested code:
Code:

namespace eval clonescan {

   set trigger "!"
   set ghz "1"     
   set skip { "S" "Q" }

   bind pub -|- "${trigger}clones" [namespace current]::clonescan

   proc checknick {nick} {
      variable skip
      set test [expr {[lsearch -nocase $skip $nick] > -1 ? "1" : "0"}]
   }
   
   proc clonescan {nick uhost hand chan text} {
      global ghz
      puthelp "NOTICE $nick :Starting clonescan for $chan..."
      foreach user [chanlist $chan] {
         if {[checknick $user] || [isbotnick $user]} continue
         set host [lindex [split [getchanhost $user $chan] @] 1]
         lappend clones($host) $user
      }
      switch -- $ghz {
         0 {
            foreach host [array names clones] {
               set len [llength $clones($host)]
               if {$len > 1} {
                  set nickList [join [join $clones($host)] ", "]
                  puthelp "NOTICE $nick :\($host\) Nick list: $nickList - Clones: [expr $len - 1]"
                  incr count $len
               }
            }
         }
         1 {
            set kickList {}
            set banList {}
            foreach host [array names clones] {
               set len [llength $clones($host)]
               if {$len > 1} {
                  lappend kickList [join $clones($host)]
                  lappend banList "*!*@$host"
               }
            }
            stackBans $chan $banList
            stackKicks $chan $kicklist "We don't like clones."
         }
         default { return }
      }
   }
   
   proc stackBans {chan banlist} {
      set max 25
      set count [llength $banlist]
      while {$count > 0} {
         if {$count> $max} {
            set mode [string repeat "b" $max]
            set masks [join [lrange $banlist 0 [expr {$max - 1}]]]
            set banlist [lrange $banlist $max end]
            incr count -$max
            incr total $max
          } else {
            set mode [string repeat "b" $count]
            set masks [join $banlist]
            incr total $count
            set count 0
         }
         puthelp "MODE $chan +$mode $masks"
      }
   }
   
   proc stackKicks {chan kicklist reason} {
      set max 25
      set count [llength $kicklist]
      while {$count > 0} {
         if {$count > $max} {
            set users [join [lrange $kicklist 0 [expr {$max - 1}]] ","]
            set kicklist [lrange $kicklist $max end]
            incr count -$max
         } else {
            set users [join $kicklist ","]
            set count 0
         }
         puthelp "KICK $chan $users :$reason"
      }
   }
}

Typo fixed.
_________________
Once the game is over, the king and the pawn go back in the same box.


Last edited by caesar on Tue May 26, 2020 10:49 am; edited 1 time in total
Back to top
View user's profile Send private message
ComputerTech
Op


Joined: 22 Feb 2020
Posts: 140
Location: Northern Ireland

PostPosted: Tue May 26, 2020 7:45 am    Post subject: Reply with quote

getting this error

Code:

Tcl error [::clonescan::clonescan]: can't read "skip": no such variable


also not sure if this helps but..

http://paste.tclhelp.net/?id=6jeu

would that error cause a problem?
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1099

PostPosted: Tue May 26, 2020 8:53 am    Post subject: Reply with quote

Simple typo.
Look for where the variable is set.
See the difference in: kicklist and kickList .
_________________
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber