spamcheck

package
v1.16.3 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChecksToString added in v1.15.0

func ChecksToString(checks []Response) string

ChecksToString converts a slice of checks to a string

Types

type LastRequests added in v1.16.0

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

LastRequests keeps track of last N requests, thread-safe.

func NewLastRequests added in v1.16.0

func NewLastRequests(size int) *LastRequests

NewLastRequests creates new requests tracker

func (*LastRequests) Last added in v1.16.0

func (h *LastRequests) Last(n int) []Request

Last returns up to n last requests in chronological order (oldest to newest)

func (*LastRequests) Push added in v1.16.0

func (h *LastRequests) Push(req Request)

Push adds new request to the history

func (*LastRequests) Size added in v1.16.0

func (h *LastRequests) Size() int

Size returns the size of request history

type MetaData added in v1.9.0

type MetaData struct {
	Images     int  `json:"images"`      // number of images in the message
	Links      int  `json:"links"`       // number of links in the message
	HasVideo   bool `json:"has_video"`   // true if the message has a video or video note
	HasAudio   bool `json:"has_audio"`   // true if the message has an audio
	HasForward bool `json:"has_forward"` // true if the message has a forward
}

MetaData is a meta-info about the message, provided by the client.

type Request

type Request struct {
	Msg       string   `json:"msg"`        // message to check
	UserID    string   `json:"user_id"`    // user id
	UserName  string   `json:"user_name"`  // user name
	Meta      MetaData `json:"meta"`       // meta-info, provided by the client
	CheckOnly bool     `json:"check_only"` // if true, only check the message, do not write newly approved user to the database
}

Request is a request to check a message for spam.

func (*Request) String added in v1.9.0

func (r *Request) String() string

type Response

type Response struct {
	Name    string `json:"name"`    // name of the check
	Spam    bool   `json:"spam"`    // true if spam
	Details string `json:"details"` // details of the check
	Error   error  `json:"-"`       // error message, if any. Do not serialize it
}

Response is a result of spam check.

func (*Response) String

func (r *Response) String() string

Jump to

Keyboard shortcuts

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