Callbacks for Handling Spam and Ham
Many anti-spam plugins may also want to provide users with the ability to report both false negatives (those comments that were reported as spam, but are indeed ham), and false positives (those comments that were reported as ham, but are in fact spam) so that the system can adapt to its mistakes. This allows for the potential for a system to learn from misreported values. The TypePad AntiSpam plugin is just such a system. In fact, it is the very basis for the entire service - enabling an entire community of users to collaboratively train a system as to what is ham or spam.
Therefore a developer may want to be notified when a user reclassifies a comment as spam or ham. To do this, they would register a handle_spam
and/or a handle_junk
callback as in the example below:
name: Example Plugin for Movable Type
id: Example
description: This plugin is an example plugin for Movable Type.
version: 1.0
callbacks:
handle_spam: $Example::Example::Plugin::handle_spam
handle_ham: $Example::Example::Plugin::handle_ham
Your plugin’s Plugin.pm
file would then need to contain the following handlers:
package Example::Plugin;
use strict;
sub handle_spam {
my ($cb, $app, $thing) = @_;
# do something
}
sub handle_ham {
my ($cb, $app, $thing) = @_;
# do something
}
1;
The return values of these handlers is ignored. All these callbacks enable is the opportunity to take some action on the related comment or TrackBack (“$thing
” in the above code sample).