Anti-advertisement Bot

By ducki on Feb 25, 2009

Hi, I'd just like to start off by saying I'm new to Hawkee and I'm very excited to join, but I've been practicing lately on my coding and have gotten a few snippets done. This one here is very sample. It is an anti-advertisement Bot that protects your channel from any user without access who spams a channel name or a website link beginning with 'www.' or 'http'. First time this happens the Bot simply notices the user giving them their first warning. Second time around, they are kicked from the channel with a message stating the reason why. Third time around they are temporarily banned for two minutes, then removed for a repeat offense; and, for the fourth time, they are banned for a total of 30 minutes for their offense. Feel free to adjust it to your likings. Also, comments would be nice. Feedback is always a plus so I can strengthen my coding skills. Thanks guys! :D

on *:TEXT:*#*:#Channel:{ 
  if ($nick !isreg #) || ($nick == $me) { halt }
  inc %ad. [ $+ [ $nick ] ]
  if (%ad. [ $+ [ $nick ] ] == 1) { notice $nick This is your first warning to notify you that you are advertising without authorization. }
  if (%ad. [ $+ [ $nick ] ] == 2) { /kick $chan $nick You have been kicked due to an unauthorized advertisement. }
  if (%ad. [ $+ [ $nick ] ] == 3) { 
    timer 1 0 raw -q MODE $chan +b $address($nick,2)
    timer 1 1 raw -q KICK $chan $nick :You have been banned for two minutes due to a repeated offense of an unauthorized advertisement.
  timer 1 120 raw -q MODE $chan -b $address($nick,2) }
  if (%ad. [ $+ [ $nick ] ] == 4) {
    timer 1 0 raw -q MODE $chan +b $address($nick,2)
    timer 1 1 raw -q KICK $chan $nick :You have been banned for thirty minutes due to a repeated offense of an unauthorized advertisement. | unset %ad. [ $+ [ $nick ] ]
    timer 1 1800 raw -q MODE $chan -b $address($nick,2)
  }
}
on *:TEXT:*www.*:#Channel:{ 
  if ($nick !isreg #) || ($nick == $me) { halt }
  inc %ad. [ $+ [ $nick ] ]
  if (%ad. [ $+ [ $nick ] ] == 1) { notice $nick This is your first warning to notify you that you are advertising without authorization. }
  if (%ad. [ $+ [ $nick ] ] == 2) { /kick $chan $nick You have been kicked due to an unauthorized advertisement. }
  if (%ad. [ $+ [ $nick ] ] == 3) { 
    timer 1 0 raw -q MODE $chan +b $address($nick,2)
    timer 1 1 raw -q KICK $chan $nick :You have been banned for two minutes due to a repeated offense of an unauthorized advertisement.
  timer 1 120 raw -q MODE $chan -b $address($nick,2) }
  if (%ad. [ $+ [ $nick ] ] == 4) {
    timer 1 0 raw -q MODE $chan +b $address($nick,2)
    timer 1 1 raw -q KICK $chan $nick :You have been banned for thirty minutes due to a repeated offense of an unauthorized advertisement. | unset %ad. [ $+ [ $nick ] ]
    timer 1 1800 raw -q MODE $chan -b $address($nick,2)
  }
}
on *:TEXT:*http*:#Channel:{ 
  if ($nick !isreg #) || ($nick == $me) { halt }
  inc %ad. [ $+ [ $nick ] ]
  if (%ad. [ $+ [ $nick ] ] == 1) { notice $nick This is your first warning to notify you that you are advertising without authorization. }
  if (%ad. [ $+ [ $nick ] ] == 2) { /kick $chan $nick You have been kicked due to an unauthorized advertisement. }
  if (%ad. [ $+ [ $nick ] ] == 3) { 
    timer 1 0 raw -q MODE $chan +b $address($nick,2)
    timer 1 1 raw -q KICK $chan $nick :You have been banned for two minutes due to a repeated offense of an unauthorized advertisement.
  timer 1 120 raw -q MODE $chan -b $address($nick,2) }
  if (%ad. [ $+ [ $nick ] ] == 4) {
    timer 1 0 raw -q MODE $chan +b $address($nick,2)
    timer 1 1 raw -q KICK $chan $nick :You have been banned for thirty minutes due to a repeated offense of an unauthorized advertisement. | unset %ad. [ $+ [ $nick ] ]
    timer 1 1800 raw -q MODE $chan -b $address($nick,2)
  }
}

Comments

Sign in to comment.
Jethro   -  Feb 28, 2009

fahadbalboa, this regex code will work:

on $*:TEXT:/(www\56|\57\57\56|\72\57\57|\43[a-zA-Z]|.com|.net|.org)/iS:*: {

What it won't trigger upon:
1) It will not match http
2) It will not match #
3) It will not match www
What it will trigger upon:
1) It will match http://
2) It will match #ChannelNameHere
3) It will match www.
Additionally, it will match spamming messages comprising of .com, .net or .org

 Respond  
fahadbalboa   -  Feb 28, 2009

Not Working ? Why ?

 Respond  
Jethro   -  Feb 27, 2009

Oh yeah, Kirby. But if that changes to

if ($nick isreg $comchan($nick,1))

, it will be valid.

 Respond  
