MT comment spam prevention

While I suppose that putting this here will teach certain lowlifes how to get around it, I suppose it’s worth sharing the technique, so that other people can benefit from it. Seems that the spammers are idiots, and post the same comment repeatedly. So if you get a pattern early on, you can prevent a lot of other ones later.

The following goes in $MT/lib/MT/App/Comments.pm and assumes that you have some clue about Perl. I won’t be providing tech support for this. Please contact your local Perl guru.

It should be somewhat obvious where these go. I’ve provided a few lines of context.

    if (!$q->param('text')) {
        return $app->handle_error($app->translate("Comment text is required."));
    }
    if ($q->param('text') =~ /I wish it true|see a later|cool amazing page/i) {
        return $app->handle_error($app->translate(
                        "An unexpected error has occured"));
    }   
    if ($q->param('author') =~ /hydrocodone|phentermine|gay f..king|valium/i) {
        return $app->handle_error($app->translate(
                        "An unexpected error has occured"));
    }
    if ($q->param('url') =~ /cheapdrug/i) {
        return $app->handle_error($app->translate(
                        "An unexpected error has occured"));
    }
    
    my $comment = MT::Comment->new;

And proceed with that same sort of thing. This will bit-bucket the most eggregious morons, and then you’ll still have to deal with the others manually. Or migrate to WordPress, as I’m planning to do just as soon as I get a few spare moments.