|
Joined: Dec 2002
Posts: 18
Pikka bird
|
OP
Pikka bird
Joined: Dec 2002
Posts: 18 |
Hi,
I am still trying to get this working. It should count how often a user violates the rule, message him at the first violation, ban-msg at the second and ban-kick at the third. The problem with it is that at the first violation the user gets the warning message _and_ the ban. I want to make it that he gets only a message at the first violation and action is taken only at the second or third one.
on @*:TEXT:*:#mytest: { if ($len($1-) < 5) || ($nick isop #) return var %text = $strip($remove($1-,$chr(32))) var %non.caps = $len($removecs(%text,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)) ; %non.caps counts number of non-caps - note how it uses $removeCS (Case SenSiTiVE) var %full.line = $len($strip($remove(%text,$chr(32)))) ; %full.line counts total length of line (with spaces removed) var %percent = $calc(1 - (%non.caps / %full.line)) ;This %percent is set to how much of the text is actually caps. if (%percent >= 0.6) { ;This if statement checks the percent of text that is caps, set -u60 %rl. [ $+ [ $address($nick,2) ] ] $calc( %rl. [ $+ [ $address($nick,2) ] ] + 1) ;the -u60 makes the variable unset after 30s without being used-for testing its 60 s if (%rl. [ $+ [ $address($nick,2) ] ] == 1) msg $chan $nick Text contained $calc(%percent * 100) percent caps. 1. Warning if (%rl. [ $+ [ $address($nick,2) ] ] == 2) ban -u30 # $nick 11 msg $chan $nick Text containedt $calc(%percent * 100) percent caps. Ban for 30 secs, last warning if (%rl. [ $+ [ $address($nick,2) ] ] == 3) { ban -u30 # $nick 11 msg $chan $nick Text contained $calc(%percent * 100) percent caps. That's it. kick # $nick You were warned. } }
Any ideas? Thanks, Gwion
|
|
|
|
Joined: Feb 2003
Posts: 15
Pikka bird
|
Pikka bird
Joined: Feb 2003
Posts: 15 |
|
|
|
|
Joined: Dec 2002
Posts: 169
Vogon poet
|
Vogon poet
Joined: Dec 2002
Posts: 169 |
Try putting {}'s around your IF statement's commands. on @*:TEXT:*:#mirc: {
if ($len($1-) < 5) || (null isop #) return
var %text = $strip($remove($1-,$chr(32)))
var %non.caps = $len($removecs(%text,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))
; %non.caps counts number of non-caps - note how it uses $removeCS (Case SenSiTiVE)
var %full.line = $len($strip($remove(%text,$chr(32))))
; %full.line counts total length of line (with spaces removed)
var %percent = $calc(1 - (%non.caps / %full.line))
;This %percent is set to how much of the text is actually caps.
if (%percent >= 0.6) {
;This if statement checks the percent of text that is caps,
set -u60 %rl. [ $+ [ $address($nick,2) ] ] $calc( %rl. [ $+ [ $address($nick,2) ] ] + 1)
;the -u60 makes the variable unset after 30s without being used-for testing its 60 s
if (%rl. [ $+ [ $address($nick,2) ] ] == 1) [color:red]{[/color]
msg $chan $nick Text contained $calc(%percent * 100) percent caps. 1. Warning
[color:red]}[/color]
if (%rl. [ $+ [ $address($nick,2) ] ] == 2) [color:red]{[/color]
ban -u30 # $nick 11
msg $chan $nick Text containedt $calc(%percent * 100) percent caps. Ban for 30 secs, last warning
[color:red]}[/color]
if (%rl. [ $+ [ $address($nick,2) ] ] == 3) {
ban -u30 # $nick 11
msg $chan $nick Text contained $calc(%percent * 100) percent caps. That's it.
kick # $nick You were warned.
}
}
} That should fix the problem you are having. I suggest killing the msgs though. You'd get flooded with even a small amount of users repeating in caps. Edit: removed other suggestions
|
|
|
|
Joined: Dec 2002
Posts: 208
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 208 |
eh, agreed .. kill msgs and add { } 's ..
i didnt read all that code, it hurt my eyes .. lol .. but anouther sugestion .. learn $+() and $eval()
those 2 identifers will clean your code up ALOT ..
no need for all that blah [ $+ [ more blah ] ] junk anymore .. eh .. yuck :P
want to set a varable based on other vars or identifers?
set $+(%,fld.,$chan,.,$nick) whatever for example might set %fld.#mIRC.Cobra^ .. MUCH nicer than doing set [ % $+ [ fld. $+ [ $chan ] $+ . $+ [ $nick ] ] ]
want to check the var in an if conditional .. well $+() creats the var as a string, so compliment it with $eval(..,2) like so
if ($eval($+(%,fld.,$chan,.,$nick),2) > 3) { code } .. etc
saves u time, makes code nicer and easier to read, reduces bugs because of [ ] inconsistancies .. i think u get the point.. lol
in the end u can code how u want to .. if u like the [ ] 's more power to ya .. but personaly i'd rather not mess with them if i didnt have to :P ..
Cobra^
|
|
|
|
Joined: Dec 2002
Posts: 18
Pikka bird
|
OP
Pikka bird
Joined: Dec 2002
Posts: 18 |
Hi,
Thanks all, unfortunately the script still doesn' work right. At first offend it now msg 1. Warning and bans. I need the messages too, can't skip that.
Any more ideas? I bet it's just a tiny problem somewhere maybe I made a simple mistake .. *sigh*
Anyway, thanks for your help, Gwion
|
|
|
|
Joined: Dec 2002
Posts: 169
Vogon poet
|
Vogon poet
Joined: Dec 2002
Posts: 169 |
Did you cut and paste the revised code from above? It worked for me. On first offense it sent a message. On second offense it bans for 30 seconds and sends the 2nd message. On third offense it bans, kicks, and sends a message.
|
|
|
|
|