[OGDev] Spam

Markus Linke markus.linke at linke.de
Thu Sep 27 20:43:19 BST 2007


thanks, I'll give it a try ...

----- "Kake L Pugh" <kake at earth.li> wrote:
| On Thu 27 Sep 2007, Markus Linke <markus.linke at linke.de> wrote:


| Yep!  As of version 0.61, OpenGuides lets you define a spamchecker
| module that will be invoked every time someone tries to save an edit.
| If the module decides that the edit is spam, it refuses the edit and
| informs the user.
| 
| From the docs for OpenGuides->commit_node:
| 
|   If you have specified the "spam_detector_module" option in your
|   wiki.conf, this method will attempt to call the "looks_like_spam"
|   method of that module to determine whether the edit is spam. If
| this
|   method returns true, then the spam_detected.tt template will be
| used
|   to display an error message.
| 
|   The looks_like_spam method will be passed a datastructure
| containing
|   content and metadata.
| 
| Here's an example:
| 
| [in wiki.conf]
| 
| spam_detector_module = OpenGuides::Local::OGLSpamDetector
| 
| [in OGLSpamDetector.pm]
| 
| package OpenGuides::Local::OGLSpamDetector;
| 
| use strict;
| 
| sub looks_like_spam {
|     my ( $class, %args ) = @_;
| 
|     if ( $args{metadata}{comment} =~ /some grammatical corrections/i )
| {
|         return 1;
|     }
| 
|     my @cats = @{ $args{metadata}{category} };
|     foreach my $cat ( @cats ) {
|         if ( $cat =~ m'http://'i ) {
|             return 1;
|         }
|     }
| 
|     my @locs = @{ $args{metadata}{locale} };
|     foreach my $loc ( @locs ) {
|         if ( $loc =~ m'http://'i ) {
|             return 1;
|         }
|     }
| 
| }




More information about the OpenGuides-Dev mailing list