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 » Sat Sep 10, 2022 11:14 am
this is what i have so far
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 {[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
}
CrazyCat
Revered One
Posts: 1306 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Sat Sep 10, 2022 1:02 pm
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.
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sat Sep 10, 2022 1:16 pm
thanks CrazyCat i got it to work as i wanted to
Apreciated.
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Sun Sep 11, 2022 3:56 am
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: Select all
if {!$temp} { return } {
pushmode $chan +b *$badpart*!*@*
}
just go directly with
if :
Code: Select all
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.
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sun Sep 11, 2022 4:36 am
Thanks ceasar
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sun Sep 11, 2022 6:59 am
for those that might need this as well not sure if its properly constructed but it seems to work well.
Code: Select all
# 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
}