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)
}
}
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
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 ] ] }
}
}
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.
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).
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.
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).