mIRC Home    About    Download    Register    News    Help

Print Thread
#139512 15/01/06 08:36 PM
Joined: Oct 2005
Posts: 98
S
Babel fish
OP Offline
Babel fish
S
Joined: Oct 2005
Posts: 98
I have searched for a script wich will warn a user if he uses capslock, and if he is doing it again, it should kick him, if he continues it should then kick him and also include a 1minute ban, preferably with a text telling him about it, I hope someone can help me with this, and ofcourse it should not kick OPs.

#139513 15/01/06 08:49 PM
Joined: Nov 2003
Posts: 227
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Nov 2003
Posts: 227
Though quite basic, and not all you asked for
here is a link to something that may help.

http://mirc-undernet.org/helpdesk/documents/protection.php#caps

I'm sure someone with more time will post a complete script to help you out.

But if you have a read over the one above, I'm sure you'll learn a bit from it too.

#139514 15/01/06 08:55 PM
Joined: Oct 2005
Posts: 98
S
Babel fish
OP Offline
Babel fish
S
Joined: Oct 2005
Posts: 98
Thanks for the link, I will have a read, and still hope for someone, to try and help me out with what I described.

#139515 15/01/06 09:27 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
the only way that I can think of to do this would be very very slow. You (your script) has to check each character of each post to see if it has all caps
but testing is going to be very slow, I dont know if there is a regex solution, but I'm guessing no.

as a test you might try
on *:text:*:#:{
var %text = $1-
var %count = $len(%text)
var %i = 1, %place, %prct
while (%i <= %count) {
var %place = $mid(%text,%i,1)
if (%place isalpha) && (%place isupper) {
inc %prct
}
inc %i
}
var %check = $calc((%prct / %count) * 100)
if ( %check > 10) { echo $chan $nick might be talking in all caps }
}
then have someone talk using a mix of letters and numbers as if describing a math problem
or an IP address

#139516 15/01/06 09:35 PM
Joined: Oct 2005
Posts: 98
S
Babel fish
OP Offline
Babel fish
S
Joined: Oct 2005
Posts: 98
Okay, I found this one:
Code:
On @*:TEXT:*:#testchan: {
  var %t = $remove($1-,$chr(32)), %percent = 50
  if ($nick !isop #) &amp;&amp;  ($calc($regex($1-,/[A-Z]/g) / $len(%t) * 100) &gt;= %percent) {
    if ( $hget(bold,$+($chan,.,$cid,.,$nick)) == 2) ban -k # $nick 2 Since you will not listen, its best you leave coz you're too loud in CAPS text.
    elseif ( !$hget(bold,$+($chan,.,$cid,.,$nick)) ) {
      hinc -mu10 bold $+($chan,.,$cid,.,$nick)
      msg $chan Warning, Drop the CAPS Please, $nick $+ .
    }
    else {
      ban -ku15 # $nick 2 You were warned not to type in CAPS - Take a 15 Seconds Ban and decide.
      hinc -m bold $+($chan,.,$cid,.,$nick)
    }
  }
}
 

Wich works, but even if I change the % to 50 it kicks even if only 1 letter is used.

#139517 15/01/06 11:09 PM
Joined: Mar 2005
Posts: 212
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Mar 2005
Posts: 212
this is the same code i just changed the braces a little
Code:
On @*:TEXT:*:#testchan: {
  var %t = $remove($1-,$chr(32)), %percent = 50
  if ($nick !isop #) &amp;&amp;  ($calc($regex($1-,/[A-Z]/g) / $len(%t) * 100) &gt;= %percent) {
    if ( $hget(bold,$+($chan,.,$cid,.,$nick)) == 2) {
      ban -k # $nick 2 Since you will not listen, its best you leave coz you're too loud in CAPS text.
      elseif (!$hget(bold,$+($chan,.,$cid,.,$nick))) {
        hinc -mu10 bold $+($chan,.,$cid,.,$nick)
        msg $chan Warning, Drop the CAPS Please, $nick $+ .
      }    
    }
    else {
      ban -ku15 # $nick 2 You were warned not to type in CAPS - Take a 15 Seconds Ban and decide.
      hinc -m bold $+($chan,.,$cid,.,$nick)    
    }  
  }
}


it worked fine for me
you appreciate that
A = 100%
aA = 50%
so a single capital letter could be enough provided its accompanied by few enough lowercase characters

#139518 15/01/06 11:12 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
well this wont do it on only one letter, but go ahead and test this
It checks if its a letter (not 0-9 or punctuation) and then checks if it is upper case or not
if it is not a letter (it IS 0-9 or punctuation) it decreases a var so that var can be used to get a % of letters that are caps and not include the nonalpha characters.
Code:
on *:text:*:#:{
  var %text = $1-
  var %count = $len(%text)
  var %onlyletters = $len(%text)
  var %i = 1, %place, %upper, %lower
  while (%i &lt;= %count) {
    var %place = $mid(%text,%i,1)
    if (%place isalpha) {
      if (%place isupper) { inc %upper }
    }
    if (%place !isalpha) { dec %onlyletters }
    inc %i
  }
  var %check = $calc((%upper / %onlyletters) * 100)
  if ( %check &gt; 30) { echo $chan $nick might be talking in all caps -= From %count Characters: %upper of %onlyletters Letters are Upper Case =- } 
}

