View previous topic :: View next topic |
Author |
Message |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Tue Aug 23, 2022 5:51 am Post subject: detect bad word hidden in long nicks |
|
|
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:
Quote: | drgb-a}d-nzuickcqf |
without having to use a lot of *
Code: |
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 |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Wed Aug 24, 2022 3:41 am Post subject: |
|
|
this is a way i know of in msl :
Code: |
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 |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Fri Aug 26, 2022 4:09 am Post subject: |
|
|
the regex basically checks for
in the nick
not sure if there is an equivalent of that in regex for eggdrop |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Sun Aug 28, 2022 1:43 am Post subject: |
|
|
Is this not doable with regexp / regsub or a combination of the two?
Or another way perhaps |
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1108 Location: France
|
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Mon Aug 29, 2022 6:02 pm Post subject: |
|
|
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 |
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1108 Location: France
|
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Tue Aug 30, 2022 5:59 pm Post subject: |
|
|
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 |
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1108 Location: France
|
Posted: Tue Aug 30, 2022 6:43 pm Post subject: |
|
|
...
I said you that you can create a proc to transform your badnicks into regexp:
Code: | 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: | % 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]* |
_________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Wed Aug 31, 2022 4:10 am Post subject: |
|
|
thanks CrazyCat let me try that |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Sat Sep 10, 2022 5:32 am Post subject: |
|
|
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 |
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1108 Location: France
|
Posted: Sat Sep 10, 2022 9:20 am Post subject: |
|
|
Just replace
Code: | if {[string match *$i* [string tolower $nick2x2]]} |
with
Code: | if {[regexp [bn2reg $i] [string tolower $nick2x2]]} |
_________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Sat Sep 10, 2022 11:00 am Post subject: |
|
|
thanks CrazyCat |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Sat Sep 10, 2022 11:07 am Post subject: |
|
|
after trial i get :
Quote: | couldn't compile regular expression pattern: quantifier operand invalid |
i used :
Code: |
if {[regexp [bn2reg $i] [string tolower $nick2x2]]} {
|
|
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Sat Sep 10, 2022 11:09 am Post subject: |
|
|
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 |
|
Back to top |
|
 |
|