View previous topic :: View next topic |
Author |
Message |
simo Owner
Joined: 22 Mar 2015 Posts: 902
|
Posted: Tue Apr 19, 2022 3:30 pm Post subject: replacing certain characters in nick banmask with * |
|
|
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:
Quote: | 0-9 ` - _ [ ] { } \ | |
Code: |
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 |
|
Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 902
|
Posted: Tue Apr 19, 2022 4:03 pm Post subject: |
|
|
thanks to MMX and SpiKe^^ it has been resolved on IRC
this is the end code incase anybody needs it:
Code: |
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*!*@* }
}
|
|
|
Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 902
|
Posted: Tue Apr 19, 2022 5:53 pm Post subject: |
|
|
this is with kicks added as well
Code: |
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
}
|
|
|
Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 785 Location: Tennessee, USA
|
Posted: Wed Apr 20, 2022 12:49 am Post subject: |
|
|
This script logic makes more sense to me... Code: |
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 }
}
|
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 902
|
Posted: Wed Apr 20, 2022 12:04 pm Post subject: |
|
|
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^^ |
|
Back to top |
|
 |
|