mIRC Home    About    Download    Register    News    Help

Print Thread
#254392 08/08/15 04:55 PM
Joined: May 2015
Posts: 133
K
Vogon poet
OP Offline
Vogon poet
K
Joined: May 2015
Posts: 133
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!


twitter @keyeslol
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
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)
}

Last edited by Sakana; 08/08/15 10:17 PM.
Joined: May 2015
Posts: 133
K
Vogon poet
OP Offline
Vogon poet
K
Joined: May 2015
Posts: 133
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.


twitter @keyeslol
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
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

Joined: May 2015
Posts: 133
K
Vogon poet
OP Offline
Vogon poet
K
Joined: May 2015
Posts: 133
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?


twitter @keyeslol
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
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 }
}






Last edited by Sakana; 09/08/15 06:10 PM.
Joined: May 2015
Posts: 133
K
Vogon poet
OP Offline
Vogon poet
K
Joined: May 2015
Posts: 133
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?


twitter @keyeslol
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
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] 
    }
  }
}

Last edited by Sakana; 10/08/15 06:20 AM.
Joined: May 2015
Posts: 133
K
Vogon poet
OP Offline
Vogon poet
K
Joined: May 2015
Posts: 133
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!


twitter @keyeslol

Link Copied to Clipboard