|
Joined: Oct 2005
Posts: 98
Babel fish
|
OP
Babel fish
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.
|
|
|
|
Joined: Nov 2003
Posts: 227
Fjord artisan
|
Fjord artisan
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#capsI'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.
|
|
|
|
Joined: Oct 2005
Posts: 98
Babel fish
|
OP
Babel fish
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.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
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
|
|
|
|
Joined: Oct 2005
Posts: 98
Babel fish
|
OP
Babel fish
Joined: Oct 2005
Posts: 98 |
Okay, I found this one:
On @*:TEXT:*:#testchan: {
var %t = $remove($1-,$chr(32)), %percent = 50
if ($nick !isop #) && ($calc($regex($1-,/[A-Z]/g) / $len(%t) * 100) >= %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.
|
|
|
|
Joined: Mar 2005
Posts: 212
Fjord artisan
|
Fjord artisan
Joined: Mar 2005
Posts: 212 |
this is the same code i just changed the braces a little
On @*:TEXT:*:#testchan: {
var %t = $remove($1-,$chr(32)), %percent = 50
if ($nick !isop #) && ($calc($regex($1-,/[A-Z]/g) / $len(%t) * 100) >= %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
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
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.
on *:text:*:#:{
var %text = $1-
var %count = $len(%text)
var %onlyletters = $len(%text)
var %i = 1, %place, %upper, %lower
while (%i <= %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 > 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.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
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
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
on @*:text:*:#:{
set %cpschan $chan
if (%op == off) && ($nick isop $chan) { return }
if (%voice == off) && ($nick isvo $chan) { return }
else {
var %p = $int($calc(($regex($1-,/[A-ZÄÖ]/g) / $len($1-)) * 100))
if (%p > 75) && (!$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 > 75) && ($len(%matchtxt) > 5) && ($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.
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
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), $&
%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) > %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.
|
|
|
|
Joined: Oct 2005
Posts: 98
Babel fish
|
OP
Babel fish
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.
|
|
|
|
|