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.

Badnick3.0.tcl <== my bot kickban to all users

Old posts that have not been replied to for several years.
Locked
f
forever79
Voice
Posts: 18
Joined: Sat Jun 21, 2003 6:12 pm

Badnick3.0.tcl <== my bot kickban to all users

Post by forever79 »

hi
i want to use badnick protection on my bot
i try to badnick3.0
and my bot kickban to all users
what is the problem

Code: Select all

#Set this to all the bad nicks you would like to ban for.Wildcards supported.
set bnick {
  "*[censored]*" 
  "*rape*" 
  "*fuk*" 
  "*badwa" 
  "*phudi*" 
  "*fudi" 
  "*pussy*" 
  "*boobs*" 
  "*porn*" 
  "*p0rn*"}

#Set this to the time for which you would like to place a bad nick host on ban.
#0 makes the ban permanent.(Not recommended)
set bnick_bantime 30

#Set this to the time after which you would like to reset the timer for the
#bad nick.
set bnick_reset 60

#Set this to the number of times you want to warn before you would like to
#place ban.0 gives no warnings.
set bnick_warnings 0

#Set this to the reason to be given while kicking the offender the first time.
set bnick_kick "Your nick offends me.Change it and come back."

#Set this to the reason while banning the user after bnick_warnings have expired
set bnick_ban "I think I told you to change ur nick.Now we don't need you."

# How do you want it to mask a ban?  Default == 2
#      0 - *!user@host.domain
#      1 - *!*user@host.domain
#      2 - *!*@host.domain
#      3 - *!*user@*.domain
#      4 - *!*@*.domain
#      5 - nick!user@host.domain
#      6 - nick!*user@host.domain
#      7 - nick!*@host.domain
#      8 - nick!*user@*.domain
#      9 - nick!*@*.domain
#     You can also specify a type of 10 to 19 which correspond to masks 0 to 9, but
#     instead of using a * wildcard to replace portions of the host.domain, it uses ?
#     wildcards to replace the numbers in the address.
set bnick_ban_type 2

###############################################################################
## You can edit below this but dont mail me if things start acting weird :Ş  ##
###############################################################################
bind join - * bnick:check
bind nick - * bnick:check

proc bnick:check {nick uhost hand chan {newnick ""}} {
	global logo bnicks bnick_bantime bnick bnick_reset bnick_warnings bnick_kick bnick_ban bnick_ban_type
	if {$newnick == ""} {set newnick $nick}
	foreach bword [split $bnick "\n"] {		
		if {[regexp -nocase $bword $newnick] && [botisop $chan]} {
			if {![info exists bnicks($uhost)]} {
				set bnicks($uhost) 1
				putkick $chan $newnick "$bnick_kick [count_update 0]  $logo"
				timer $bnick_reset "unset bnicks($uhost)"
				putlog "Warned and kicked $newnick on $chan for using bad nicks."
				puthelp "NOTICE $newnick :Change your nick before you come to $chan.The next time I catch you using bad nicks, I will ban you.  $logo"
				} {
				if {$bnicks($uhost) < $bnick_warnings} {
					incr bnicks($uhost)
					bnick:resettimer "bnicks($uhost)"
					timer $bnick_reset "unset bnicks($uhost)"
					putkick $chan $newnick "Warning $bnicks($uhost) for using bad nicks.Be careful I am watching you... [count_update 0]  $logo"
					puthelp "NOTICE $newnick :Join $chan with a bad nick for [expr $bnick_warnings - $bnick($uhost)] more time(s) and I will make sure you will join no more.  $logo"
					putlog "Warning $bnick($uhost) for $newnick on $chan for using bad nicks."
				} {
					unset bnicks($uhost)
					bnick:resettimer "bnicks($uhost)"
					newchanban $chan [bnick:masktype $nick!$uhost $bnick_ban_type] "Bad Nick Protection" "$bnick_ban [count_update 1]  $logo" $$bnick_bantime
					putkick $chan $newnick "$bnick_ban [count_update 1]  $logo"
				}
				}
		}
	}
}
proc bnick:resettimer {reset} {
	foreach time_check [string tolower [timers]] {
		if {[string match *$reset* $time_check]} {killtimer [lindex [split $time_check] end]}
	}
}

