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 

detect bad word hidden in long nicks
Goto page Previous  1, 2
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Sat Sep 10, 2022 11:14 am    Post subject: Reply with quote

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
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1108
Location: France

PostPosted: Sat Sep 10, 2022 1:02 pm    Post subject: Reply with quote

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


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Sat Sep 10, 2022 1:16 pm    Post subject: Reply with quote

thanks CrazyCat i got it to work as i wanted to

Apreciated.
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3767
Location: Mint Factory

PostPosted: Sun Sep 11, 2022 3:56 am    Post subject: Reply with quote

Would be a good idea to stop the loop once you found a match, cos that's the intended purpose, right? I mean after:
Code:

set temp 1

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


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Sun Sep 11, 2022 4:36 am    Post subject: Reply with quote

Thanks ceasar
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Sun Sep 11, 2022 6:59 am    Post subject: Reply with quote

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
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
Goto page Previous  1, 2
Page 2 of 2

 
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