This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Spam protection

Help for those learning Tcl or writing their own scripts.
Post Reply
F
Fill
Halfop
Posts: 80
Joined: Sun Jan 18, 2009 6:08 pm

Spam protection

Post by Fill »

Hey there,

I'm building an anti-spam script which is now something like this:

Code: Select all

set varExceptions {
  "exception 1"
  "exception 2"
}

bind pubm - "$spamchan *.net*" spamfilter
bind pubm - "$spamchan *http://*" spamfilter

bind pubm - "$spamchan *www.*" spamfilter

bind pubm - "$spamchan *hotmail*" spamfilter
bind pubm - "$spamchan *mail*" spamfilter
bind pubm - "$spamchan *youtube*" spamfilter
bind pubm - "$spamchan *myspace*" spamfilter
bind pubm - "$spamchan *blog*" spamfilter
bind pubm - "$spamchan *flog*" spamfilter
bind pubm - "$spamchan *fotolog*" spamfilter
bind pubm - "$spamchan *#*" spamfilter
bind pubm - "$spamchan *.pt*" spamfilter
bind pubm - "$spamchan *.com.pt*" spamfilter
bind pubm - "$spamchan *.biz*" spamfilter
bind pubm - "$spamchan *.info*" spamfilter
bind pubm - "$spamchan *.com*" spamfilter
bind pubm - "$spamchan *.net*" spamfilter
bind pubm - "$spamchan *.org*" spamfilter
bind pubm - "$spamchan *.co.uk*" spamfilter
bind pubm - "$spamchan *.eu*" spamfilter
bind pubm - "$spamchan *.au*" spamfilter
bind pubm - "$spamchan *.com.br*" spamfilter
bind pubm - "$spamchan *.tv*" spamfilter
bind pubm - "$spamchan *.org.pt*" spamfilter
bind pubm - "$spamchan *.me*" spamfilter


proc spamfilter { nick uhost hand chan text } {
  global varExceptions spammer
  foreach site $varExceptions {
    if {[string match -nocase "*$site*" $text]} {return 0}
  }
  if {(![isop $nick $chan]) && (![ishalfop $nick $chan]) && (![isvoice $nick $chan]) } {

	set host *!*@[lindex [split $uhost @] 1]

	newchanban $chan ~q:$host RoBotX(nospam.tcl) spammer($chan) 60 sticky

	putserv "PRIVMSG $chan $nick: You're not allowed to spam on $chan. Adding temporary ~q: ban on your host. All your messages will be ignored from now on."
	}
} 
The problem is that when someone says "Visit my website --> www.testsomething.net", the bot sends double message, 'cos it binds the *www.* and *.net* -.-"

However I want to bind all these wildcards because sometimes they just say "site.net", etc... and I also have to mantain my exceptions.

What's your suggestion to solve my problem?
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

It is a sort of byproduct of your method of dealing with spam. Specifically, seperate PUBM binds.

The norm would be to create a list of *spam* masks and, using a single PUBM bind, test each in a foreach loop. You could then output and break from the loop upon finding the first incidence of spam.

Remember also that the bot must test each PUBM bind against each IRC channel chat line. In a fast moving channel with many PUBM binds, that puts a significant strain on the bots resources.

Check out the scripts on offer on this site's Tcl achive. It's a good way to learn.

To be fair I suppose testing each chat line against many spam masks is perhaps also something of a strain too.
I must have had nothing to do
K
Kein
Voice
Posts: 21
Joined: Wed Apr 09, 2008 9:57 pm

Post by Kein »

OMG
That is the first time when I see such big amounts of pubms >_>

As arfer already said: use general '*' pubm :P
I'm too lazy for all of this
F
Fill
Halfop
Posts: 80
Joined: Sun Jan 18, 2009 6:08 pm

Post by Fill »

arfer wrote:It is a sort of byproduct of your method of dealing with spam. Specifically, seperate PUBM binds.

The norm would be to create a list of *spam* masks and, using a single PUBM bind, test each in a foreach loop. You could then output and break from the loop upon finding the first incidence of spam.

Remember also that the bot must test each PUBM bind against each IRC channel chat line. In a fast moving channel with many PUBM binds, that puts a significant strain on the bots resources.

Check out the scripts on offer on this site's Tcl achive. It's a good way to learn.

To be fair I suppose testing each chat line against many spam masks is perhaps also something of a strain too.
yeah I see. someone told me to use regular expressions for URL matching. But maybe your method is better, I'll try and download some sample script @ the TCL archive. anyway, how would I stop a loop upon the first matching?
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

After executing whatever kick/ban/warning code simply use the Tcl command break to exit the foreach loop.

I have to say, I have a particular loathing of these scripts. They lack inbuilt intelligence (masks are generally too vague). For example, all it takes is for one user to say to another user on the channel "Are you on myspace?" and they get an immediate sticky ban.
I must have had nothing to do
z
zerodtk
Voice
Posts: 20
Joined: Wed Mar 25, 2009 6:06 pm

Post by zerodtk »

or just try to add it with *www*biz*
just a quick thought
F
Fill
Halfop
Posts: 80
Joined: Sun Jan 18, 2009 6:08 pm

Post by Fill »

arfer wrote:After executing whatever kick/ban/warning code simply use the Tcl command break to exit the foreach loop.

I have to say, I have a particular loathing of these scripts. They lack inbuilt intelligence (masks are generally too vague). For example, all it takes is for one user to say to another user on the channel "Are you on myspace?" and they get an immediate sticky ban.
Well I didn't decide the binds, someone asked me to do it with these wildcards ^^
Post Reply