Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChecksToString ¶
ChecksToString converts a slice of checks to a string
Types ¶
type LastRequests ¶
type LastRequests struct {
// contains filtered or unexported fields
}
LastRequests keeps track of last N requests, thread-safe.
func NewLastRequests ¶
func NewLastRequests(size int) *LastRequests
NewLastRequests creates new requests tracker
func (*LastRequests) Last ¶
func (h *LastRequests) Last(n int) []Request
Last returns up to n last requests in chronological order (oldest to newest)
func (*LastRequests) Push ¶
func (h *LastRequests) Push(req Request)
Push adds new request to the history
func (*LastRequests) Size ¶
func (h *LastRequests) Size() int
Size returns the size of request history
type MetaData ¶
type MetaData struct {
Images int `json:"images"` // number of images in the message
Links int `json:"links"` // number of links in the message
Mentions int `json:"mentions"` // number of mentions (@username) 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
HasKeyboard bool `json:"has_keyboard"` // true if the message has a keyboard (buttons)
HasContact bool `json:"has_contact"` // true if the message has a shared contact
HasGiveaway bool `json:"has_giveaway"` // true if the message is a giveaway
HasSticker bool `json:"has_sticker"` // true if the message has a sticker
MessageID int `json:"message_id"` // telegram message ID
}
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
FirstName string `json:"first_name"` // user's first name
LastName string `json:"last_name"` // user's last name
IsPremium bool `json:"is_premium"` // true if user has telegram premium
Meta MetaData `json:"meta"` // meta-info, provided by the client
CheckOnly bool `json:"check_only"` // if true, only check, don't write approved user
ForceLLM bool `json:"force_llm"` // force LLM review
LLMContext string `json:"llm_context"` // extra moderation context for LLM
LLMMessage string `json:"llm_message,omitempty"` // message text formatted for LLM, if different from Msg
HistoryMsg string `json:"history_msg,omitempty"` // author text to keep in LLM chat history
ImageData []byte `json:"-"` // downloaded image bytes for vision analysis
ImageMIME string `json:"-"` // MIME type of the image (e.g. "image/jpeg")
}
Request is a request to check a message for spam.
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
ExtraDeleteIDs []int `json:"extra_delete_ids,omitempty"` // additional message IDs to delete when spam detected
Score float64 `json:"score,omitempty"` // signal strength 0.0-1.0 (1.0 for deterministic)
Weight float64 `json:"weight,omitempty"` // signal weight for aggregation (default 1.0)
RuleID string `json:"rule_id,omitempty"` // structured rule identifier (e.g. "stopword", "meta-links")
NormalizedText string `json:"normalized_text,omitempty"` // matched text snippet after normalization (truncated 64 chars)
}
Response is a result of spam check.
type RiskScore ¶
type RiskScore struct {
Total float64 `json:"total"` // weighted sum of all spam signal scores
Signals []Response `json:"signals"` // all signals that contributed
Decision bool `json:"decision"` // true if total >= threshold
Reason string `json:"reason,omitempty"` // human-readable explanation
}
RiskScore is the aggregated scoring result from all detector signals.
Click to show internal directories.
Click to hide internal directories.