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.

count total score of duplicate characters in nick

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

count total score of duplicate characters in nick

Post by simo »

could this msl code be translated into tcl

Code: Select all

 if ($regex($nick,/(.)\1+/g) > 3) {   kick $chan  $nick counts $regex($nick,/(.)\1+/g) duplicate characters  }
it matches any duplicate char of any kind and counts as one and adds a total and if exceeded 3 matching duplicates it executes kick

Join :   aabbccddeeff   ~Mibbit@Amigo.Premium.net
aabbccddeeff Kicked from #tcl-test By +simo <> ( counts 6 duplicate characters )
possibly for nick change as well
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

Code: Select all

if {[set dup [regexp -all {(.)\1} $nick]] >= 3} { putkick $chan $nick "counts $dup duplicate characters" }
Last edited by heartbroken on Sun May 05, 2019 5:53 pm, edited 2 times in total.
Life iS Just a dReaM oN tHE wAy to DeaTh
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thnx for the response heartbroken

i tried this:

Code: Select all

bind join - * join:nickcheck
bind nick - * nick:nickcheck

proc nick:nickcheck {nick uhost hand chan newnick} {
    join:nickcheck $newnick $uhost $hand $chan
}

proc join:nickcheck {nick uhost hand chan} {
  global botnick
  if {[string tolower $nick] != [string tolower $botnick]} {
    if {[botisop $chan]} {
    if {[set dup [regexp -all {(.)\1} $nick]] >= 3} { 
  putkick $chan $nick "counts $dup duplicate characters" 
    }
   }
  }
}

and with a nick like hhhgggfffdddd it should detect 4 duplicate chars but instead it says it detected 5 not sure why ?
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i think i see why it counts repeated chars twice or more like gggg it counts as 2 while its repeats from 1 char and should count as 1
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

(.) -> matches any char, with \1 matches 2 same characters. if you want to match 3 same chars -> (.)\1\1 …
and regexp's -all option, gives how many matches in given string. >= checking if counted matches equal or bigger than 3 … do the job...
Life iS Just a dReaM oN tHE wAy to DeaTh
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tnx for the clarfication

also could it be done that repeat chars more than one of a char counts as 1 so hhhhhhhhh counts as 1 and gg counts as 1 and ggg counts as 1 and so on
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

for example:

gghhhhkkkkkwwwwww will have total count of 4
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

(.)\1+ will do what you want .
it matches two and more same chars in string.
Life iS Just a dReaM oN tHE wAy to DeaTh
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

excellent thanx heartbroken
Post Reply