View previous topic :: View next topic |
Author |
Message |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Sat Sep 10, 2022 11:14 am Post subject: |
|
|
this is what i have so far
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 {[regexp -- {[bn2reg $i]} [string tolower $nick2x2]]} {
set badpart $i
set temp 1
}
}
if {!$temp} { return } {
pushmode $chan +b *$badpart*!*@*
}
}
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
}
|
|
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1108 Location: France
|
Posted: Sat Sep 10, 2022 1:02 pm Post subject: |
|
|
Try to explain simply what you want to do if you really want help. I'm fed up with reading between lines or wait for another post to decrypt what you try to do.
You now have all the leads you need to do your script. _________________ 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 1:16 pm Post subject: |
|
|
thanks CrazyCat i got it to work as i wanted to
Apreciated. |
|
Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3767 Location: Mint Factory
|
Posted: Sun Sep 11, 2022 3:56 am Post subject: |
|
|
Would be a good idea to stop the loop once you found a match, cos that's the intended purpose, right? I mean after:
just add a 'break' to stop the loop. Also you don't need the if .. else part in this:
Code: |
if {!$temp} { return } {
pushmode $chan +b *$badpart*!*@*
}
|
just go directly with if:
Code: |
if {$temp} {
pushmode $chan +b *$badpart*!*@*
}
|
Oh, and you could optimize this and add a 'reahsh' bind where you build the regexp only once into a different variable and use it from there, no point on building it every time a user joins the channel. This should save you some time/resources. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Sun Sep 11, 2022 4:36 am Post subject: |
|
|
Thanks ceasar |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Sun Sep 11, 2022 6:59 am Post subject: |
|
|
for those that might need this as well not sure if its properly constructed but it seems to work well.
Code: |
# to enable on channel via partyline Syntax: .chanset #channel +badnickchecker
# or to enable in channel !badnick on / off
bind PUB -|- !badnick badnick:checker
bind PUB n !badnick badnick:checker
proc badnick:checker {nick uhost hand chan arg} {
switch -nocase -- [lindex [split $arg] 0] {
on {
if {[channel get $chan badnickchecker]} {
putserv "NOTICE $nick :badnickchecker is already enabled on $chan."
} else {
channel set $chan +badnickchecker
putserv "NOTICE $nick :badnickchecker is now enabled."
}
}
off {
if {![channel get $chan badnickchecker]} {
putserv "NOTICE $nick :badnickchecker is already disabled on $chan."
} else {
channel set $chan -badnickchecker
putserv "NOTICE $nick :badnickchecker is now disabled."
}
}
}
}
setudef flag badnickchecker
set bnick {
"SomeVeryLongBadNick"
"SomeVeryLongBadNick"
"SomeVeryLongBadNick"
"SomeVeryLongBadNick"
"SomeVeryLongBadNick"
"SomeVeryLongBadNick"
"SomeVeryLongBadNick"
}
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} {
if {![channel get $chan badnickchecker]} { return }
global bnick temp
set temp 0
foreach xix [string tolower $bnick] {
if {[string match "[bn2reg $xix]" [string tolower $nick]]} {
set bdpart [bn2reg $xix]
regsub -all {\*{1,}} $bdpart "*" bdpartxc
set badpart $bdpartxc
set temp 1
break
}
}
if {$temp} {
set chost [getchanhost $nick $chan]
set masxs [maskhost $nick!$chost 2]
pushmode $chan +b $badpart!*@*
}
}
proc bn2reg {text} {
set sep {*}
set reg $sep
for {set i 0} {$i<=[string length $text]} {incr i} {
append reg [string index $text $i]$sep
}
return $reg
}
|
|
|
Back to top |
|
 |
|