spam protection (bot)

By PuNkTuReD on Dec 24, 2008

multi channel spam protection for a bot

!sp on/off/status

available to channel operators and helpers

catches
http - www - com - org - net

on *:TEXT:*:#: { 
  if ($nick isop $chan) || ($nick ishop $chan) {
    if (!sp == $strip($1)) { 
      if (!$2) { .msg $chan ?spam command: ?spam on/off/status }
      if ($regex($strip($1-),/on|off/i)) { set $+(%,sp,$chan) $2 | .msg $chan Spam Protect is now $($+(%,sp,$chan),2) $+ . }
      if ($strip($2) == status) { .msg $chan Spam Protect is currently $($+(%,sp,$chan),2) }
  } }
  if ($regex($strip($1-),/\b(?:http|www|com|org|net)\b/i)) && ($($+(%,sp,$chan),2) == on) { 
    if ($+(%,spam,$nick) == $null) { set $+(%,spam,$nick) 1 }
    else { inc $+(%,spam,$nick) 1 }
    if ($($+(%,spam,$nick),2) == 3) { unset $+(%,spam,$nick) | ban -k $chan $nick 2 Spam/Advertising. | .notice $nick You have been banned from $chan for Spam/Advertising. }
    .msg $chan $nick - Spamming is not allowed in this channel.
} } 

Comments

Sign in to comment.
michealkenny   -  Aug 01, 2010

it does work on the ustream flash chat, in a client it shows up as -opsusername/#channel- REMOVE usernameofposter messageofposter, but on the ustream flash chat, it shows up as [Removed By OpsUsername], but it wouldn't work on a network such as geekshed, but i just want this for ustream so can you help me? thank you in advance, sorry I just don't know how to write code, thank you

 Respond  
Gummo   -  Aug 01, 2010
notice # REMOVE $nick $1-

That can't remove messages unless the clients allow that syntax. For you to have received the message, all other clients must have also seen it.

 Respond  
michealkenny   -  Jul 31, 2010

hi, this is awesome!, but I would like it if it did nothing but remove the url and kick on the second time unless your an op or half-op, then it doesn't remove the url or kick or warn, I would like for this to work on the ustream irc network and i think the script for removing posts on ustream is

notice # REMOVE $nick $1-

thank you so much if you know how to do it!

this is the script with the removing code in it and it works, but i dont want it to ban users, I just want it to kick them on the second time they post a link and i dont want it to do anything if your an op or half op

on *:TEXT:*:#: { 
  if ($nick isop $chan) || ($nick ishop $chan) {
    if (!sp == $strip($1)) { 
      if (!$2) { eis | .msg $chan ?spam command: ?spam on/off/status }
      if ($regex($strip($1-),/on|off/i)) { set $+(%,sp,$chan) $2 | .msg $chan Spam Protect is now $($+(%,sp,$chan),2) $+ . }
      if ($strip($2) == status) { .msg $chan Spam Protect is currently $($+(%,sp,$chan),2) }
  } }
  if ($regex($strip($1-),/\b(?:http|www|com|org|net)\b/i)) && ($($+(%,sp,$chan),2) == on) { 
    if ($+(%,spam,$nick) == $null) { set $+(%,spam,$nick) 1 }
    else { inc $+(%,spam,$nick) 1 }
    if ($($+(%,spam,$nick),2) == 3) { unset $+(%,spam,$nick) | ban -k $chan $nick 2 Spam/Advertising. | .notice $nick You have been banned from $chan for Spam/Advertising. }
    .msg $chan $nick - Spamming is not allowed in this channel.
    notice # REMOVE $nick $1-
} } 

thanks in advance

 Respond  
RicJames   -  May 05, 2010

Sweet Thanks Jethro_ :)

Edit: Sorry my brain must of been switched off :P

Thanks again Jethro :)

 Respond  
Jethro   -  May 03, 2010

RicJames, I edited the code above. Please see to it.

 Respond  
RicJames   -  May 03, 2010

Nice Jethro thanks but can you please edit it so it doesn't ban halfops and above? Thanks in advance :)

 Respond  
