Caps Lock

By Spoofing on Dec 20, 2010

Simple Caps Lock kicker :P

on @*:TEXT:*:#: {
  if ($len($1-) > 16) && ($calc(($len($1-) - $len($removecs($1-,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z))) / $len($1-) * 100) > 40) {
    ban -ku60 # $nick 1 huh..
  }
}

Comments

Sign in to comment.
Jethro   -  Dec 21, 2010

Yes, jaytea. I already know the effect existed between $1 and $regml() for /S. If someone uses regex match text section for $regml(1) and then use $2 $3, etc, they're not gonna be stripped but the $regml(1).

Anyway, I do appreciate your taking the time for the humble explanation. I'll take note of that.

 Respond  
jaytea   -  Dec 21, 2010

with the 'S' modifier, all that occurs is mIRC will strip control codes (as $strip() does) before passing the text to the regex engine - a side effect of this is that $regml() will return stripped results and $regml().pos will refer to positions in the stripped string. it does not affect the value of $1- in the event.

since the expression '([A-Z])' only matches a single character that is never part of a control code, the only purpose that including the 'S' modifier serves is that the values of $regml().pos will be modified in a manner that is arguably unfavourable (but that's not relevant here :P). so as it stands, /S doesn't change the behaviour of the given example, but there is the implication that control codes should not be considered, which is why i suggested $strip($1-) in place of $1-.

and yes, the lack of a $len() check looks like it was an unfortunate oversight :P although even without the check it serves as an example of a simple method for calculating the percentage of capital letters in a string - it's just a shame that it isn't documented for the benefit of newcomers to coding.

 Respond  
Jethro   -  Dec 21, 2010

Well, perhaps I was being inept to spoofing's intention to submit something for the sake of satire. And apparently the if ($len($1-) > 16) was later added to supplement a workable script. So if the satire was a result a broken script, so be it then.

 Respond  
Jethro   -  Dec 21, 2010

Yes, jaytea. You're right. $regml(0) should have been used in the first case. Thanks for your referral. As for the /S modifier, it's meant to be used to strip control codes, which works the same as $strip() as far as I'm concerned.

 Respond  
jaytea   -  Dec 21, 2010

in case it wasn't obvious: Spoofing made this as a joke or parody of sorts ;P he realizes $calc($len($1-) - $removecs($1-, A, B, C)) = $countcs(str, A, B, C) when A, B and C are single characters and is just mimicking the thought process of a new user to the language for nostalgic purposes (based on a comment he made earlier).

also Jethro, that regex version is incorrect; you mean to use $regml(0) in place of $regml(1) in the first case, and $1- in place of $regml(1) in the second. also, i'm not sure if you used //S out of habit since it's unnecessary here, but if you actually want to not consider control codes it would follow that you'd want to take $len($strip($1-)) as the length of the text.

 Respond  
xdesoto   -  Dec 20, 2010

I need to learn regex ;/

 Respond  
Jethro   -  Dec 20, 2010

I think the regex version is even shorter and just as effective:

on $@*:text:/([A-Z])/gS:#:{
  $iif($len($1-) > 16 && $calc(($len($1-) - $len($regml(0)))/$len($1-)*100) > 40,ban -ku60 # $nick 1 huh..)
}
 Respond  
Spoofing   -  Dec 20, 2010

added

if ($len($1-) > 16)
 Respond  
Jethro   -  Dec 20, 2010

It ain't workin' all right. I've commented on spoofing's snippets in the past, but he usually keeps quiet 'bout what other people have to say.

 Respond  
Lets_Blow_Up_Hawkee   -  Dec 20, 2010

Doesn't work.

 Respond  
xdesoto   -  Dec 20, 2010

I was about to say it doesn't look right ;/

 Respond  
Jethro   -  Dec 20, 2010

Spoofing, have you tested the snippet before submitting it? It kicks/bans any single capital letter.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.