the if ( %check > 30) is what you would need to change to set what you think would be the right value.
but 30% caps seems high to me in Normal conversation.

#139519 15/01/06 11:23 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
Quote:

you appreciate that
A = 100%
aA = 50%
so a single capital letter could be enough provided its accompanied by few enough lowercase characters


Though I have typed at this post, my feeling is scripts are NOT a good replacement for a good Op. With this sort of script and some others that are "protection" you are more likely to have false positive results than being a truely useful script. Your example is a pefect one to illustrate that.

I can't think of how many times I have seen some op banning/kicking people and saying "It wasn't me it was my l33t script".

I'll stop here before I start a full on rant laugh

#139520 16/01/06 05:49 AM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Code:
on @*:text:*:#:{
  set %cpschan $chan
  if (%op == off) &amp;&amp; ($nick isop $chan) { return }
  if (%voice == off) &amp;&amp; ($nick isvo $chan) { return }
  else {
    var %p = $int($calc(($regex($1-,/[A-ZÄÖ]/g) / $len($1-)) * 100))
    if (%p &gt; 75) &amp;&amp; (!$hget($+(warn,$cid,$chan),$nick)) {
      hinc -m $+(warn,$cid,$chan) $nick
      set %inptext $nick $+ : Using CAPS is considered shouting, so turn off your CAPSLOCK.
    }
    elseif (%p &gt; 75) &amp;&amp; ($len(%matchtxt) &gt; 5) &amp;&amp; ($hget($+(warn,$cid,$chan),$nick)) { 
      set %inptext $nick $+ : Using CAPS is considered shouting, so turn off your CAPSLOCK.
      hdel $+(warn,$cid,$chan) $nick 
    }
  }
}

set %op on, then the script will also warn oped persons..
set %voice on, then the script will also warn voiced persons..
_____________ EDIT

If you want the script to 1 warn 2 kick 3 ban, then play a bit with user levels.

set %inptext $nick $+ : Using CAPS is considered shouting, so turn off your CAPSLOCK. | .auser CAPS1 $nick

on @CAPS1:text:*:#:{

and so on..

Last edited by sparta; 16/01/06 05:58 AM.
#139521 16/01/06 11:33 AM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:
alias caps return $calc($regex($1,/[A-Z]/g) / $len($1-) * 100)
alias _caps return $calc($regex($1,/[A-Z]/g) / $len($remove($1,$chr(32))) * 100)
alias __caps {
  var %text
  return $calc($(,,$regsub($1,/[^a-z]/gi,,%text)) $regex(%text,/[A-Z]/g) / $len(%text) * 100)
}
on @*:text:*:#:{
  if ($nick !isreg $chan) return
  var %method = _caps, %percent = 50, %warn = Don't use so many caps $+ $chr(32), $&amp; 
    %kick = You were told not to use so many caps, %ban = This is what happens when people don't listen, %mask = 2
  if ($($+($,%method,$chr(40),$1-,$chr(41)),2) &gt; %percent) {
    hinc -m $+(caps,$cid,$chan) $nick
    var %n = $hget($+(caps,$cid,$chan),$nick)
    if (%n == 1) msg $chan %warn $nick
    elseif (%n == 2) kick $chan $nick %kick
    elseif (%n == 3) {
      ban -ku60 $chan $nick %mask %ban
      hdel $+(caps,$cid,$chan) $nick
    }
  }
}


There are several variables at the top of the on text event you can edit to change how the code works:

%mask - the type of mask to ban in the ban command. Look at /help $mask to see a list.

%method - the method used to determine how many caps are used. This can be caps (returns percentage of capital letters in the string), _caps (returns percentage of capitals in the string, ignores spaces) or __caps (returns percentage of capitrals in the string, ignores everything except letters).

%percent - the percentage of caps allowed. If the percentage of caps in a string is more than this value the user will be warned/kicked/banned.

%warn - warning message.
%kick - kick message.
%ban - ban message.

#139522 16/01/06 01:21 PM
Joined: Oct 2005
Posts: 98
S
Babel fish
OP Offline
Babel fish
S
Joined: Oct 2005
Posts: 98
Im still a big noob to scripting, but I wont back down, and I do read faqs and help files hehe, and I will play around with your suggestions, someone once said "learning by doing!" and that's what I intend to do, once again, I thank you all for taking time to answer here, I might return if I mess things up.


Link Copied to Clipboard