Skip to main content

comments

Drupal module: Advanced Comment Trigger

Posted in

I have to admit that I've got it pretty good in the website spam department. The Mollom project, started by some of the same folks who started Drupal, uses content analysis to keep spam users from registering accounts on my site, leaving blog & forum comments, and using my site's contact form to spam me via email as well.

The only problem that I've really seen is the rise of spammers who will post blog comments containing text from the blog post itself, almost entirely unchanged, along with one or more links to their sites. Content-based analysis is of no use here, since the majority of the comment is actual text that I would want on my site -- after all, I blogged it!

Until now, I've been following all blog comments to my site via built-in RSS feeds, noticing spam comments some time after they were posted, and going back and deleting them. Drupal allows for comment moderation, but I want comments to go out there right away.

Drupal also allows for some advanced responses using triggers and actions. I could define a trigger such as "comment contains http://" and then assign it an action such as "unpublish comment". In fact, this is what fellow Cocoa developer and Drupal user David Sinclair of Dejal Systems does currently.

But this presents a problem in my use case, as i want to publish comments of my own sometimes containing hyperlinks. Also, I don't have a problem on my forums, just on the blog.

After some back and forth with David on Twitter, I decided to set out and build a small module to help with this. About twenty-four hours later, I give you: Advanced Comment Trigger.

After enabling the module, head to the trigger configuration in Drupal, then the "Advanced comment trigger" tab. Assign the new trigger to the "Unpublish comment" action, then follow the link to fine-tune the module settings. You can configure the trigger to occur on anywhere from one to five or more hyperlinks in the comment body, as well as exempt certain user roles (for example, site admins) or certain content types (for example, forum topics) from triggering the action.


trigger & action configuration


module configuration

I've also included the source to a Drupal view to create an RSS feed of moderated comments so that you can easily follow the comments to which the trigger applies. Checking this from time to time will allow you to easily publish any comments that accidentally get moderated, as well as get an idea of how well this module is working.

In the near future, I hope to add a few more available actions to the trigger such as emailing a site admin or post author or blocking an offending commenter.

Feedback is welcome. You can follow the project at the Drupal project page or on GitHub.

Syndicate content