|
Joined: May 2009
Posts: 28
Ameglian cow
|
OP
Ameglian cow
Joined: May 2009
Posts: 28 |
can anyone teach me how to write a script to ban a chatter swearing in op pm?
|
|
|
|
Joined: Nov 2009
Posts: 117
Vogon poet
|
Vogon poet
Joined: Nov 2009
Posts: 117 |
on @$*:TEXT:/\bword1\b|\bword2\b|\bword3\b/iS:#:ban -ku600 # $nick 2 Ten minute kick/ban for language!
on @$*:ACTION:/\bword1\b|\bword2\b|\bword3\b/iS:#:ban -ku600 # $nick 2 Ten minute kick/ban for language!
|
|
|
|
Joined: Jul 2007
Posts: 1,129
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
gooshie, the op meant pm, not the active channel. So the # should have been ? don't you think? on @$*:TEXT:/\bword1\b|\bword2\b|\bword3\b/iS:?:ban -ku600 #YourChannel $nick 2 Ten minute kick/ban for language!
on @$*:ACTION:/\bword1\b|\bword2\b|\bword3\b/iS:?:ban -ku600 #YourChannel $nick 2 Ten minute kick/ban for language! Change #YourChannel to your real channel. This, I believe, can only work on a single channel basis. If you want this to work on all, a while loop needs to be used with $comchan()...as there's no $chan in pm.
|
|
|
|
Joined: May 2009
Posts: 28
Ameglian cow
|
OP
Ameglian cow
Joined: May 2009
Posts: 28 |
is there anything i should change in this addons?
on *:text:*:?:{ if ($me isop #) { var %f = $strip($1-) if (*bitch* iswm %f) || (* bastard * iswm %f) || (cunt* iswm %f) || (*cunt* iswm %f) || (* cock * iswm %f) || (*cock-* iswm %f) || (cock iswm %f) || (*fuk* iswm %f) || (*fuck* iswm %f) || (*fucker* iswm %f) || (*fucking* iswm %f) || (* horny * iswm %f) || (* nigger * iswm %f) || (* nigger iswm %f) || (nigger iswm %f) || (*penis* iswm %f) || (* pussy iswm %f) || (*pussy- * iswm %f) || (* pussy * iswm %f) || (pussy iswm %f) || (*slut* iswm %f) || (*whore* iswm %f) || (*di ck* iswm %f) || (*fck* iswm %f) || (*fak you * iswm %f) || (* dick * iswm %f) || (* cibai * iswm %f) || (<censored> iswm %f) || (<censored> * iswm %f) || (* <censored> iswm %f) || (* <censored> * iswm %f) || (* horny * iswm %f) || (* horny iswm %f) || (horny * iswm %f) || (* bitch * iswm %f) || (* bitch iswm %f) || (bitch * iswm %f) { kick $chan $nick Swearing Detected, DONT SWEAR In My Private! Ban -u180 $chan $nick 2 } } }
|
|
|
|
Joined: Jul 2006
Posts: 4,180
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,180 |
The on text event trigger in private so $chan is $null and kb the nick in private makes no sense, what do you want to do ? .
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Jan 2007
Posts: 1,156
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
This code will not work because there is no $chan in a query event. Either have this feature on or off. Same goes for your ban. You can use $comchan($nick,1) for the 1st channel in the your channel list that you both are in. Or you can write the channel name in.
|
|
|
|
Joined: May 2009
Posts: 28
Ameglian cow
|
OP
Ameglian cow
Joined: May 2009
Posts: 28 |
what i wan to do is kb chatter if they swear in my private
|
|
|
|
Joined: Nov 2009
Posts: 117
Vogon poet
|
Vogon poet
Joined: Nov 2009
Posts: 117 |
on ^*:OPEN:?:pmkban $1-
on *:TEXT:*:?:pmkban $1-
on *:ACTION:*:?:pmkban $1-
alias -l pmkban {
if $regex($1-,/word1|word2|word3/iS) {
var %c,%i 1
while $comchan($nick,%i) {
%c = $v1
if $nick(%c,$me,~&@%) {
ban -ku600 %c $nick 2 Ten minute ban for language in private message!
}
inc %i
}
.ignore -u600 $nick 2
}
}
|
|
|
|
Joined: Jul 2007
Posts: 1,129
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
The regex match range can get real long if there's a lot of bad words to add. It may also get cut off. Using $count() for bad word matching is pretty much the same as the regex you use in your script. You can use the line break $& identifier to break up a single line to multiple ones. But you can't use the $& for regex...because it won't work.
|
|
|
|
Joined: May 2009
Posts: 28
Ameglian cow
|
OP
Ameglian cow
Joined: May 2009
Posts: 28 |
lol so wats the easier way?
|
|
|
|
Joined: Jul 2007
Posts: 1,129
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
Use the $count() with the line break identifier like this: on ^*:OPEN:?:pmkban $1-
on *:TEXT:*:?:pmkban $1-
on *:ACTION:*:?:pmkban $1-
on *:NOTICE:*:?:pmkban $1-
alias -l pmkban {
if $count($strip($1-),bitch,bastard,cunt,cock,fuk,[censored],horny,nigger,whore,penis,$&
shithead,badword,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,$&
36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,$&
) {
var %c,%i 1
while $comchan($nick,%i) {
%c = $v1
if $nick(%c,$me,~&@%) {
ban -ku600 %c $nick 2 Ten minute ban for foul language in private message!
}
inc %i
}
}
} Replace the numbers with the bad words. You do the same with $& identifier when the line add gets long enough.
|
|
|
|
Joined: Nov 2009
Posts: 117
Vogon poet
|
Vogon poet
Joined: Nov 2009
Posts: 117 |
on ^*:OPEN:?:pmkban $1-
on *:TEXT:*:?:pmkban $1-
on *:ACTION:*:?:pmtkban $1-
on *:NOTICE:*:?:pmkban $1-
alias -l pmkban {
var %r /bitch|bastard|cunt|cock|fuc?k|<censored>| $&
h(0|o)rn(ie|y)|nigger|\btwat\b|whore|penis|shit| $&
\bcibai\b|di ?ck|pussy-?|fak you|fck|slut/iS
if $regex($1-,%r) {
var %c,%i 1
while $comchan($nick,%i) {
%c = $v1
if $nick(%c,$me,~&@%) {
ban -ku600 %c $nick 2 Ten minute ban for foul language in private message!
}
inc %i
}
.ignore -u600 $nick 2
}
}
|
|
|
|
Joined: Jul 2007
Posts: 1,129
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
Fair enough. I overlooked the fact that a local var would've done the trick.
|
|
|
|
Joined: Jul 2007
Posts: 1,129
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
gooshie, one matter is found. I'm not sure if you've noticed an issue that the bad word after $& won't work, but the rest will.
|
|
|
|
Joined: Nov 2009
Posts: 117
Vogon poet
|
Vogon poet
Joined: Nov 2009
Posts: 117 |
on ^*:OPEN:?:pmkban $1-
on *:TEXT:*:?:pmkban $1-
on *:ACTION:*:?:pmtkban $1-
on *:NOTICE:*:?:pmkban $1-
alias -l pmkban {
var %c,%i 1,%r /bitch|bastard|cunt|cock|fuc?k|<censored>| $&
$+ h(0|o)rn(ie|y)|nigger|\btwat\b|whore|penis|shit| $&
$+ \bcibai\b|di ?ck|pussy-?|fak you|fck|slut/iS
if $regex($1-,%r) {
while $comchan($nick,%i) {
%c = $v1
if $nick(%c,$me,~&@%) {
ban -ku600 %c $nick 2 Ten minute ban for foul language in private message!
}
inc %i
}
.ignore -u600 $nick 2
}
}
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
In case you don't want to deal with regular expressions, but want to manage a variable list - allowing for a mix of both badWORDS (like pussy in your example) and badSTRINGS (like *slut* in your example), you could alternatively use $wildtok. It's not as fast as single-lined regular expression, but a flawed regex may be worse... Example: ; your list of badwords and badstrings
var %bad = badword1 *badstring* anotherbadword anotherb*string
var %n = 1
; loop the badwords and -strings
while ($gettok(%bad,%n,32)) {
; check for occurences of this badword/-string in <TEXT>
if ($wildtok(<TEXT>,$v1,1,32)) {
; your action here
echo -ag word $v1 in <TEXT> matches badword definition: $gettok(%bad,%n,32)
break
}
inc %n
} To combine the variability/legibility of a list and the speed/flexibility of regular expressions, a hash table in combination with $hfind(,R) could be of use (with no need for a while-loop).
|
|
|
|
Joined: Nov 2009
Posts: 117
Vogon poet
|
Vogon poet
Joined: Nov 2009
Posts: 117 |
Horstl I'll look foward to seeing your script that does all that..
|
|
|
|
Joined: Jul 2007
Posts: 1,129
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
It'd be nice if you could show us an example of how to use $hfind() with the r switch to match for bad words.
|
|
|
|
Joined: Jul 2006
Posts: 4,180
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,180 |
He said R, not r, here is quick example of what he meant alias testR { tokenize 32 this is the test sentence : plop. hadd -m badword .*test.* hadd badword plop hadd badword .*is\sthe.* echo -a > $hfind(badword,$1-,0,R) hfree badword } In regex, \s is a space and .* is used to represent the * wildcard (in order to have an item name where spaces can exists). Then, mirc compare (using regex) each item (that represent regex pattern) with $1- (like if ($regex($1-,itemN)) { })
Last edited by Wims; 28/12/09 09:18 AM.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Nov 2009
Posts: 117
Vogon poet
|
Vogon poet
Joined: Nov 2009
Posts: 117 |
I'm confused.. are you using regex in the hash table to solve some percieved problem with $regex???
Also, could you make a full script to do what the other script already does so we can compare size and sorta guess which is faster or easier to edit or whatever it is you are trying to improve upon...
|
|
|
|
|