akismet
A GO Akismet client, made for easy use and testing
$ go get github.com/Alkemic/akismet
Validate you key:
akismetClient, _ := akismet.NewClient("akismet-key", "http://some-blog.com")
ctx := context.Background()
validated, err := akismetClient.Valid(ctx)
if err != nil {
// handle error
}
Check if comment is a SPAM:
akismetClient, _ := akismet.NewClient("akismet-key", "http://some-blog.com")
ctx := context.Background()
isSpam, err := akismetClient.Check(ctx, &akismet.Comment{
Type: "comment",
Author: "John Doe",
UserIP: "1.2.3.4",
})
if err != nil {
// handle error
}
Submit SPAM:
akismetClient, _ := akismet.NewClient("akismet-key", "http://some-blog.com")
ctx := context.Background()
err := akismetClient.SubmitSpam(ctx, &akismet.Comment{
Type: "comment",
Author: "John Doe",
UserIP: "1.2.3.4",
})
if err != nil {
// handle error
}
Submit HAM (aka false positive):
akismetClient, _ := akismet.NewClient("akismet-key", "http://some-blog.com")
ctx := context.Background()
err := akismetClient.SubmitHam(ctx, &akismet.Comment{
Type: "comment",
Author: "John Doe",
UserIP: "1.2.3.4",
})
if err != nil {
// handle error
}
You can use your own http.Client
instance with calls to API, just use WithHttpClient
functional option:
customHttpClient := &http.Client{
// your options here
}
akismet.NewClient("akismet-key", "http://some-blog.com", WithHttpClient(customHttpClient))