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.

help please anti caps for arfer

Help for those learning Tcl or writing their own scripts.
Post Reply
S
Sedition
Voice
Posts: 17
Joined: Wed Dec 14, 2011 10:04 pm
Location: Bolivia, Beni, Trinidad / DALnet

help please anti caps for arfer

Post by Sedition »

# web http://forum.egghelp.org/viewtopic.php?t=17178
## updates anti caps for arfer my bros ;) ##
## random phrases was added to the kick method.
## It was added that recognize nicknames and channels random phrases (%chan %nick)
## my email urquizoandrade@hotmail.com /server irc.dal.net #tcls and #lapaz

set nocapsauth "arfer"
set nocapsversion "v1.0.5"

# set bot user flags to ignore text
set vCapsFlagsAllow fo

# set text length (excluding spaces) to allow without checking
set vCapsLengthAllow 3

# set maximum percentage caps allowed (calculation excludes spaces in text)
# greater than 0, less than or equal to 100
set vCapsPercentAllow 90

# set number of warnings before punishing
# integer value equal to or greater than 1
set vCapsWarnings 2

# set here the mode of punishment - metodo de kick
# 1 == kick only (after warnings)
# 2 == kickban (after warnings)
set vCapsPunishMode 1

# time in minutes within which a warning remains valid
# even after the user is punished, passed offences remain valid for this time period
# hence a user could be punished twice for two consecutive offences
set vCapsSinTime 4

# if punishment mode 2, set here the time in minutes the ban lasts
set vCapsBanTime 10

### random phrases ##

set nocapspb {
"%nick Please lower your capital letters, uppercase means shouting in %c."
"Please Disables capitalization Thanks, %nick it's like you scream in %c."
"Do not use capitalization, %nick it's like you shout in %c, Please avoid using them."
}

proc ctcp_capslock {nick uhost hand chan keyword arg} {
pCapsDetect $nick $uhost $hand $chan $arg
}

bind PUBM - * pCapsDetect
bind ctcp - ACTION ctcp_capslock

proc pCapsDetect {nick uhost hand chan text} {
global vCapsBanTime vCapsFlagsAllow vCapsLengthAllow vCapsPercentAllow nocapspb
global vCapsPunishMode vCapsSinBin vCapsSinTime vCapsWarnings
if {[botisop $chan]} {
if {![matchattr [nick2hand $nick] $vCapsFlagsAllow $chan]} {
set caps [regexp -all -- {[A-Z]} $text]
set total [string length [regsub -all -- {[\s]} $text {}]]
if {$total > $vCapsLengthAllow} {
set percent [expr {$caps * 100.0 / $total}]
if {$percent > $vCapsPercentAllow} {
set now [unixtime]
set max [expr {$now - ($vCapsSinTime * 60)}]
lappend vCapsSinBin(${nick},$chan) $now
foreach sin $vCapsSinBin(${nick},$chan) {
if {$sin >= $max} {lappend newlist $sin}
}
set vCapsSinBin(${nick},$chan) $newlist
if {[llength $vCapsSinBin(${nick},$chan)]> $vCapsWarnings} {
switch -- $vCapsPunishMode {
1 {}
2 {
pushmode $chan +b $uhost
timer $vCapsBanTime [list pushmode $chan -b $uhost]
}
default {return 0}
}
putkick $chan $nick "no caps please autoban for $vCapsBanTime min. excess caps, in ($vCapsPercentAllow%)"
putserv "MODE $chan +b $uhost" -next
timer $vCapsBanTime [list pushmode $chan -b $uhost]
} else {
set drem [lindex $nocapspb [rand [llength $nocapspb]]]
set output "*** 12[llength $vCapsSinBin(${nick},$chan)] 4Notice *** 14ò.Ó 14$drem"
regsub -all -- {%c} $output $chan output
putserv "PRIVMSG $chan :[regsub -all -- {%nick} $output $nick]"
}
}
}
}
}
return 0
}

putlog "anticaps $nocapsversion by $nocapsauth has been loaded successfully"
good I wait for all that he learns more on tcl thanks for shaping a solid group of help
Post Reply