Test blog/forum comments for spam in real-time.
NOTE: This repository is now obsolete, the current API is implemented by the golang
code in this repository:
This node.js server implements the BlogSpam.net v2 API.
The blogspam API & service allows site-owners to test incoming blog/forum comments for SPAM in real-time.
The original (v1) blogspam API was written in Perl and used XML::RPC as thetransport mechanism, that code is available
on CPAN, but has been depreciated
and replaced by this new API/implementation.
In brief:
SPAM
” or “OK
”.
reason
” which declares the reason for a SPAM result, however these are optional.There are clients for this server-API available for several applications including Trac, IkiWiki, and also a wordpress plugin.
I started the http://blogspam.net/ service a few years ago to handle the spammy
comments which were received upon the Debian Administration website.
The comments that were spammy were a pain to deal with, but at the same
time they weren’t really specific to the site. The idea of abstracting
away the spam testing from the site was appealing.
Since then I’ve added support for the remote service to many other of my sites,
and also made it generally available to the internet at large. The service was
pretty good, but became hard to maintain for two main reasons:
This javascript port of the service replaces the legacy API and suffers
from none of the drawbacks. For compatibility there exists an XML::RPC proxy
but this is no longer deployed live, as the old API has been retired.
I’ve hacked together a minimal Wordpress plugin which will query comments in real-time against the production deployment of this server.
You can find the source code and installation instructions within the github repository:
The API is documented online, and contains three
end-points:
The main API is the spam-testing one, and that is the only one documented here.
The spam-testing API should receive JSON-encoded hash, via a HTTP POST.
Permitted hash fields are:
The server will load a series of plugins on-startup, and each submission will be
passed through the loaded plugins in turn.
Plugins are loaded when the server starts up from beneath:
plugins/
plugins.local/
The individual plugins can handle the results by calling one of the three call-back
methods it receives:
spam
ham
next
A spam or ham result terminates the processing, avoiding later plugins.
NOTE: This means you must have 99-ok.js, or similar plugin, so that the final result is OK.
The actual result of the testing will be returned to the caller in the form of :
result
”, as well as other optional keys.The code is designed to run directly from a git checkout, with no need to install it system-wide. The only service dependency is an instance of the redis which is assumed to run on the localhost.
NOTE: You can specify the address of your redis-server in the
config.js
file if it runs on a different host/port.
The server relies upon a small number of node.js
libraries, which you can install with:
$ npm install
Now you’ve installed the dependencies you can launch the server.
In one terminal run the main script:
node server.js
In another run the test-cases by running:
cd ./tests/
./run-tests
This will fire off some pre-cooked comments, and compare the results of the testing
against the expected result. If you see errors which are surprising then you can
run a single case explicitly:
./run-tests --test ./exclude-plugins.test [--verbose]
There are a couple of perl utility scripts located beneath ./utils
. In brief these are:
dump
stats
submitJSON