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.

Drone score system

Help for those learning Tcl or writing their own scripts.
Post Reply
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Drone score system

Post by simo »

i was looking at this thread:

http://forum.egghelp.org/viewtopic.php? ... c&start=15

and was wondering how the score actually gets counted i wanted to use it and count the actual chars used

like the amount of CAPS used
the amount of digits used
the amount other chars used and get a total of all these combined
except it should count in nick only and disregard ident
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i tried this but got weird outcomes :

Code: Select all


 set exchost { 
    "*.irccloud.com" 
} 




set threshold 5

bind nick - * nick:check_drone

proc nick:check_drone {nick uhost hand chan newnick} {
    check_drone $newnick $uhost $hand $chan
}


bind join - * check_drone
 
proc check_drone {nick uhost hand chan} {
  global exchost
  if {[isbotnick $nick]} return
  if {([regexp {^guest.+[0-9]{4}$} [string tolower $nick]])} { return } 
  foreach phx $exchost {  if {[string match -nocase $phx $uhost]} {  return 0 }  }
       if [matchattr $hand of|of $chan] return 
      putserv "privmsg $chan :[sb:score $nick] - $nick"
  if {[sb:score $nick] >= $::threshold} {  
         set chost [getchanhost $nick $chan]
        set bmask [maskhost "$nick!$chost" 2]
        pushmode $chan +b $bmask  
 }
}



proc sb:score {str} {
   set score 0
   set vowel "aeiouyxq"
   set other "{}\\\[\\\]-_^`|\\\\"
   set digit "0123456789"
   set caps "ABCDEFGHIJKLMNOPQRSTUVWXYZ"  
   set str [string tolower $str]

   incr score [llength [regexp -all -inline \[$caps\]{2,} $str]]
   incr score [llength [regexp -all -inline \[$vowel\]{2,} $str]]
   incr score [llength [regexp -all -inline \[$other\]{2,} $str]]
   incr score [llength [regexp -all -inline \[$digit\]{2,} $str]]

   incr score [llength [regexp -all -inline \[$caps$digit\]{2,} $str]]
   incr score [llength [regexp -all -inline \[$caps$other\]{2,} $str]]
   incr score [llength [regexp -all -inline \[$vowel$other\]{2,} $str]]
   incr score [llength [regexp -all -inline \[$caps$other\]{2,} $str]]
   incr score [llength [regexp -all -inline \[$vowel$digit\]{2,} $str]]
   incr score [llength [regexp -all -inline \[$caps$digit\]{2,} $str]]
   incr score [llength [regexp -all -inline \[$other$digit\]{2,} $str]]
  # incr score $score
}


for example this nick: wlwiaC|on[3]D-axry shows a score of 4 wich is odd as it has lots of chars that should be counted

what we where looking for is :

aeiuo = 5 consonants counted
meaning ABCD = 4 CAPS counted
1234 = 4 digits counted
_|[] = 4 other chars counted

a total score of 17 counted
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Didn't fully look your script, and didn't read the referenced post, but first thing I can see is that all your counts using caps won't work, because you transform the input string to lowercase.

And you have two duplicate count: \[$caps$digit\]{2,} and \[$caps$other\]{2,}

Note that the count are done on minimum 2 consecutive matches (the {2,} in regexp). Here is, in usual language, what you really count with your example:
- number of successive caps (doesn't work, gives 0)
- number of successive vowel (gives 1, only "ia" matches)
- number of successive others chars (gives 0)
- number of successive digits (gives 0)
- number of successive caps and digits (see digits, gives 0)
- number of successive caps and others (see others, gives 0)
- number of successive vowel and others (may give 3: "ia", "on" "-a")
- (duplicate) number of successive caps and others (see others, gives 0)
- number of successive vowel and digits (may give 1: "ia")
- (duplicate) number of successive caps and digits (see digits, gives 0)
- number of successive other and digits (may give 1, "[3]")

Gives me a total of 5
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

hm ok thanks CC
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

A bit of nitpicking:
1. don't use return in a loop. want to stop? just break it, I mean literally, use break not return.

Code: Select all

foreach phx $exchost {  if {[string match -nocase $phx $uhost]} {  return 0 }  } 
2. I would move this like:

Code: Select all

if [matchattr $hand of|of $chan] return 
somewhere higher like after isbotnick line.

Code: Select all

set chost [getchanhost $nick $chan]
set bmask [maskhost "$nick!$chost" 2] 
3. you don't need first line cos you already got the result in $uhost variable, and you don't need the second line cos would return *!ident@host that you again got in $uhost variable.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

oh yea true didnt see that thanks caesar
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

I made a small POC: an adaptation of unreal' antirandom module in tcl: https://scripts.eggdrop.fr/details-Antirandom-s260.html
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks CC i checked it out but it doesnt seem to have a check for special chars like :

set vowel "aeiouyxq"
set other "{}\\\[\\\]-_^`|\\\\"
set digit "0123456789"
set caps "ABCDEFGHIJKLMNOPQRSTUVWXYZ"


as thats what we get most

it seems a pub command check while we wanted on join check
and we wanted to check nick only or check for a combi of nick and ident
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

As I said, my script is just a proof of concept to do a tcl version of the unreal antirandom module.

you can add count for caps and other chars in my script if you want, and replace the bind pub with a bind join.
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

BTW, here is the modification of my main procedure:

Code: Select all

proc check {ustring} {
	set score 0
	if { [string length $ustring]<3 } { return 0 }
	set digits [llength [regexp -all -inline -- {[0-9]} $ustring]]
	set consonants [llength [regexp -all -inline -nocase -- {[bcdfghjklmnpqrstvwxz]} $ustring]]
	set vowels [llength [regexp -all -inline -nocase -- {[aeiuoy]} $ustring]]
	set others [llength [regexp -all -inline -- {[\{\}\[\]\-\_\^\`\|\\]} $ustring]]
	set caps [llength [regexp -all -inline -- {[A-Z]} $ustring]]
	if {$digits >= 5 } { incr score $digits }
	if {$consonants >= 4} { incr score $consonants }
	if {$vowels >= 4} { incr score $vowels }
	if {$others >= 5 } { incr score $others }
	if {$caps >= 5 } { incr score $caps }
	putlog "DBG : $digits digits, $consonants consonants, $vowels vowels, $others others, $caps caps"
	set two [string range $ustring 0 1]
	if {[info exists ::antirand::triple($two)]} {
		foreach l [split [string range $ustring 2 end] {}] {
			if {[string first $l $::antirand::triple($two)]!=-1} { incr score }
		}
	}
	return $score
}
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

ah ok i guess i misunderstood thanks CC
Post Reply