proc bnick:replace {string subs} {
 if {[llength $subs] == "1"} {set subs [lindex $subs 0]}
 for {set i 0} {[lindex $subs $i] != ""} {incr i 2} {
  regsub -all -- [lindex $subs $i] $string [lindex $subs [expr $i+1]] string
 } ; return $string
}

proc bnick:masktype {uhost type} {
 if {![string match "*!*@*.*" $uhost]} {
  set nick [lindex [split $uhost "!"] 0] ; set uhost "$nick![getchanhost $nick]"
  if {$uhost == "$nick!"} {set type "return_nothing"}
 }
 switch -exact $type {
  0 {set ban "*[string range $uhost [string first ! $uhost] e]"}
  1 {set ban "*!*[string trimleft [string range $uhost [expr [string first ! $uhost]+1] e] "~"]"}
  2 {set ban "*!*[string range $uhost [string first @ $uhost] e]"}
  3 {
   set ident [string range $uhost [expr [string first ! $uhost]+1] [expr [string last @ $uhost]-1]]
   set ban "*!*[string trimleft $ident "~"][string range [maskhost $uhost] [string first @ [maskhost $uhost]] e]"
  }
  4 {set ban "*!*[string range [maskhost $uhost] [string last "@" [maskhost $uhost]] e]"}
  5 {set ban $uhost}
  6 {
   set nick [string range $uhost 0 [expr [string first "!" $uhost]-1]]
   set ident [string range $uhost [expr [string first "!" $uhost]+1] [expr [string last "@" $uhost]-1]]
   set ban "$nick!*[string trimleft $ident "~"][string range $uhost [string last "@" $uhost] e]"
  }
  7 {
   set nick [string range $uhost 0 [expr [string first "!" $uhost]-1]]
   set ban "$nick!*[string range $uhost [string last "@" $uhost] e]"
  }
  8 {
   set nick [string range $uhost 0 [expr [string first "!" $uhost]-1]]
   set ident [string range $uhost [expr [string first "!" $uhost]+1] [expr [string last "@" $uhost]-1]]
   set ban "$nick!*[string trimleft $ident "~"][string range [maskhost $uhost] [string last "@" [maskhost $uhost]] e]"
  }
  9 {
   set nick [string range $uhost 0 [expr [string first "!" $uhost]-1]]
   set ban "$nick!*[string range [maskhost $uhost] [string last "@" [maskhost $uhost]] e]"
  }
  10 {
   set host [string range $uhost [string last "@" $uhost] e]
   if {[bnick:findip [string range $host 1 e]] == "0"} {
    set host [bnick:replace $host "1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 0 ?"]
    set ident [string range $uhost [expr [string first "!" $uhost]+1] [expr [string last "@" $uhost]-1]]
    set ban "*!$ident$host"
   } {set ban [bnick:masktype $uhost 0]}
  }
  11 {
   set host [string range $uhost [string last "@" $uhost] e]
   if {[bnick:findip [string range $host 1 e]] == "0"} {
    set host [bnick:replace $host "1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 0 ?"]
    set ident [string range $uhost [expr [string first "!" $uhost]+1] [expr [string last "@" $uhost]-1]]
    set ban "*!*[string trimleft $ident "~"]$host"
   } {set ban [bnick:masktype $uhost 1]}
  }
  12 {
   set host [string range $uhost [string last "@" $uhost] e]
   if {[bnick:findip [string range $host 1 e]] == "0"} {
    set host [bnick:replace $host "1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 0 ?"]
    set ban "*!*$host"
   } {set ban [bnick:masktype $uhost 2]}
  }
  13 {
   set host [string range $uhost [string last "@" $uhost] e]
   if {[bnick:findip [string range $host 1 e]] == "0"} {set ban [bnick:masktype $uhost 11]} {set ban [bnick:masktype $uhost 3]}
  }
  14 {
   set host [string range $uhost [string last "@" $uhost] e]
   if {[bnick:findip [string range $host 1 e]] == "0"} {set ban [bnick:masktype $uhost 12]} {set ban [bnick:masktype $uhost 4]}
  }
  15 {
   set host [string range $uhost [string last "@" $uhost] e]
   if {[bnick:findip [string range $host 1 e]] == "0"} {
    set host [bnick:replace $host "1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 0 ?"]
    set rest [string range $uhost 0 [expr [string last "@" $uhost]-1]]
    set ban $rest$host
   } {set ban [bnick:masktype $uhost 5]}
  }
  16 {
   set host [string range $uhost [string last "@" $uhost] e]
   if {[bnick:findip [string range $host 1 e]] == "0"} {
    set host [bnick:replace $host "1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 0 ?"]
    set rest "[string range $uhost 0 [expr [string first "!" $uhost]-1]]!*[string trimleft [string range $uhost [expr [string first "!" $uhost]+1] [expr [string last "@" $uhost]-1]] "~"]"
    set ban $rest$host
   } {set ban [bnick:masktype $uhost 6]}
  }
  17 {
   set host [string range $uhost [string last "@" $uhost] e]
   if {[bnick:findip [string range $host 1 e]] == "0"} {
    set host [bnick:replace $host "1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 0 ?"]
    set rest "[string range $uhost 0 [expr [string first "!" $uhost]-1]]!*"
    set ban $rest$host 
   } {set ban [bnick:masktype $uhost 7]}
  }
  18 {
   set host [string range $uhost [string last "@" $uhost] e]
   if {[bnick:findip [string range $host 1 e]] == "0"} {set ban [bnick:masktype $uhost 16]} {set ban [bnick:masktype $uhost 8]}
  }
  19 {
   set host [string range $uhost [string last "@" $uhost] e]
   if {[bnick:findip [string range $host 1 e]] == "0"} {set ban [bnick:masktype $uhost 17]} {set ban [bnick:masktype $uhost 9]}
  }
  return_nothing {set ban ""}
  default {set ban "*!*[string range $uhost [string first "@" $uhost] e]"}
 }
 set _nick [lindex [split $ban !] 0]
 set _ident [string range $ban [expr [string first ! $ban]+1] [expr [string last @ $ban]-1]]
 set _host [string range $ban [expr [string last @ $ban]+1] e]
 if {$_ident != [set temp [string range $_ident [expr [string length $_ident]-9] e]]} {
  set _ident *[string trimleft $temp *]
 }
 if {$_host != [set temp [string range $_host [expr [string length $_host]-63] e]]} {
  set _host *[string trimleft $temp *]
 } ; return $_nick!$_ident@$_host
}

proc bnick:findip {args} {
 catch {unset bnick_found_ip}
 if {![string match *.*.*.* $args]} {return 0}
 foreach arg $args {
  if {[string match *.*.*.* $arg]} {
   set bnick_testa [split $arg "."] ; set i 0
   while {[llength $bnick_testa] != $i} {
    set bnick_test [lrange $bnick_testa $i end]
    if {[string length [lindex $bnick_test 1]]<4 && [string length [lindex $bnick_test 2]]<4} {
     if {[lindex $bnick_test 1] < 256 && [lindex $bnick_test 2] < 256 && [lindex $bnick_test 1] >= 0 && [lindex $bnick_test 2] >= 0} {
      set first "abcdefghi"
      if {[string index [lindex $bnick_test 0] [expr [string length [lindex $bnick_test 0]] - 1]] <= 9 && [string index [lindex $bnick_test 0] [expr [string length [lindex $bnick_test 0]] - 1]] >= 0} {
       set first [string range [lindex $bnick_test 0] [expr [string length [lindex $bnick_test 0]] - 1] end]
       if {[string index [lindex $bnick_test 0] [expr [string length [lindex $bnick_test 0]] - 2]] <= 9 && [string index [lindex $bnick_test 0] [expr [string length [lindex $bnick_test 0]] - 2]] >= 0} {
        set first [string range [lindex $bnick_test 0] [expr [string length [lindex $bnick_test 0]] - 2] end]
        if {[string index [lindex $bnick_test 0] [expr [string length [lindex $bnick_test 0]] - 3]] <= 9 && [string index [lindex $bnick_test 0] [expr [string length [lindex $bnick_test 0]] - 3]] >= 0} {
         set first [string range [lindex $bnick_test 0] [expr [string length [lindex $bnick_test 0]] - 3] end]
        }
       }
      }
      set second [lindex $bnick_test 1] ; set third [lindex $bnick_test 2] ; set fourth "abcdefghi"
      if {[string index [lindex $bnick_test 3] 0] <= 9 && [string index [lindex $bnick_test 3] 0] >= 0} {
       set fourth [string index [lindex $bnick_test 3] 0]
       if {[string index [lindex $bnick_test 3] 1] <= 9 && [string index [lindex $bnick_test 3] 1] >= 0} {
        set fourth $fourth[string index [lindex $bnick_test 3] 1]
        if {[string index [lindex $bnick_test 3] 2] <= 9 && [string index [lindex $bnick_test 3] 2] >= 0} {
         set fourth $fourth[string index [lindex $bnick_test 3] 2]
        }
       }
      }
      if {($first < 256) && ($second < 256) && ($third < 256) &&
          ($fourth < 256) && ($first > 0) && ($second > 0) &&
          ($third > 0) && ($fourth > 0) && ([string index $first 0] > 0) &&
          ([string index $second 0] > 0) && ([string index $third 0] > 0) &&
          ([string index $fourth 0] > 0)} {
       if {[info exists bnick_found_ip]} {
        set bnick_found_ip "$bnick_found_ip $first.$second.$third.$fourth"
       } {set bnick_found_ip $first.$second.$third.$fourth}
      }
     }
    } ; incr i +1
   }
  }
 } ; if {[info exists bnick_found_ip]} {return $bnick_found_ip} {return 0}
}

putlog "Bad nick control v3.0 by \002Prince_of_the_net\002 \[Loaded\]"
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

set bnick {
"******"
[snip]
a snigle "*" will match any word or nick in your case, it will even match a paragraph, if you want to match only 1 letter then use "?" so instead of ****** use ??????
f
forever79
Voice
Posts: 18
Joined: Sat Jun 21, 2003 6:12 pm

**** <== is f.u.c.k , this form not show it

Post by forever79 »

**** <== is f.u.c.k , this form not show it

i try to this code

Code: Select all

set bnick { 
  "*rape*" 
  "*fuk*" 
} 
but my bot is kickban to all users
b
bLEIFus
Voice
Posts: 6
Joined: Sat Jul 03, 2004 6:21 am

Post by bLEIFus »

Hmmm, i know, this is an old topic, but i have the same problem with this script. it kicks+bans all users joining my chan. Is there a solution for it?
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Try this and see if it fixes anything:

Code: Select all

set bnick { 
  *rape* 
  *fuk* 
}
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

from what I can see he does not use string match as matching but regexp....
Elen sila lúmenn' omentielvo
b
bLEIFus
Voice
Posts: 6
Joined: Sat Jul 03, 2004 6:21 am

Post by bLEIFus »

Alchera wrote:Try this and see if it fixes anything:

Code: Select all

set bnick { 
  *rape* 
  *fuk* 
}
Hmmm this does not fix the problem :cry:
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

From what I see there are alot of useless things in that script, for a simple one use this, like I do:

Code: Select all

#Set the 'bad nicks' to kick/ban out of the channel.
set badnicks { "nick1" "nick2" "nick3" }

#Set the channels to activate this script on.
set badnickchans "#mychan1 #mychan2"

#Set the bantime.
set badnickbantime "60"


##### SCRIPT #####
bind join - "*" bad:nick

proc bad:nick {nick host hand chan} {
 global badnicks badnickchans badnickbantime
  if {([lsearch -exact [string tolower $badnickchans] [string tolower $chan]] != -1) && (![isbotnick $nick])} {
   foreach badnick $badnicks {
    if {([string match -nocase *$badnick* $nick])} {
      if {([botisop $chan]) && (![isop $nick $chan]) && (![isvoice $nick $chan]) && (![matchattr $hand mn|mn $chan])} {
        set badnickban1 "*$badnick*!*@*"; set badnickban2 "*!*@[lindex [split $host @] 1]"
        set ban "MODE $chan +bb $badnickban1 $badnickban2\n"
        set kick "KICK $chan $nick :0,1 Bad Nick Kick 2,0 - Unacceptable user nick *$badnick* 2detected. Please change your 2'nick' 12to a suitable one and then 2rejoin back.2\n"
        putdccraw 0 [string length $ban] $ban; putdccraw 0 [string length $kick] $kick
        timer $badnickbamtime "pushmode $chan -b $badnickban2"
        }
      }
    }
  }
}
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
b
bLEIFus
Voice
Posts: 6
Joined: Sat Jul 03, 2004 6:21 am

Post by bLEIFus »

Thank you awyeah, n1ce script, works as wanted. It would be nice feature if this script warns first ( kick ) and then bans. Maybe with a adjustable number of warnings. Thats what i like in the other "non-proper-working" script........
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Since this is an on-join check I doubt you will need this "(![isop $nick $chan]) && (![isvoice $nick $chan])" and
timer $badnickbamtime "pushmode $chan -b $badnickban2"
should be a
  • ? :P

    Lil tip:
    Instead of "global badnicks badnickchans badnickbantime" make your variables like: bad(nicks) and bad(chans) and just call global bad. :)

    Id go for an string match rather than an lsearch. haven't tested wich one is faster.

    ps: rejoin back? :o

    edit:
    here are my *time* tests on lsearch with "string tolower" and the string match
    % time {set t "foo moo bar" ; set s "mOo" ; lsearch -exact [string tolower $t] [string tolower $s]}
    76 microseconds per iteration
    % time {set t "foo moo bar" ; set s "mOo" ; lsearch -exact [string tolower $t] [string tolower $s]}
    60 microseconds per iteration
    % time {set t "foo moo bar" ; set s "mOo" ; lsearch -exact [string tolower $t] [string tolower $s]}
    62 microseconds per iteration

    % time {set t "foo moo bar" ; set s "mOo" ; string match -nocase $t $s}
    23 microseconds per iteration
    % time {set t "foo moo bar" ; set s "mOo" ; string match -nocase $t $s}
    41 microseconds per iteration
    % time {set t "foo moo bar" ; set s "mOo" ; string match -nocase $t $s}
    36 microseconds per iteration
    ps: dosen't lsearch have a -nocase thing like string match has? umm..
Once the game is over, the king and the pawn go back in the same box.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

caesar:

The way I used the timer that also works. If you have more "'s just add an extra \ infront of them they work perfectly. I didn't use list because I am not calling to another proc neither passing variables or so.

Yeah isop and isvoice are redundant, but if we make another proc to delay the main proc with a utimer 1-2 secs then it would be handy as ChanServ gives some delay in milliseconds to op the person after he joins the channel.

The warning thing would require a bit more of coding, but I think it's useless. People already know channel rules and if they don't they can read the kick message change their nick and come back in after they are kicked. We don't need to stress the bot make it send warnings and stuff.

It could be something like this then:

Code: Select all

#Set the 'bad nicks' to kick/ban out of the channel.
set badnicks { "nick1" "nick2" "nick3" }

#Set the channels to activate this script on.
set badnickchans "#mychan1 #mychan2"

#Set the bantime.
set badnickbantime "60"


##### SCRIPT #####
bind join - "*" bad:nick:delay

proc bad:nick:delay {nick host hand chan} {
 utimer 2 [list bad:nick $nick $host $hand $chan]
}

proc bad:nick {nick host hand chan} {
 global badnicks badnickchans badnickbantime
  if {([lsearch -exact [string tolower $badnickchans] [string tolower $chan]] != -1) && (![isbotnick $nick])} {
   foreach badnick $badnicks {
    if {([string match -nocase *$badnick* $nick])} {
      if {([botisop $chan]) && (![isop $nick $chan]) && (![isvoice $nick $chan]) && (![matchattr $hand mn|mn $chan])} {
        set badnickban1 "*$badnick*!*@*"; set badnickban2 "*!*@[lindex [split $host @] 1]"
        set ban "MODE $chan +bb $badnickban1 $badnickban2\n"
        set kick "KICK $chan $nick :0,1 Bad Nick Kick 2,0 - Unacceptable user nick *$badnick* 2detected. Please change your 2'nick' 12to a suitable one and then 2rejoin back.2\n"
        putdccraw 0 [string length $ban] $ban; putdccraw 0 [string length $kick] $kick
        timer $badnickbamtime "pushmode $chan -b $badnickban2"
        return 0
        }
      }
    }
  }
}
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Locked