but note that it does not recognize variants such as
HELLO PEDRO, how are you DOING
or
greetings TO ALL HELLO if
or
hi TO ALL people
·····················
the tcl only recognizes that:
HELLO
it is possible to extend the tcl so that it recognizes these variants
Code: Select all
# caps.tcl
# set bot user flags to ignore text
set vCapsFlagsAllow fo
# set text length (excluding spaces) to allow without checking
set vCapsLengthAllow 8
# 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 3
# set here the mode of punishment
# 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 20
# if punishment mode 2, set here the time in minutes the ban lasts
set vCapsBanTime 10
bind PUBM - * pCapsDetect
proc pCapsDetect {nick uhost hand chan text} {
global vCapsBanTime vCapsFlagsAllow vCapsLengthAllow vCapsPercentAllow
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 ${nick}!$uhost
flushmode $chan
timer $vCapsBanTime [list pushmode $chan -b ${nick}!$uhost]
}
default {return 0}
}
putkick $chan $nick "excess caps, you were warned"
} else {
set output "*** [llength $vCapsSinBin(${nick},$chan)] WARNING(S) *** within the last $vCapsSinTime minutes for excess caps"
putserv "PRIVMSG $chan :$nick $output"
}
}
}
}
}
return 0
}
# eof