anti_spam

package
v0.0.0-...-fbd1cd9 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const LOG_TAG = "[AntiSpam]"

Variables

This section is empty.

Functions

This section is empty.

Types

type AkismetChecker

type AkismetChecker struct {
	// contains filtered or unexported fields
}

func (*AkismetChecker) Check

func (c *AkismetChecker) Check(p *CheckerParams) (bool, error)

func (*AkismetChecker) Name

func (*AkismetChecker) Name() string

type AkismetReqParams

type AkismetReqParams struct {
	Blog      string `name:"blog"`       // required
	UserIP    string `name:"user_ip"`    // required
	UserAgent string `name:"user_agent"` // required

	CommentType        string `name:"comment_type"`
	CommentAuthor      string `name:"comment_author"`
	CommentAuthorEmail string `name:"comment_author_email"`
	CommentAuthorURL   string `name:"comment_author_url"`
	CommentContent     string `name:"comment_content"`

	UserRole    string `name:"user_role"`
	Referrer    string `name:"referrer"`
	Permalink   string `name:"permalink"`
	BlogLang    string `name:"blog_lang"`
	BlogCharset string `name:"blog_charset"`
}

type AliyunChecker

type AliyunChecker struct {
	AccessKeyID     string
	AccessKeySecret string
	Region          string
}

func (*AliyunChecker) Check

func (c *AliyunChecker) Check(p *CheckerParams) (bool, error)

阿里云反垃圾 @link https://help.aliyun.com/document_detail/70409.html @link https://help.aliyun.com/document_detail/107743.html 接入地址

func (*AliyunChecker) Name

func (*AliyunChecker) Name() string

type AntiSpam

type AntiSpam struct {
	// contains filtered or unexported fields
}

func NewAntiSpam

func NewAntiSpam(conf *AntiSpamConf) *AntiSpam

Create new AntiSpam instance

func (AntiSpam) CheckAndBlock

func (as AntiSpam) CheckAndBlock(params *CheckerParams)

Check and block comment if it is spam, the function is exposed and can be called by other modules

type AntiSpamConf

type AntiSpamConf struct {
	config.ModeratorConf

	OnBlockComment  func(commentID uint)
	OnUpdateComment func(commentID uint, content string)
}

type Checker

type Checker interface {
	Name() string
	Check(p *CheckerParams) (bool, error)
}

func NewAkismetChecker

func NewAkismetChecker(key string) Checker

func NewAliyunChecker

func NewAliyunChecker(accessKeyID, accessKeySecret, region string) Checker

func NewTencentChecker

func NewTencentChecker(secretID, secretKey, region string) Checker

type CheckerParams

type CheckerParams struct {
	BlogURL string

	Content   string
	CommentID uint

	UserName  string
	UserEmail string
	UserID    uint
	UserIP    string
	UserAgent string
}

type KeywordsChecker

type KeywordsChecker struct {
	// contains filtered or unexported fields
}

func NewKeywordsChecker

func NewKeywordsChecker(conf *KeywordsCheckerConf) *KeywordsChecker

func (*KeywordsChecker) Check

func (c *KeywordsChecker) Check(p *CheckerParams) (bool, error)

func (*KeywordsChecker) Name

func (*KeywordsChecker) Name() string

type KeywordsCheckerConf

type KeywordsCheckerConf struct {
	Files           []string
	FileSep         string
	ReplaceTo       string
	Mode            KwCheckerMode
	OnUpdateComment func(commentID uint, content string)
}

type KwCheckerMode

type KwCheckerMode int
const (
	KwCheckerModeBlock   KwCheckerMode = iota // 仅拦截
	KwCheckerModeReplace                      // 仅替换关键词
)

type TencentChecker

type TencentChecker struct {
	SecretID  string
	SecretKey string
	Region    string
}

func (*TencentChecker) Check

func (c *TencentChecker) Check(p *CheckerParams) (bool, error)

腾讯云文本内容安全 TMS @link https://cloud.tencent.com/document/product/1124/51860 @link https://console.cloud.tencent.com/cms/text/overview

func (*TencentChecker) Name

func (*TencentChecker) Name() string

Jump to

Keyboard shortcuts

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