Skip to content

Commit

Permalink
0.0.2 version, minor fixes; error handling and package.json fix for npm
Browse files Browse the repository at this point in the history
  • Loading branch information
Humantech Gestao do Conhecimento committed Mar 13, 2012
1 parent c797f67 commit cd66f89
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 49 deletions.
16 changes: 11 additions & 5 deletions README.md
Expand Up @@ -9,16 +9,16 @@ Based on the SpamAssassin plugin from [Haraka](http://haraka.github.com/).
var Spamd = require("node-spamd");
var spamd = new Spamd(sender, receiver, host, port);

spamd.evaluate(subject, message, function(res){
spamd.evaluate(subject, message, function(res, err){

if(typeof res !== 'undefined'){
if(res.spam){
if(err) {
console.log(err);
} else {
if(res.spam) {
console.log('The message is Spam, is evaluated with ' + res.evaluation + " points in a maximun of " + res.allowed);
}else{
console.log('The message is not Spam, is evaluated with ' + res.evaluation + " points in a maximun of " + res.allowed);
}
}else{
console.log('Some error ocurred.');
}
});

Expand All @@ -37,6 +37,12 @@ The method returns an object, with the following attributes:
<br/>**evaluation** = Number or points or hits, that the message has obtained.
<br/>**allowed** = Configured minimal required points for SpamAssassin mark the message as SPAM. This is a spamd setting.

## TODO

* document source code;
* real documentation;
* jsHint standards.

## License

Copyright (C) 2012 Humantech
Expand Down
23 changes: 9 additions & 14 deletions examples/spamd.js
@@ -1,19 +1,14 @@
var Spamd = require("../lib/spamd");
var spamd = new Spamd('from@yourdomain.com', 'to@anotherdomain.com', 'localhost', 783);

var subject = 'Test Subject';
var message = 'test content.';

spamd.evaluate(subject, message, function(res){

if(typeof res !== 'undefined'){
if(res.spam){
var Spamd = require("node-spamd"),
spamd = new Spamd(sender, receiver, host, port);

spamd.evaluate(subject, message, function(res, err){
if (err) {
console.log(err);
} else {
if (res.spam) {
console.log('The message is Spam, is evaluated with ' + res.evaluation + " points in a maximun of " + res.allowed);
}else{
} else {
console.log('The message is not Spam, is evaluated with ' + res.evaluation + " points in a maximun of " + res.allowed);
}
}else{
console.log('Some error ocurred.');
}

});
59 changes: 39 additions & 20 deletions package.json
@@ -1,22 +1,41 @@
{ "name": "node-spamd"
, "version": "0.0.1"
, "engines": [ "node >=0.4.0" ]
, "description": "SpamAssassin message evaluator for node.js"
, "author": "Thomas Alexander Ewald <thomas@humantech.com.br>"
, "contributors": [
{ "name": "Guilherme Henrique de Oliveira", "email": "guilherme@humantech.com.br" }
]
, "keywords" : [ "spam", "evaluation", "spamassassin", "score" ]
, "repository":{
"type": "git"
, "url": "https://github.com/humantech/node-spamd.git"
}
, "bin" : { "spamd" : "./bin/spamd.js" }
, "scripts": {
{
"name": "node-spamd",
"version": "0.0.2",
"engines": [
"node >=0.4.0"
],
"description": "SpamAssassin message evaluator for node.js",
"author": {
"name" : "Humantech Gestao do Conhecimento",
"email" : "admin@humantech.com.br",
"web" : "http://www.humantech.com.br/",
"twitter" : "humantech_"
},
"contributors": [
"Guilherme Henrique de Oliveira <guilherme@humantech.com.br>",
"Thomas Alexander Ewald <thomas@humantech.com.br>
],
"license" : {
"type" : "MIT"
},
"keywords": [
"spam",
"evaluation",
"spamassassin",
"score"
],
"repository": {
"type": "git",
"url": "git://github.com/humantech/node-spamd.git"
},
"scripts": {
"test": "vows --spec"
}
, "directories" : {
"bin": "./bin"
}
, "main": "./lib/spamd.js"
},
"directories" : {
"examples" : "examples"
},
"main": "./lib/spamd.js",
"dependencies": {},
"devDependencies": {},
"optionalDependencies": {}
}
20 changes: 10 additions & 10 deletions test/spamd-tests.js
Expand Up @@ -2,19 +2,19 @@ var assert = require('assert'),
vows = require('vows'),
spamd = require("../lib/spamd");

var host = '10.1.1.3';
var port = 783;
var host = 'localhost',
port = 783;

var sender = 'guilherme@humantech.com.br';
var receiver = 'thomas@humantech.com.br';
var sender = 'from@yourdomain.com',
receiver = 'to@anotherdomain.com';

var Spamd = new spamd(sender, receiver, host, port);

var spamSubject = 'Buy Cialis, viagra';
var spamMessage = 'enlarge your penis\r\n boobs\r\n meet sexy teens tonight! \r\n';
var spamSubject = 'Viagra, Cialis, Vicodin: buy medicines without prescription! CHEAPEST PRICE!',
spamMessage = 'Cheap prices on viagra, cialis, vicodin! FPA approved! High quality is guaranteed!\n\rGet your medicine without prescription, online! Loose weight, gain strenght.\n\r\n\rWord at home and get a lot of money! See it for yourself!\n\rThis message is not a spam.\n\rTake a look at my pictures! Your forgot it on my cellphone.\n\r<a href="http://moxpage.info/get-paid-taking-surveys.html">Visit your Yahoo Group now</a>';

var cleanSubject = 'Test';
var cleanMessage = 'This is a test message.\r\n';
var cleanSubject = 'Test',
cleanMessage = 'This is a test message.\r\n';

vows.describe('node-spamd').addBatch({
'Validating' : {
Expand All @@ -31,11 +31,11 @@ vows.describe('node-spamd').addBatch({
var self = this;
setTimeout(function(){
Spamd.evaluate(spamSubject, spamMessage, self.callback);
}, 1000);
}, 2000);
},
'Message should be marked as SPAM': function(response, error) {
assert.equal(response.spam, true);
}
}
}
}).export(module);
}).export(module);

0 comments on commit cd66f89

Please sign in to comment.