mIRC Homepage
Posted By: keyeslol Symbol Protection - 08/08/15 04:55 PM
Hey guys,

I'm looking to implement symbol protection (non alphanumberic) for a channel.

What would be the best way to handle this?

Code:
if $len($removecs($strip($1-)[^a-z0-9\s])) > 10)


Or perhaps some other way?

Thanks!
Posted By: Sakana Re: Symbol Protection - 08/08/15 10:13 PM
Don't you want these allowed?

. , ? - : ' / & ( )


Does your thing work? Otherwise I made this to find the number of non-alphanum characters in $1-

Code:
alias symbols {
  var %res
  noop $regsub(testing,$1-,/[\w\s]/gi,p,%res)
  var %len_res = $regex(%res,/p/g)
  return $calc($len($1-) - %len_res)
}
Posted By: keyeslol Re: Symbol Protection - 08/08/15 10:16 PM
Any non-alphanumeric character I want to basically detect and delete it from chat.

ASCII is really common to spam, so i want to basically delete it.
Posted By: Sakana Re: Symbol Protection - 09/08/15 04:33 AM
Ok, well I guess the best way is just to calculate the percentage of symbols in the message, so if the length of the message is over 10 and the % of symbols is over 50% then it has to be spam
Posted By: keyeslol Re: Symbol Protection - 09/08/15 04:21 PM
Your alias is returning the length correct? So i could call your alias, compare what you are returning and if over 10 do action right?
Posted By: Sakana Re: Symbol Protection - 09/08/15 06:06 PM
Ya, it returns the number of symbols

//echo -a $symbols(fhdl34@kals:asd k2")

This should give 3


You can only check for the number of symbols if you want, but it's probably better to check the ratio of symbols to letters/numbers as well as the length of the message
Code:

if ($len($1-) > 10) {
var %ratio = $calc($symbols($1-)/$len($1-))
 if (%ratio > 0.5) { do something }
}





Posted By: keyeslol Re: Symbol Protection - 10/08/15 05:54 AM
So here's my code so far, doesn't seem to be working.

Code:
  alias symbols {
    var %res
    noop $regsub(testing,$1-,/[\w\s]/gi,p,%res)
    var %len_res = $regex(%res,/p/g)
    return $calc($len($1-) - %len_res)
  }

  if ($len($1-) > 10) {
    var %ratio = $calc($symbols($1-)/$len($1-))
    if (%ratio > 0.5) { 
      msg # .timeout $nick 600
    msg # $nick -> stop spamming symbols! [timeout] }
  }


Ideas?
Posted By: Sakana Re: Symbol Protection - 10/08/15 06:15 AM
You're missing the ON TEXT wink
This is the full and working thing. You can obviously change the length and ratio that trigger the ban to anything you want.


Code:
alias symbols {
  var %res
  noop $regsub(testing,$1-,/[\w\s]/gi,p,%res)
  var %len_res = $regex(%res,/p/g)
  return $calc((%len_res - $len($1-))*(-1))
}

on *:text:*:#: {
  if ($len($1-) > 10) {
    var %ratio = $calc($symbols($1-)/$len($1-))
    if (%ratio > 0.5) { 
      msg # .timeout $nick 600
      msg # $nick -> stop spamming symbols! [timeout] 
    }
  }
}
Posted By: keyeslol Re: Symbol Protection - 10/08/15 05:12 PM
I didn't post my entire code lol. I have an on text at the top of my code. I think my problem was where it was, as i just realized my alias was within my on * event.

Thanks for the help Sakana!
© mIRC Discussion Forums