mIRC Homepage
Posted By: 12izla using $& properly? - 29/06/06 09:46 PM
I have a line in a script that is too long for the editor, i found the $& comand in the help file. am i using it correctly? The way it is atm it isnt working, can someone point out where i have gone wrong?

Its basicly just code to filter out false positives in an intense swear filter on a games server.

Quote:

The $& identifier
This identifier allows you to break up a single line into multiple lines which are combined when the script is performed, so you can edit long commands more easily:

longline {
echo This is an example of a long $&
line that has been split into multiple lines $&
to make it easier to edit
}





Code:
 
      if ((ga ya isin %l) || (ga ye isin %l) || (ga yi isin %l) || (ga yo isin %l) || (ga yo isin %l) || (cockt isin %l) $&
        || (cockp isin %l) || (stfu k isin %l) || (g hey isin %l) || (f a ga isin %l) || (f a ge isin %l) || (f a gh isin %l) $&
        || (f a gi isin %l) || (f a gl isin %l) || (f a gn isin %l) || (f a go isin %l) || (f a gr isin %l) || (f a gr isin %l) $&
        || (f a gu isin %l) || (f a gy isin %l) || (f a gg isin %l) || (if u k isin %l) || (si u t isin %l) || (shi ton isin %l) $&
        || (di kan isin %l) || (f ago isin %l) || (f aga isin %l) || (arsen isin %l) || (ars e isin %l) || (t it's isin %l) || (t it s isin %l) $&
        || (shi tu isin %l) || (at it s isin %l) || (s Hi To isin %l) || (f u kno isin %l) || (tit isin %l) || (d i kn isin %l) $&
        || (d i ki isin %l) || (who re isin %l) || (g a ye isin %l) || (ped o isin %l) || (t its isin %l) || (t. its isin %l) || (t wat isin %l) $&
        || (bit ch isin %l) || (s hit isin %l) || (or gym isin %l) || (lt wate isin %l) || (ltwate isin %l) || (otwate isin %l) || (ot wate isin %l) $&
        || (sh it isin %l)) {
 
Posted By: voipme Re: using $& properly? - 29/06/06 09:50 PM
I'm thinking its the spacing. Try changing them to the following and see if it works.

Ex:
Code:

if (($+(ga,$chr(32),ya) isin %l) ||
...
 
Posted By: 12izla Re: using $& properly? - 29/06/06 10:18 PM
hmm i can try it, but the actual check for "ga ye" worked before the line got too long crazy
Posted By: 12izla Re: using $& properly? - 29/06/06 10:21 PM
Makes no diference frown thanks for the reply anyway.

The code worked when it was...

Code:
 

          if ((or gym isin %l) || (lt wat isin %l) || (otwate isin %l) || (hot wat isin %l) || (altwate isin %l) || (hotwat isin %l)) {
     
 


but as time went past i had to add in more checks untill it got to the point as i was saving the script the end of the line was being chopped off.
Posted By: genius_at_work Re: using $& properly? - 30/06/06 12:48 AM
Try making several sets of if-statements and a switch variable. Example:

Code:
var %switch = $false
if (blah1 isin %a || blah2 isin %a || blah3 isin %a) %switch = $true
if (blah4 isin %a || blah5 isin %a || blah6 isin %a) %switch = $true

if (%switch) { ;do the rest of your commands here }


Either that, or you (or someone) could make those conditions into a much shorter $regex.

-genius_at_work
Posted By: DaveC Re: using $& properly? - 30/06/06 03:49 AM
heres a non regex option, pretty simple to add to so doesnt take a regex master to apply it smile

if ($isin(%l,ga ya,ga ye,ga yi,ga yo,ga yo,cockt,cockp,stfu k,g hey,f a ga,f a ge,f a gh,f a gi,f a gl,f a gn,f a go,f a gr,f a gr,f a gu,f a gy,f a gg,if u k,si u t,shi ton,di kan,f ago,f aga,arsen,ars e,t it's,t it s,shi tu,at it s,s Hi To,f u kno,tit,d i kn,d i ki,who re,g a ye,ped o,t its,t. its,t wat,bit ch,s hit,or gym,lt wate,ltwate,otwate,ot wate,sh it)) {

you need an aditional alias below

alias isin { var %i = 2 | while (%i <= $0) { if ($($+($,%i),2) isin $1) { return $v1 } | inc %i } }

usage $isin(string,value1,value2,value3,...)
It well return with the first matching VALUE that is in STRING, else it returns nothing.
Posted By: schaefer31 Re: using $& properly? - 30/06/06 06:50 AM
Random questions.

Why such odd spacing in the words? (e.g. t it's)

Why such odd variations of words? (e.g. lt wat)
Posted By: DaveC Re: using $& properly? - 30/06/06 07:10 AM
Ill take a punt and say hes trying to build an Anti accidently detect swear words script maybe
I could see people using spaces to beat a swear word detector, so hes removing all spaces then sweeping for them "fast water" becomes "fastwater" and detects "twat", so maybe hes trying to buld in a anti matcher, in specific occasions like about the detect if "t wat" is detected, also see cocktail and cockpit examples.

That or hes trying the oppersite hes trying to detect swear words in other sentences, but there are certainly easier ways than that!
Posted By: genius_at_work Re: using $& properly? - 30/06/06 02:18 PM
This regex should work:

Code:
if ($regex(esc,%l,/(ga y[aeio]|cock[tp]|stfu k|g hey|f a g[aeghilnoruy]|if u k|si u t|shi ton|di kan|f ag[ao]|arsen|ars e|t\.? it[ ']?s|shi tu|at it s|s hi to|f u kno|tit|d i ki|who re|g a ye|ped o|t wat|bit ch|s hit|sh it|or gym|[ol]t ?wate)/iS)) { echo -a Matched $regml(esc,1) }

(untested)

-genius_at_work
Posted By: 12izla Re: using $& properly? - 30/06/06 04:48 PM
Quote:
This regex should work:

Code:
if ($regex(esc,%l,/(ga y[aeio]|cock[tp]|stfu k|g hey|f a g[aeghilnoruy]|if u k|si u t|shi ton|di kan|f ag[ao]|arsen|ars e|t\.? it[ ']?s|shi tu|at it s|s hi to|f u kno|tit|d i ki|who re|g a ye|ped o|t wat|bit ch|s hit|sh it|or gym|[ol]t ?wate)/iS)) { echo -a Matched $regml(esc,1) }

(untested)

-genius_at_work


You are 100% correct on the first guess, as the swear filter went up, instantly the gamers started spacing words out to avoid the bans, so removing spaces and the ussual space chars seemed like a good idea. unfortunatly it brought in some false bans for the likes of, "its a bit chilly in here" (banned for bitch) but i still want to ban for b-i-t-c-h and b i t c h.

Thanks for yer replies guys and i'll get to work on it 2nite laugh
© mIRC Discussion Forums