egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

replacing certain characters in nick banmask with *

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Tue Apr 19, 2022 3:30 pm    Post subject: replacing certain characters in nick banmask with * Reply with quote

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
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Tue Apr 19, 2022 4:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Tue Apr 19, 2022 5:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 785
Location: Tennessee, USA

PostPosted: Wed Apr 20, 2022 12:49 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Wed Apr 20, 2022 12:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber