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.

Channel Protection v1.1 Script

Old posts that have not been replied to for several years.
Locked
User avatar
blood_x
Halfop
Posts: 77
Joined: Tue Nov 20, 2001 8:00 pm
Location: KL, Malaysia
Contact:

Channel Protection v1.1 Script

Post by blood_x »

Currently, I used Channel Protection v1.1 written by Daniel Skovli and can be found in tcl archive. This TCL script protect channel from bold, underline, color, public notice and caps lock. When, I do botnet link, and run this script into both eggdrop (bot A and bot B), this TCL script kick among them. Eg. when bot A using BOLD character in #mychannel, bot B kick bot A (reason: No Bold Allowed In #mychannel). In other word, this TCL script can't protect other bot from doing such things or there's NO exemptions flag for bot in this TCL script.

How to add an exemption flags for bot (+b) in this TCL script?
Thank you for your support and commitments.

Sincerely,
fzAy®
http://www.iNTRACyber.com
(We Chat, We Share & We Learn)
User avatar
blood_x
Halfop
Posts: 77
Joined: Tue Nov 20, 2001 8:00 pm
Location: KL, Malaysia
Contact:

Post by blood_x »

The TCL script as below;

#binds:
bind notc - * ban_notice
bind pubm - * check_pubm
bind ctcp - ACTION check_ctcp

#redefining some old, and setting some new global vars:
set chanpro(remember) [expr $chanpro(remember) * 60] ;#returns minutes..
set chanpro(chans) [string tolower $chanpro(chans)] ;#makes sure the user did not get all CrEAtiVE on me :P~
set caps_count(none:none) 0
set bold_count(none:none) 0
set color_count(none:none) 0
set underline_count(none:none) 0
set annoy_count(none:none) 0


# The proc's:

#CHECK_CTCP
proc check_ctcp {nick uhost hand dest keyword args} {

#load some global variables
global chanpro botnick

#set some variables
set this_botnick [string tolower $botnick]
set chan [string tolower $dest]
set enabled [lsearch -exact $chanpro(chans) $chan]
set nick [string tolower $nick]
set uhost [string tolower $uhost]

#check if the chan enabled, else return..
if {$enabled == -1} {return 0}

#check if the bot is OPed, else return..
if {![botisop $chan]} {return 0}

#check if the bot is actually typing the word himself, if so - return..
if {$nick == $this_botnick} {return 0}

#check the args for colors, bold, underline and CAPS
if {[string match *\003* $args]} {kick_color $nick $uhost $hand $chan $args} \
elseif {[string match *\002* $args]} {check_bold $nick $uhost $hand $chan $args} \
elseif {[string match *\037* $args]} {check_underline $nick $uhost $hand $chan $args} \
else {check_caps $nick $uhost $hand $chan $args; check_annoy $nick $uhost $hand $chan $args}

} ;#end proc


#CHECK_PUBM
proc check_pubm {nick uhost hand chan args} {

#load some global variables
global chanpro botnick

#set some variables
set this_botnick [string tolower $botnick]
set chan [string tolower $chan]
set enabled [lsearch -exact $chanpro(chans) $chan]
set nick [string tolower $nick]
set uhost [string tolower $uhost]

#check if the chan enabled, else return..
if {$enabled == -1} {return 0}

#check if the bot is OPed, else return..
if {![botisop $chan]} {return 0}

#check if the bot is actually typing the word himself, if so - return..
if {$nick == $this_botnick} {return 0}

#check the args for colors, bold, underline and CAPS
if {[string match *\003* $args]} {kick_color $nick $uhost $hand $chan $args} \
elseif {[string match *\002* $args]} {check_bold $nick $uhost $hand $chan $args} \
elseif {[string match *\037* $args]} {check_underline $nick $uhost $hand $chan $args} \
else {check_caps $nick $uhost $hand $chan $args; check_annoy $nick $uhost $hand $chan $args;}

} ;#end proc


#BAN_NOTICE
proc ban_notice {nick uhost hand args dest} {

#load some global variables
global chanpro botnick

#set some variables
set chan [string tolower $dest]
set enabled [lsearch -exact $chanpro(chans) $chan]

#check if the channel if enabled, else return
if {$enabled == -1} {return 0}

#set the botnick variable - tolower
set this_botnick [string tolower $botnick]

#checks if the notice check is disabled..
if {$chanpro(notice) == 0} {return 0}

#Prevent error msg if the notice is to the bot.. (error msg's sux :P)
if {$this_botnick == $chan} {return 0}

#checks if the user is an op, if so check if protect_ops is enabled
if {([matchattr $hand o|o $chan]) || ([isop $nick $chan])} {
putserv "[subst $chanpro(op_method)] :[subst $chanpro(op_notice)]"
return 0
} else {
set bmask [maskhost [getchanhost $nick $chan]]
set bmask [format "*!*%s" [string range $bmask 2 [string length $bmask]]]
newchanban $chan $bmask $botnick [subst $chanpro(ban_notice)] $chanpro(ban_time_notice)
putserv "KICK $chan $nick :[subst $chanpro(ban_notice)]"
}

} ;# end proc



##CHECK_CAPS
proc check_caps {nick uhost hand chan args} {

#load some global variables
global chanpro caps_count botnick

#check if CAPS-check is disabled, if so - return
if {$chanpro(caps) == 0} {return 0}

#check if the string can match URL's, if so - return..
if {[string match *http://* $args] || [string match *www.* $args]} {return 0}


#splits the argument.
set chars [split $args ""]
set caps 0 ; set total_string 0

#check each char with a loop
foreach char $chars {
if {![regexp ^\\+?\[a-zA-ZæøåÆØÅ\]+\$ $char]} {continue} \
elseif {[string toupper $char] == "$char"} {incr caps}
incr total_string
}

#checks the amount of CAPS in percent
if {($caps == 0) || $total_string == 0} {return 0}
set num [expr $caps.0 / $total_string * 100]

#checks if the percentage CAPS use is above the limit and if the string is long enough to be counted
if {($num >= $chanpro(caps_percent)) && ($total_string >= $chanpro(caps_length))} {

##now, proceed to the actual actions the bot will take

#If the dude is an op, check for protect_ops and give warning if so. if not enabled, treat him as a regular user
if {([matchattr $hand o|o $chan]) || ([isop $nick $chan])} {
if {$chanpro(protect_ops) == 1} {
putserv "[subst $chanpro(op_method)] :[subst $chanpro(op_caps)]"
return 0
}
}

#create a timer for the violation, kick/ban..
if {![info exists caps_count($uhost:$chan)]} {
set caps_count($uhost:$chan) 0
}
incr caps_count($uhost:$chan)
timer $chanpro(remember) {unset caps_count($uhost:$chan); putlog "removed timer for $uhost in $chan"}
if {$caps_count($uhost:$chan) == 1} {putserv "KICK $chan $nick :[subst $chanpro(kick_caps)]"}
if {$caps_count($uhost:$chan) == 2} {
set bmask [maskhost [getchanhost $nick $chan]]
set bmask [format "*!*%s" [string range $bmask 2 [string length $bmask]]]
newchanban $chan $bmask $botnick [subst $chanpro(ban_caps)] $chanpro(ban_time_caps)
putserv "KICK $chan $nick :[subst $chanpro(ban_caps)]"
set caps_count($uhost:$chan) 1
}
}

} ;#end proc



#KICK_COLOR
proc kick_color {nick uhost hand chan args} {

#load some global variables
global chanpro color_count botnick

#check if color-check is disabled, if so - return
if {$chanpro(color) == 0} {return 0}

##now, proceed to the actual actions the bot will take

#If the dude is an op, check for protect_ops and give warning if so. if not enabled, treat him as a regular user
if {([matchattr $hand o|o $chan]) || ([isop $nick $chan])} {
if {$chanpro(protect_ops) == 1} {
putserv "[subst $chanpro(op_method)] :[subst $chanpro(op_color)]"
return 1
}
}

#create a timer for the violation, kick/ban..
if {![info exists color_count($uhost:$chan)]} {
set color_count($uhost:$chan) 0
}
incr color_count($uhost:$chan)
timer $chanpro(remember) {unset color_count($uhost:$chan); putlog "removed timer for $uhost in $chan"}
if {$color_count($uhost:$chan) == 1} {putserv "KICK $chan $nick :[subst $chanpro(kick_color)]"}
if {$color_count($uhost:$chan) == 2} {
set bmask [maskhost [getchanhost $nick $chan]]
set bmask [format "*!*%s" [string range $bmask 2 [string length $bmask]]]
newchanban $chan $bmask $botnick [subst $chanpro(ban_color)] $chanpro(ban_time_color)
putserv "KICK $chan $nick :[subst $chanpro(ban_color)]"
set color_count($uhost:$chan) 1
}

} ;#end proc


#CHECK_BOLD
proc check_bold {nick uhost hand chan args} {

#load some global variables
global chanpro bold_count botnick

#check if bold-check is disabled, if so - return
if {$chanpro(bold) == 0} {return 0}

##now, proceed to the actual actions the bot will take

#If the dude is an op, check for protect_ops and give warning if so. if not enabled, treat him as a regular user
if {([matchattr $hand o|o $chan]) || ([isop $nick $chan])} {
if {$chanpro(protect_ops) == 1} {
putserv "[subst $chanpro(op_method)] :[subst $chanpro(op_bold)]"
return 1
}
}

#create a timer for the violation, kick/ban..
if {![info exists bold_count($uhost:$chan)]} {
set bold_count($uhost:$chan) 0
}
incr bold_count($uhost:$chan)
timer $chanpro(remember) {unset bold_count($uhost:$chan); putlog "removed timer for $uhost in $chan"}
if {$bold_count($uhost:$chan) == 1} {putserv "[subst $chanpro(warning_method)] :[subst $chanpro(warn_bold)]"}
if {$bold_count($uhost:$chan) == 2} {putserv "KICK $chan $nick :[subst $chanpro(kick_bold)]"}
if {$bold_count($uhost:$chan) == 3} {
set bmask [maskhost [getchanhost $nick $chan]]
set bmask [format "*!*%s" [string range $bmask 2 [string length $bmask]]]
newchanban $chan $bmask $botnick [subst $chanpro(ban_bold)] $chanpro(ban_time_bold)
putserv "KICK $chan $nick :[subst $chanpro(ban_bold)]"
set bold_count($uhost:$chan) 2
}

} ;#end proc


#CHECK_UNDERLINE
proc check_underline {nick uhost hand chan args} {

#load some global variables
global chanpro underline_count botnick

#check if bold-check is disabled, if so - return
if {$chanpro(underline) == 0} {return 0}

##now, proceed to the actual actions the bot will take

#If the dude is an op, check for protect_ops and give warning if so. if not enabled, treat him as a regular user
if {([matchattr $hand o|o $chan]) || ([isop $nick $chan])} {
if {$chanpro(protect_ops) == 1} {
putserv "[subst $chanpro(op_method)] :[subst $chanpro(op_underline)]"
return 1
}
}

#create a timer for the violation, kick/ban..
if {![info exists underline_count($uhost:$chan)]} {
set underline_count($uhost:$chan) 0
}
incr underline_count($uhost:$chan)
timer $chanpro(remember) {unset underline_count($uhost:$chan); putlog "removed timer for $uhost in $chan"}
if {$underline_count($uhost:$chan) == 1} {putserv "[subst $chanpro(warning_method)] :[subst $chanpro(warn_underline)]"}
if {$underline_count($uhost:$chan) == 2} {putserv "KICK $chan $nick :[subst $chanpro(kick_underline)]"}
if {$underline_count($uhost:$chan) == 3} {
set bmask [maskhost [getchanhost $nick $chan]]
set bmask [format "*!*%s" [string range $bmask 2 [string length $bmask]]]
newchanban $chan $bmask $botnick [subst $chanpro(ban_underline)] $chanpro(ban_time_underline)
putserv "KICK $chan $nick :[subst $chanpro(ban_underline)]"
set underline_count($uhost:$chan) 2
}

} ;#end proc


##CHECK_ANNOY
proc check_annoy {nick uhost hand chan args} {

#load some global variables
global chanpro annoy_count botnick

#set the annoy variable
set annoy 0

#check if annoy-check is disabled, if so - return
if {$chanpro(annoy) == 0} {return 0}

#check each char with a loop
foreach word [split $args] {
foreach letter [split $word ""] {
if {($letter == "?") || ($letter == "!") || ($letter == "@") || ($letter == "~") || ($letter == "%") || ($letter == "#")} {incr annoy}
}

#checks if the length of the annoy is huge enough
if {$annoy >= $chanpro(annoy_length)} {continue} else {set annoy 0}
}

#check if the annoy was big enough
if {!($annoy >= $chanpro(annoy_length))} {return 0}

##now, proceed to the actual actions the bot will take

#If the dude is an op, check for protect_ops and give warning if so. if not enabled, treat him as a regular user
if {([matchattr $hand o|o $chan]) || ([isop $nick $chan])} {
if {$chanpro(protect_ops) == 1} {
putserv "[subst $chanpro(op_method)] :[subst $chanpro(op_annoy)]"
return 1
}
}

#create a timer for the violation, kick/ban..
if {![info exists annoy_count($uhost:$chan)]} {
set annoy_count($uhost:$chan) 0
}
incr annoy_count($uhost:$chan)
timer $chanpro(remember) {unset annoy_count($uhost:$chan); putlog "removed timer for $uhost in $chan"}
if {$annoy_count($uhost:$chan) == 1} {putserv "[subst $chanpro(warning_method)] :[subst $chanpro(warn_annoy)]"}
if {$annoy_count($uhost:$chan) == 2} {putserv "KICK $chan $nick :[subst $chanpro(kick_annoy)]"}
if {$annoy_count($uhost:$chan) == 3} {
set bmask [maskhost [getchanhost $nick $chan]]
set bmask [format "*!*%s" [string range $bmask 2 [string length $bmask]]]
newchanban $chan $bmask $botnick [subst $chanpro(ban_annoy)] $chanpro(ban_time_annoy)
putserv "KICK $chan $nick :[subst $chanpro(ban_annoy)]"
set annoy_count($uhost:$chan) 2
}

} ;#end proc

It is necessary to add exemptions kick/ban for other bot (+b|-). Can someone guide me..

Thanks. :wink:
Thank you for your support and commitments.

Sincerely,
fzAy®
http://www.iNTRACyber.com
(We Chat, We Share & We Learn)
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

just add this line of code under each of the procs.... those that check bold/color ... etc that is :)

Code: Select all

if {[matchattr $hand +b]} { return 0 }
Elen sila lúmenn' omentielvo
User avatar
blood_x
Halfop
Posts: 77
Joined: Tue Nov 20, 2001 8:00 pm
Location: KL, Malaysia
Contact:

Post by blood_x »

Papillon wrote:just add this line of code under each of the procs.... those that check bold/color ... etc that is :)

Code: Select all

if {[matchattr $hand +b]} { return 0 }
By this time, its work! Hehe, wat a simple solution.. Why lah I can't get that idea.. :oops: Anyway, thanks papillon..

Regards.
Thank you for your support and commitments.

Sincerely,
fzAy®
http://www.iNTRACyber.com
(We Chat, We Share & We Learn)
Locked