I found this while trolling the search feature on here
Code:
on *:text:*:#:{
if (!%caps.floodprotection) {
inc -u2 %caps.floodprotection
var %caps = $regex($1-,/[A-Z]/g)
if (%caps > 5) { msg $chan Stop talking in $round($calc(%caps / $len($1-) * 100),2) $+ % and stuff $nick }
}
}
Trouble is, if someone writes a decent size sentence that will have 5 caps or more randomly it gets triggered, how would i change it to trigger on say 5 or more caps in a row BLAHBLAH and not blaH blaH blaH blaH blaH
Ok, try this code then. It has a minimum limit for length.
Code:
on *:text:*:#:{
if (%caps.floodprotection) return
if ($len($1-) <= [color:red]5[/color]) return
var %pcnt = $calc($regex($1-,/[A-Z]/g) / $len($1-) * 100)
if (%pcnt <= [color:green]50[/color]) return
set -u2 %caps.floodprotection
msg $chan Stop talking in $round(%pcnt,2) $+ % and stuff $nick
}
RED = ignore text that is less than or equal to 5 characters in length GREEN = ignore text that has less than or equal to 50% uppercase characters.
Which characters do you want to be considered "caps" and "non-caps"? A-Z are uppercase, a-z are lowercase, 1-9!@#$%^&*()etc have no case. You need to decide which ones you want to unclude. The following code considers A-Z vs a-z... all other characters are ignored:
Code:
on *:text:*:#:{
if (%caps.floodprotection) return
[color:red] var %var,%temp = $regsub($1-,/[^A-Za-z]+/g,,%var)
tokenize 32 %var[/color]
if ($len($1-) <= 5) return
...
Add the red parts to the previous code. The rest is identical.