Stable version of node-js port
This commit is contained in:
44
examples/report.go
Normal file
44
examples/report.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go-spamc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
html := "<html><title>Test</title><body>Hello world. I'm not a Spam, don't kill me spamassassin!</body></html>"
|
||||
|
||||
client := spamc.New("127.0.0.1:783", 10)
|
||||
|
||||
//the 2nd parameter is optional, you can set who (the unix user) do the call
|
||||
//looks like client.Report(html, "saintienn")
|
||||
|
||||
reply, err := client.Report(html)
|
||||
|
||||
if err == nil {
|
||||
fmt.Println(reply)
|
||||
} else {
|
||||
fmt.Println(reply, err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Example Response
|
||||
{
|
||||
Code: 0,
|
||||
Message: 'EX_OK',
|
||||
Vars:{
|
||||
isSpam: true,
|
||||
spamScore: 6.9,
|
||||
baseSpamScore: 5,
|
||||
report:[
|
||||
{
|
||||
"score": score,
|
||||
"symbol": x[1],
|
||||
"message": message,
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,30 +0,0 @@
|
||||
/**
|
||||
* User: Carl Glaysher
|
||||
* Date: 17/03/2012
|
||||
* Time: 08:46
|
||||
* Description: Front end to check spamc client
|
||||
*/
|
||||
var spamc = require('./spamc');
|
||||
var client = new spamc();
|
||||
|
||||
client.report('My Message as String',function(result){
|
||||
console.log(result);
|
||||
});
|
||||
|
||||
/* Example Response
|
||||
{
|
||||
responseCode: 0,
|
||||
responseMessage: 'EX_OK',
|
||||
isSpam: true,
|
||||
spamScore: 6.9,
|
||||
baseSpamScore: 5,
|
||||
report:[
|
||||
{
|
||||
score: '0.0',
|
||||
name: 'NO_RELAYS',
|
||||
description: 'Informational',
|
||||
type: 'message'
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user