Documentation ¶
Overview ¶
Package webapi provides a web API spam detection service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomPassword ¶
GenerateRandomPassword generates a random password of a given length
Types ¶
type Config ¶
type Config struct { Version string // version to show in /ping ListenAddr string // listen address Detector Detector // spam detector SpamFilter SpamFilter // spam filter (bot) DetectedSpam DetectedSpam // detected spam accessor Locator Locator // locator for user info AuthPasswd string // basic auth password for user "tg-spam" AuthHash string // basic auth hash for user "tg-spam". If both AuthPasswd and AuthHash are provided, AuthHash is used Dbg bool // debug mode Settings Settings // application settings }
Config defines server parameters
type DetectedSpam ¶ added in v1.10.0
type DetectedSpam interface { Read() ([]storage.DetectedSpamInfo, error) SetAddedToSamplesFlag(id int64) error }
DetectedSpam is a storage interface used to get detected spam messages and set added flag.
type Detector ¶ added in v1.5.0
type Detector interface { Check(req spamcheck.Request) (spam bool, cr []spamcheck.Response) ApprovedUsers() []approved.UserInfo AddApprovedUser(user approved.UserInfo) error RemoveApprovedUser(id string) error }
Detector is a spam detector interface.
type Locator ¶ added in v1.5.0
Locator is a storage interface used to get user id by name and vice versa.
type Settings ¶ added in v1.9.0
type Settings struct { PrimaryGroup string `json:"primary_group"` AdminGroup string `json:"admin_group"` DisableAdminSpamForward bool `json:"disable_admin_spam_forward"` LoggerEnabled bool `json:"logger_enabled"` SuperUsers []string `json:"super_users"` NoSpamReply bool `json:"no_spam_reply"` CasEnabled bool `json:"cas_enabled"` MetaEnabled bool `json:"meta_enabled"` MetaLinksLimit int `json:"meta_links_limit"` MetaLinksOnly bool `json:"meta_links_only"` MetaImageOnly bool `json:"meta_image_only"` MetaVideoOnly bool `json:"meta_video_only"` MultiLangLimit int `json:"multi_lang_limit"` OpenAIEnabled bool `json:"openai_enabled"` SamplesDataPath string `json:"samples_data_path"` DynamicDataPath string `json:"dynamic_data_path"` WatchIntervalSecs int `json:"watch_interval_secs"` SimilarityThreshold float64 `json:"similarity_threshold"` MinMsgLen int `json:"min_msg_len"` MaxEmoji int `json:"max_emoji"` MinSpamProbability float64 `json:"min_spam_probability"` ParanoidMode bool `json:"paranoid_mode"` FirstMessagesCount int `json:"first_messages_count"` StartupMessageEnabled bool `json:"startup_message_enabled"` TrainingEnabled bool `json:"training_enabled"` }
Settings contains all application settings
type SpamFilter ¶
type SpamFilter interface { UpdateSpam(msg string) error UpdateHam(msg string) error ReloadSamples() (err error) DynamicSamples() (spam, ham []string, err error) RemoveDynamicSpamSample(sample string) (int, error) RemoveDynamicHamSample(sample string) (int, error) }
SpamFilter is a spam filter, bot interface.
Click to show internal directories.
Click to hide internal directories.