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 

count total score of duplicate characters in nick

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Master


Joined: 22 Mar 2015
Posts: 330

PostPosted: Sun May 05, 2019 2:45 pm    Post subject: count total score of duplicate characters in nick Reply with quote

could this msl code be translated into tcl

Code:

 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


Quote:

Join : aabbccddeeff ~Mibbit@Amigo.Premium.net
aabbccddeeff Kicked from #tcl-test By +simo <> ( counts 6 duplicate characters )


possibly for nick change as well
Back to top
View user's profile Send private message
heartbroken
Halfop


Joined: 23 Jun 2011
Posts: 93
Location: somewhere out there

PostPosted: Sun May 05, 2019 3:46 pm    Post subject: Reply with quote

Code:
if {[set dup [regexp -all {(.)\1} $nick]] >= 3} { putkick $chan $nick "counts $dup duplicate characters" }

_________________
Life iS Just a dReaM oN tHE wAy to DeaTh


Last edited by heartbroken on Sun May 05, 2019 5:53 pm; edited 2 times in total
Back to top
View user's profile Send private message
simo
Master


Joined: 22 Mar 2015
Posts: 330

PostPosted: Sun May 05, 2019 5:44 pm    Post subject: Reply with quote

thnx for the response heartbroken

i tried this:

Code:

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


Joined: 22 Mar 2015
Posts: 330

PostPosted: Sun May 05, 2019 5:51 pm    Post subject: Reply with quote

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


Joined: 23 Jun 2011
Posts: 93
Location: somewhere out there

PostPosted: Sun May 05, 2019 6:00 pm    Post subject: Reply with quote

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


Joined: 22 Mar 2015
Posts: 330

PostPosted: Sun May 05, 2019 6:21 pm    Post subject: Reply with quote

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


Joined: 22 Mar 2015
Posts: 330

PostPosted: Mon May 06, 2019 10:38 am    Post subject: Reply with quote

for example:

gghhhhkkkkkwwwwww will have total count of 4
Back to top
View user's profile Send private message
heartbroken
Halfop


Joined: 23 Jun 2011
Posts: 93
Location: somewhere out there

PostPosted: Mon May 06, 2019 4:48 pm    Post subject: Reply with quote

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


Joined: 22 Mar 2015
Posts: 330

PostPosted: Mon May 06, 2019 6:12 pm    Post subject: Reply with quote

excellent thanx heartbroken
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 -> Script Requests 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