mIRC Homepage

caps script

Posted By: Mary_juana

caps script - 30/11/05 06:04 PM

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

thanks.
Posted By: genius_at_work

Re: caps script - 30/11/05 06:46 PM

The answer to your question is already in that script. The percent of caps that is included in the message can be used as the condition.
Code:
on *:text:*:#:{
  if (!%caps.floodprotection) {
    inc -u2 %caps.floodprotection
    if ($calc($regex($1-,/[A-Z]/g) / $len($1-) * 100) > [color:green]50[/color]) msg $chan Stop talking in $round($ifmatch,2) $+ % and stuff $nick 
  }
}


The green 50 can be altered to the desired level in percent.

-genius_at_work
Posted By: Mary_juana

Re: caps script - 30/11/05 08:38 PM

That doesn't seem to do what i want it to, it's not very accurate for a start, i tested the exact code i could do 1 cap, and it triggered it off
Posted By: genius_at_work

Re: caps script - 30/11/05 11:11 PM

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.

-genius_at_work
Posted By: Mary_juana

Re: caps script - 01/12/05 01:17 PM

Yeah lovely, that did the job! smile

Just one small query with it though

<nick> THIS IS TALKING IN CAPS
<me> Stop talking in 81.82% caps and stuff nick

i'd regard that as 100% but i know it's taking spaces into account
how would i remove them?
Posted By: FiberOPtics

Re: caps script - 01/12/05 04:36 PM

$caps(<string>)[.property]
Posted By: genius_at_work

Re: caps script - 01/12/05 05:15 PM

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-) &lt;= 5) return
...


Add the red parts to the previous code. The rest is identical.

-genius_at_work
© 2019 mIRC Discussion Forums