akismet

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2022 License: MIT Imports: 8 Imported by: 0

README

go-akismet

Go library for accessing the Akismet API

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// HTTPClient is underlying http client.
	// If it is nil, http.DefaultClient is used.
	HTTPClient HTTPClient

	// UserAgent is User-Agent header of requests.
	UserAgent string

	// APIKey is an API Key for using Akismet API.
	APIKey string

	// BaseURL is the endpoint of Akismet API.
	// If is is empty, https://rest.akismet.com/1.1/ is used.
	BaseURL string
}

func (*Client) CheckComment

func (c *Client) CheckComment(ctx context.Context, comment *Comment) (*Result, error)

func (*Client) SubmitHam

func (c *Client) SubmitHam(ctx context.Context, comment *Comment) error

SubmitHam submits false-positives - items that were incorrectly classified as spam by Akismet.

func (*Client) SubmitSpam

func (c *Client) SubmitSpam(ctx context.Context, comment *Comment) error

SubmitSpam submits comments that weren’t marked as spam but should have been.

func (*Client) VerifyKey

func (c *Client) VerifyKey(ctx context.Context, blog string) error

type Comment

type Comment struct {
	// Blog is The front page or home URL of the instance making the request.
	// For a blog or wiki this would be the front page. Note: Must be a full URI, including http://.
	Blog string

	// UserIP is IP address of the comment submitter.
	UserIP string

	// UserAgent is the user agent string of the web browser submitting the comment.
	// Typically the HTTP_USER_AGENT cgi variable. Not to be confused with the user agent of your Akismet library.
	UserAgent string

	// Referrer is the content of the HTTP_REFERER header should be sent here.
	Referrer string

	// Permalink is the full permanent URL of the entry the comment was submitted to.
	Permalink string

	// CommentType is a string that describes the type of content being sent.
	CommentType CommentType

	// CommentAuthor is name submitted with the comment.
	CommentAuthor string

	// CommentAuthorEmail is Email address submitted with the comment.
	CommentAuthorEmail string

	// CommentAuthorURL is URL submitted with comment.
	// Only send a URL that was manually entered by the user,
	// not an automatically generated URL like the user’s profile URL on your site.
	CommentAuthorURL string

	// CommentContent is the content that was submitted.
	CommentContent string

	// The UTC timestamp of the creation of the comment, in ISO 8601 format.
	// May be omitted for comment-check requests if the comment is sent to the API at the time it is created.
	CommentDate time.Time

	// CommentPostModified is the UTC timestamp of the publication time for the post, page or thread on which the comment was posted.
	CommentPostModified time.Time

	// BlogLang indicates the language(s) in use on the blog or site,
	// in ISO 639-1 format, comma-separated. A site with articles in English and French might use “en, fr_ca”.
	BlogLang string

	// BlogCharset is the character encoding for the form values included
	// in comment_* parameters, such as “UTF-8” or “ISO-8859-1”.
	BlogCharset string

	// UserRole is the user role of the user who submitted the comment.
	// This is an optional parameter. If you set it to “administrator”, Akismet will always return false.
	UserRole string

	// IsTest is an optional parameter. You can use it when submitting test queries to Akismet.
	IsTest bool

	RecheckReason string

	HoneypotFieldName string
}

type CommentType

type CommentType string
const (
	// CommentTypeComment is a blog comment.
	CommentTypeComment CommentType = "comment"

	// CommentTypeForumPost is a top-level forum post.
	CommentTypeForumPost CommentType = "forum-post"

	// CommentTypeReply is reply to a top-level forum post.
	CommentTypeReply CommentType = "reply"

	// CommentTypeBlogPost is a blog post.
	CommentTypeBlogPost CommentType = "blog-post"

	// CommentTypeContactForm is a contact form or feedback form submission.
	CommentTypeContactForm CommentType = "contact-form"

	// CommentTypeSignUp is new user account.
	CommentTypeSignUp CommentType = "signup"

	// CommentTypeMessage is a message sent between just a few users.
	CommentTypeMessage CommentType = "message"
)

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is a interface for http client.

type Result

type Result struct {
	Spam bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL