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 Apr 19, 2022 3:30 pm
greetingz, i was wondering if this could be changed to make sure that digits in the nick are replaced with a * so even if like
nick1234!*@*
to have it like
nick*!*@*
and n23ck`!*@*
to be like n*ck*!*@*
the characters we look for to replace with * are:
0-9 ` - _ [ ] { } \ |
Code: Select all
bind pub -|- !badnick pub:badnick2A
proc pub:badnick2A {nick host hand chan text} {
if {![isop $nick $chan] && ![ishalfop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }
set text
set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
set items [split $text]
if {[llength $items] < 1} { putnow "notice $nick :Syntax !nl nick" ; return }
foreach user $text { pushmode $chan +b *$user*!*@* }
}
Last edited by
simo on Tue Apr 19, 2022 11:09 pm, edited 1 time in total.
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Tue Apr 19, 2022 4:03 pm
thanks to MMX and SpiKe^^ it has been resolved on IRC
this is the end code incase anybody needs it:
Code: Select all
bind pub -|- !badnick pub:badnick2A
proc pub:badnick2A {nick host hand chan text} {
if {![isop $nick $chan] && ![ishalfop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }
set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
set items [split $text]
if {[llength $items] < 1} { putnow "notice $nick :Syntax !badnick nick" ; return }
regsub -all {[0-9\-\_`\[\]\{\}\\\|]} $text "*" text
regsub -all -- {\*{2,}} $text "*" text
foreach user $text { pushmode $chan +b *$user*!*@* }
}
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Tue Apr 19, 2022 5:53 pm
this is with kicks added as well
Code: Select all
bind pub -|- !badnick pub:badnick2A
proc pub:badnick2A {nick host hand chan text} {
if {![isop $nick $chan] && ![ishalfop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }
set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
global botnick
set users [list]
set reason "PLease change your name by using\: /nick NewNick and rejoin by using\: /join $chan ...... thank you."
set text [split $text]
regsub -all {[0-9\-\_`\[\]\{\}\\\|]} $text "*" textolo
regsub -all -- {\*{2,}} $textolo "*" textwaxem
foreach user $text {
if {![onchan $user $chan]} {
pushmode +chan +b *$textwaxem*!*@*
} else {
if {![isop $user $chan] && ![ishalfop $user $chan] && ![matchattr $hand o|o $chan]} {
pushmode $chan +b *$textwaxem*!*@*
putserv "kick $chan $user $reason" }
}
}
flushmode $chan
}
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Wed Apr 20, 2022 12:49 am
This script logic makes more sense to me...
Code: Select all
bind pub -|- !badnick pub:badnick2A
proc pub:badnick2A {nick host hand chan text} {
if {![isop $nick $chan] && ![ishalfop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }
set nklist [split [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]]
if {![llength $nklist]} { putnow "notice $nick :Syntax: !badnick nick" ; return 0 }
set reason "Please change your nick by using: /nick NewNick and rejoin by using: /join $chan ...... thank you."
set users [list]
foreach user $nklist {
if {[onchan $user $chan]} {
if {![isop $user $chan] && ![ishalfop $user $chan] && ![matchattr [nick2hand $user $chan] o|o $chan]} {
pushmode $chan +b *[string trim [regsub -all {[^a-zA-Z]+} $user "*"] "*"]*!*@*
lappend users $user
}
} else { pushmode $chan +b *[string trim [regsub -all {[^a-zA-Z]+} $user "*"] "*"]*!*@* }
}
flushmode $chan
if {[llength $users]} { putkick $chan [join $users ","] $reason }
}
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Wed Apr 20, 2022 12:04 pm
yes your right that makes more sense as i got the double * if chars are placed at end and start of nick tested it and it seems to work as expected
thanks SpiKe^^