Jethro   -  May 03, 2010
on $*:text:/^!sp\so(n|ff)$/iS:#: {
  if (!%f) { inc -u5 %f | if ($nick(#,$nick,oh)) {
      var %s *** Spam protection is now
      $+($replace($regml(1),n,.en,ff,.dis),able) #spam
  .msg # $iif($group(#spam) != on,%s off!,%s on!) } }
}
#spam on
on @*:text:*:#:url $1-
on @*:action:*:#:url $1-
on @*:notice:*:#:url $1-
alias -l url {
  var %s = /(?<=^|\s)((?>\S{3,8}:\/\/|w{3}\56)\S+)/iS
  if (($regex($1-,%s)) && ($nick(#,$nick,rv))) {
    ban -ku300 # $nick 2 Spamming is not allowed in this channel!
  }
}
#spam end
 Respond  
RicJames   -  May 03, 2010

Would I change the 3 here > if ($($+(%,spam,$nick),2) == 3) to 1 if I want it to ban first time instead of warning them?

Edit: This script doesn't work :(

 Respond  
  -  Mar 02, 2010

did you get my msg. ?

 Respond  
Jethro   -  Mar 02, 2010

You need to change #room1 and #room2 to the actual channel names. Replace them with the channels you want the script to work in. For example, > on @:TEXT::#yusif,#blah: { will work for the channel #yusif and #blah

 Respond  
  -  Mar 02, 2010

no Jethro_ , the chanels there all single # nothing else

but what i meant by didn't works for me , the script , not what you showed for specific room

 Respond  
Jethro   -  Mar 02, 2010

Why didn't it work for you? Are you using a network that have the %# channel type instead of the single #?

 Respond  
  -  Mar 02, 2010

thanks Jethro_ for your help, but unfortunately didnt work for me
and the question! dose it work with all mirc versions or just with specific version and higher ?

 Respond  
Jethro   -  Mar 01, 2010

am opping in 4 rooms at the same time, and i just want it only work for two of them while am still opping in other two roomschange > on :TEXT::#: {To:

on @*:TEXT:*:#room1,#room2: {

Replace #room1 and #room2 with the actual channel names. They are the rooms you want the script to work in.

 Respond  
Gummo   -  Mar 01, 2010

Also, if you stick the S modifier onto the end of the regex (so it's /regex/iS) then you can check against $1- instead of $strip($1-)

 Respond  
  -  Mar 01, 2010

would it work only in specific room ?
which mean , am opping in 4 rooms at the same time, and i just want it only work for two of them while am still opping in other two rooms too,
how can that happen ?

 Respond  
radtaz   -  Dec 25, 2008

Man Thanks man It works great.

 Respond  
Aucun50   -  Dec 25, 2008

Update works perfect good job.

 Respond  
PuNkTuReD   -  Dec 25, 2008

ahh cool thanks for that Gummo
and thanks FragUK

 Respond  
fraguk   -  Dec 25, 2008

Nice work PunkTuReD m8

 Respond  
Gummo   -  Dec 25, 2008

Perhaps make:

/http|www|com|org|net/i

Become:

/\b(?:http|www|com|org|net)\b/i

To remove false positives. The \b is a word boundary.

 Respond  
PuNkTuReD   -  Dec 25, 2008

this should work if you dont want it kicking ops, halfops or voiced users

on *:TEXT:*:#: { 
  if ($nick isop $chan) || ($nick ishop $chan) {
    if (!sp == $strip($1)) { 
      if (!$2) { eis | .msg $chan ?spam command: ?spam on/off/status }
      if ($regex($strip($1-),/on|off/i)) { set $+(%,sp,$chan) $2 | .msg $chan Spam Protect is now $($+(%,sp,$chan),2) $+ . }
      if ($strip($2) == status) { .msg $chan Spam Protect is currently $($+(%,sp,$chan),2) }
  } }
  if ($regex($strip($1-),/http|www|com|org|net/i)) && ($($+(%,sp,$chan),2) == on) { 
    if ($nick isop $chan) || ($nick ishop $chan) || ($nick isvoice $chan) { halt }
    else {
      if ($+(%,spam,$nick) == $null) { set $+(%,spam,$nick) 1 }
      else { inc $+(%,spam,$nick) 1 }
      if ($($+(%,spam,$nick),2) == 3) { unset $+(%,spam,$nick) | ban -k $chan $nick 2 Spam/Advertising. | .notice $nick You have been banned from $chan for Spam/Advertising. }
      .msg $chan $nick - Spamming is not allowed in this channel.
    }
} } 
 Respond  
radtaz   -  Dec 25, 2008

Can you or can you tell me how to make it to where is does not kick ops, half-ops, or voiced people? Thanks

 Respond  
PuNkTuReD   -  Dec 25, 2008

sorry about that

 Respond  
Aucun50   -  Dec 24, 2008

Thanks ill give it a try again.
Just gave it a try and it bans right away still.

 Respond  
PuNkTuReD   -  Dec 24, 2008

fair call,
updated to ban on the third spam

 Respond  
Aucun50   -  Dec 24, 2008

Tested it works great, one thing, if someone spams i shouldn't ban right away it should warn 3 times then ban but that just my input.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.