Kirby   -  Feb 27, 2009
on $*:TEXT:/(www\56|\57\57\56|\72\57\57|\43[a-zA-Z]|.com|.net|.org)/iS:*: {

You don't want * for # if you're going to have

if ($nick isreg #) {

I'm sure it works...I just tested it.

 Respond  
Jethro   -  Feb 26, 2009

Why not?
Below edited version ought to work:

on $*:TEXT:/(www\56|\57\57\56|\72\57\57|\43[a-zA-Z]|.com|.net|.org)/iS:*: {
  if ($nick isreg #) {
    inc %ad. [ $+ [ $wildsite ] ]
    if (%ad. [ $+ [ $wildsite ] ] == 1) { .notice $nick This is your first warning to notify you that you are advertising without authorization. }
    if (%ad. [ $+ [ $wildsite ] ] == 2) { .kick $chan $nick You have been kicked due to an unauthorized advertisement. }
    if (%ad. [ $+ [ $wildsite ] ] == 3) { ban -ku120 $nick 2 You have been banned for two minutes due to a repeated offense of an unauthorized advertisement. }
    if (%ad. [ $+ [ $wildsite ] ] == 4) { ban -ku1800 $nick 2 You have been banned for thirty minutes due to a repeated offense of an unauthorized advertisement. | unset %ad. [ $+ [ $wildsite ] ] }
  }
}
 Respond  
ducki   -  Feb 26, 2009

It doesn't work for me.

 Respond  
Jethro   -  Feb 26, 2009

Sorry my silly mistake. The comma isn't needed at all. Please remove it.

on $*:TEXT:/(www\56|\57\57\56|\72\57\57|\43[a-zA-Z]|.com|.net|.org)/iS:*: {

Now it should kick people who spam beginning with # and NOT like ######### repeatedly or, as kirby suggested in his example...who's #1...etc. It will match # followed by only channel names.

Replaced on text # with * so it works on the private, too.

 Respond  
Kirby   -  Feb 26, 2009

I don't understand regex. Sorry, I cannot help you.

 Respond  
ducki   -  Feb 26, 2009

What would I have to put in order for it to also kick those who spam a channel beginning with #?

 Respond  
Kirby   -  Feb 26, 2009

As I said before, with the -u switch, it unbans in the # of seconds supplied in the succeeding parameter.
And I just tested it but, it only occurs when someone says something with www or http.

 Respond  
ducki   -  Feb 26, 2009

What would I have to put in order for the Bot to remove the ban instead of the ChanServ? Or does the bot still remove the ban?

Does that script count for anyone who advertises anything beginning with a #, www., or http?

 Respond  
Kirby   -  Feb 26, 2009

I missed a comma in my regex string. I edited it. Also, you can just use
Code:

unset %ad.*

If you unset all of it, then it unsets other "warned" nicks/addresses as well.

So what I would've done is something like this, taking Jethro_'s regex on text:

on $*:text:/(www\56|\57\57\56|\72\57\57|\43,[a-zA-Z]|.com)/iS:#: {
  if ($nick isreg #) {
    inc %ad. [ $+ [ $wildsite ] ]
    if (%ad. [ $+ [ $wildsite ] ] == 1) { .notice $nick This is your first warning to notify you that you are advertising without authorization. }
    if (%ad. [ $+ [ $wildsite ] ] == 2) { .kick $chan $nick You have been kicked due to an unauthorized advertisement. }
    if (%ad. [ $+ [ $wildsite ] ] == 3) { ban -ku120 $nick 2 You have been banned for two minutes due to a repeated offense of an unauthorized advertisement. }
    if (%ad. [ $+ [ $wildsite ] ] == 4) { ban -ku1800 $nick 2 You have been banned for thirty minutes due to a repeated offense of an unauthorized advertisement. | unset %ad. [ $+ [ $wildsite ] ] }
  }
}

I've also forgotten to mention that there's a -u switch, which means unset in # of seconds.
So

ban -u120k

would ban, kick, and unban in 120 seconds (2 minutes).

 Respond  
Jethro   -  Feb 25, 2009

I missed a comma in my regex string. I edited it. Also, you can just use

unset %ad.*
 Respond  
ducki   -  Feb 25, 2009

Thanks for your feedback guys! :D

 Respond  
Jethro   -  Feb 25, 2009

Not sure how you can fix the "www" and "#" things, so you should ask a person who is familiar with regex (regular expressions).
It's easy to fix it with regex:

on $*:TEXT:/(www\56|\57\57\56|\72\57\57|\43,[a-zA-Z]|.com)/iS:#: {

The above regex string will match www. http:// .com and # It won't kick with just reading # itself.

 Respond  
Kirby   -  Feb 25, 2009

You could change:

    timer 1 0 raw -q MODE $chan +b $address($nick,2)
    timer 1 1 raw -q KICK $chan $nick :You have been banned for two minutes due to a repeated offense of an unauthorized advertisement.

into

ban -k $nick 2 You have been banned for two minutes due to a repeated offense of an unauthorized advertisement.

, as the "-k" switch signifies the "kick" and the "2" signifies the mask #.
I don't think timers are necessary, nor the raws.

  if ($nick !isreg #) || ($nick == $me) { halt }

could be removed and substituted with (on the next line)

if ($nick isreg #) {

, and start there, as scripts do not activate by "you".
Also, I wouldn't advise you to use

.timer 1 0 <action>

or use

on *:TEXT:*www.*:...{

, and

on *:TEXT:*#*:...

because someone could say something like this and could be banned like this.

Who's #1 on the stats?
BanBot1337 sets mode: +b !*@cows.go.mooooooooo.org You have been banned for two minutes due to a repeated offense of an unauthorized advertisement., or something like that. :P

I've also realized something: You used

  inc %ad. [ $+ [ $nick ] ]

If you're going to ban by $address($nick,2), then why not inc the same way?
People can easily by-pass this ban by changing nicks.

Not sure how you can fix the "www" and "#" things, so you should ask a person who is familiar with regex (regular expressions).

 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.