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.
Help for those learning Tcl or writing their own scripts.
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Tue Aug 23, 2022 5:51 am
greetingz folks,
we have been using this tcl for a while it works fine but we wanted to be able to check for hidden badnick paterns hidden withing the nickname nicks like
badnick hidden in:
drgb-a}d-nzuickcqf
without having to use a lot of *
Code: Select all
set bnick {
"badnick"
"someverylongbadword"
"somewordthatsbad"
"veryabussivelongword"
}
bind join - * join:badnick
bind nick - * nick:badnick
proc nick:badnick {nick uhost hand chan newnick} {
join:badnick $newnick $uhost $hand $chan
}
proc join:badnick {nick uhost hand chan} {
global bnick temp
regsub -all -- {(.)\1+} $nick {\1} nick2x2
set temp 0
foreach i [string tolower $bnick] {
if {[string match *$i* [string tolower $nick2x2]]} {
set badpart $i
set temp 1
}
}
if {!$temp} { return } {
pushmode $chan +b *$badpart*!*@*
}
}
Last edited by
simo on Sun Aug 28, 2022 1:53 am, edited 3 times in total.
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Wed Aug 24, 2022 3:41 am
this is a way i know of in msl :
Code: Select all
if ($regex($gettok($nick,/( $+ $regsubex(badword|badword|badword|badword|badword|badword|badword|badword|badword|badword|badword|badword,//g,.*) $+ )/i)) { do stuff }
Last edited by
simo on Sun Aug 28, 2022 1:45 am, edited 1 time in total.
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Fri Aug 26, 2022 4:09 am
the regex basically checks for
*b*a*d*w*o*r*d*
in the nick
not sure if there is an equivalent of that in regex for eggdrop
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sun Aug 28, 2022 1:43 am
Is this not doable with regexp / regsub or a combination of the two?
Or another way perhaps
CrazyCat
Revered One
Posts: 1306 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Mon Aug 29, 2022 11:05 am
This is because
*b*a*d*w*o*r*d* must be (to be used in regexp) :
Code: Select all
[^\s]*b[^\s]*a[^\s]*d[^\s]*w[^\s]*o[^\s]*r[^\s]*d[^\s]*
You can probably make a little proc which will transform all your badnicks into the good regexp
https://regex101.com/r/Ahp8OQ/1
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Mon Aug 29, 2022 6:02 pm
Thanks crazycat but when I said it checks for *b*a*d*n*i*c*k*
I didn't mean it checks for literally * in the nick but rather it searches between chars to find hidden badword hidden between characters to evade a ban
CrazyCat
Revered One
Posts: 1306 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Mon Aug 29, 2022 6:33 pm
Did you check my regex101.com link before answering ?
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Tue Aug 30, 2022 5:59 pm
Thanks crazycat Yes i checked it it has a lot of * i wanted to prevent that to add a zillion * for each bad word to check for
CrazyCat
Revered One
Posts: 1306 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Tue Aug 30, 2022 6:43 pm
...
I said you that you can create a proc to transform your badnicks into regexp:
Code: Select all
proc bn2reg {text} {
set sep {[^\s]*}
set reg $sep
for {set i 0} {$i<=[string length $text]} {incr i} {
append reg [string index $text $i]$sep
}
return $reg
}
Test in tclsh:
Code: Select all
% proc bn2reg {text} {
set sep {[^\s]*}
set reg $sep
for {set i 0} {$i<=[string length $text]} {incr i} {
append reg [string index $text $i]$sep
}
return $reg
}
% bn2reg badnick
[^\s]*b[^\s]*a[^\s]*d[^\s]*n[^\s]*i[^\s]*c[^\s]*k[^\s]*
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Wed Aug 31, 2022 4:10 am
thanks CrazyCat let me try that
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Sep 10, 2022 5:32 am
Sorry for the late reply, i wanted to try your last posted code crazycat but im not sure how to test it with the current badnick checker i have in use the one i posted above
CrazyCat
Revered One
Posts: 1306 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Sat Sep 10, 2022 9:20 am
Just replace
Code: Select all
if {[string match *$i* [string tolower $nick2x2]]}
with
Code: Select all
if {[regexp [bn2reg $i] [string tolower $nick2x2]]}
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Sep 10, 2022 11:00 am
thanks CrazyCat
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Sep 10, 2022 11:07 am
after trial i get :
couldn't compile regular expression pattern: quantifier operand invalid
i used :
Code: Select all
if {[regexp [bn2reg $i] [string tolower $nick2x2]]} {
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Sep 10, 2022 11:09 am
ive changed to :
if {[regexp -- {[bn2reg $i]} [string tolower $nick2x2]]} {
but now it sets weird bans
17:13:25 Joins : sfbdfadnicksdjh [ident: Mibbit] *!*@32.158.124.74
17:13:25 @Hawk Sets Mode on #test to: +b *veryabussivelongword*!*@*
i guess what we were looking is +b *b*a*d*n*i*c*k*!*@*
to set wild mask ban on the detected bad part of nick
Last edited by
simo on Sat Sep 10, 2022 11:26 am, edited 3 times in total.