NAME
Blog::Spam::Plugin::Sample - A sample plugin.
ABOUT
This is a sample plugin which is designed to demonstrate the functionality which a plugin may implement to be usefully called by Blog::Spam::Server.
OVERVIEW
The Blog::Spam::Server receives comment data, via XML::RPC, from remote clients.
These incoming comments, and associated meta-data, will be examined by each known plugin in turn. If a single plugin determines the comment is SPAM then all further testing is ceased.
PLUGIN METHODS
For a plugin to be loaded it must live beneath the Blog::Spam::Plugin namespace.
There are two mandatory methods ("new" + "name"), and two optional methods ("testComment", "expire").
METHODS
new
This method is called when the server is started, and all plugins are loaded.
This method is mandatory.
name
Return the name of this plugin.
This method is mandatory.
testComment
This method is invoked upon the reception of an incoming comment to test. It is given a hash of options, with notable keys including:
There are two valid return values "OK", which means the comment should be allowed to continue, and "SPAM" which means the plugin has determined the comment to be SPAM.
Optionally the SPAM result may be qualified with a human-readable explanation:
return "SPAM:This comment defames me";
expire
This method is optional.
Some plugins maintain state which must be expired. If this method is implemented it will be invoked upon a regular frequency, with the intention that a plugin may expire its state at that time.
There are two arguments, the first is a handle to the Blog::Sample::Server object, and the second is a frequency label:
- hourly
-
This method has been called once per hour.
- daily
-
This method has been called once per day.
- weekly
-
This method has been called once per week.
logMessage
This method is optional.
This method will be called when the server wishes to log a result of a connection. ie. It will be called once for each received comment at the end of the testComment function.
The message structure, as submitted to testing, will be supplied as a hash, and this hash will contain a couple of additional keys:
- result
-
The result of the test "OK" or "SPAM:[reson]".
- blocker
-
If the result of the test was not "OK" then the name of the plugin which caused the rejection will be saved in this key.
- peer
-
The remote IP address of the client which submitted the message for testing.
AUTHOR
LICENSE
Copyright (c) 2008-2010 by Steve Kemp. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The LICENSE file contains the full text of the license.