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 

Drone score system

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


Joined: 22 Mar 2015
Posts: 705

PostPosted: Fri Nov 12, 2021 6:02 pm    Post subject: Drone score system Reply with quote

i was looking at this thread:

http://forum.egghelp.org/viewtopic.php?t=9808&postdays=0&postorder=asc&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
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 705

PostPosted: Fri Nov 12, 2021 6:12 pm    Post subject: Reply with quote

i tried this but got weird outcomes :


Code:


 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
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 882
Location: France

PostPosted: Fri Nov 12, 2021 7:39 pm    Post subject: Reply with quote

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
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 705

PostPosted: Sat Nov 13, 2021 11:30 am    Post subject: Reply with quote

hm ok thanks CC
Back to top
View user's profile Send private message
caesar
Mint Rubber


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

PostPosted: Sat Nov 13, 2021 3:55 pm    Post subject: Reply with quote

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:

foreach phx $exchost {  if {[string match -nocase $phx $uhost]} {  return 0 }  }

2. I would move this like:
Code:

if [matchattr $hand of|of $chan] return

somewhere higher like after isbotnick line.
Code:

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.
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 705

PostPosted: Sat Nov 13, 2021 5:20 pm    Post subject: Reply with quote

oh yea true didnt see that thanks caesar
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 882
Location: France

PostPosted: Thu Nov 18, 2021 8:25 am    Post subject: Reply with quote

I made a small POC: an adaptation of unreal' antirandom module in tcl: https://scripts.eggdrop.fr/details-Antirandom-s260.html
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 705

PostPosted: Thu Nov 18, 2021 8:47 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 882
Location: France

PostPosted: Thu Nov 18, 2021 9:22 am    Post subject: Reply with quote

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.
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 882
Location: France

PostPosted: Thu Nov 18, 2021 9:36 am    Post subject: Reply with quote

BTW, here is the modification of my main procedure:
Code:
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
}

_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 705

PostPosted: Thu Nov 18, 2021 10:11 am    Post subject: Reply with quote

ah ok i guess i misunderstood thanks CC
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