Documentation
¶
Index ¶
- func NewSqliteDB(file string) (*sqlx.DB, error)
- type ApprovedUsers
- type DetectedSpam
- type DetectedSpamInfo
- type Locator
- func (l *Locator) AddMessage(msg string, chatID, userID int64, userName string, msgID int) error
- func (l *Locator) AddSpam(userID int64, checks []spamcheck.Response) error
- func (l *Locator) Close() error
- func (l *Locator) Message(msg string) (MsgMeta, bool)
- func (l *Locator) MsgHash(msg string) string
- func (l *Locator) Spam(userID int64) (SpamData, bool)
- func (l *Locator) UserIDByName(userName string) int64
- func (l *Locator) UserNameByID(userID int64) string
- type MsgMeta
- type SpamData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApprovedUsers ¶
type ApprovedUsers struct {
// contains filtered or unexported fields
}
ApprovedUsers is a storage for approved users ids
func NewApprovedUsers ¶
func NewApprovedUsers(db *sqlx.DB) (*ApprovedUsers, error)
NewApprovedUsers creates a new ApprovedUsers storage
func (*ApprovedUsers) Delete ¶ added in v1.5.1
func (au *ApprovedUsers) Delete(id string) error
Delete deletes the given id from the storage
type DetectedSpam ¶ added in v1.7.0
type DetectedSpam struct {
// contains filtered or unexported fields
}
DetectedSpam is a storage for detected spam entries
func NewDetectedSpam ¶ added in v1.7.0
func NewDetectedSpam(db *sqlx.DB) (*DetectedSpam, error)
NewDetectedSpam creates a new DetectedSpam storage
func (*DetectedSpam) Read ¶ added in v1.7.0
func (ds *DetectedSpam) Read() ([]DetectedSpamInfo, error)
Read returns all detected spam entries
func (*DetectedSpam) SetAddedToSamplesFlag ¶ added in v1.10.0
func (ds *DetectedSpam) SetAddedToSamplesFlag(id int64) error
SetAddedToSamplesFlag sets the added flag to true for the detected spam entry with the given id
func (*DetectedSpam) Write ¶ added in v1.7.0
func (ds *DetectedSpam) Write(entry DetectedSpamInfo, checks []spamcheck.Response) error
Write adds a new detected spam entry
type DetectedSpamInfo ¶ added in v1.7.0
type DetectedSpamInfo struct { ID int64 `db:"id"` Text string `db:"text"` UserID int64 `db:"user_id"` UserName string `db:"user_name"` Timestamp time.Time `db:"timestamp"` Added bool `db:"added"` // added to samples ChecksJSON string `db:"checks"` // Store as JSON Checks []spamcheck.Response `db:"-"` // Don't store in DB }
DetectedSpamInfo represents information about a detected spam entry.
type Locator ¶ added in v1.3.0
type Locator struct {
// contains filtered or unexported fields
}
Locator stores messages metadata and spam results for a given ttl period. It is used to locate the message in the chat by its hash and to retrieve spam check results by userID. Useful to match messages from admin chat (only text available) to the original message and to get spam results using UserID.
func NewLocator ¶ added in v1.3.0
NewLocator creates new Locator. ttl defines how long to keep messages in db, minSize defines the minimum number of messages to keep
func (*Locator) AddMessage ¶ added in v1.3.0
AddMessage adds messages to the locator and also cleans up old messages.
func (*Locator) AddSpam ¶ added in v1.3.0
AddSpam adds spam data to the locator and also cleans up old spam data.
func (*Locator) Message ¶ added in v1.3.0
Message returns message MsgMeta for given msg this allows to match messages from admin chat (only text available) to the original message
func (*Locator) MsgHash ¶ added in v1.3.0
MsgHash returns sha256 hash of a message we use hash to avoid storing potentially long messages and all we need is just match
func (*Locator) UserIDByName ¶ added in v1.5.0
UserIDByName returns user id by username. Returns 0 if not found
func (*Locator) UserNameByID ¶ added in v1.5.0
UserNameByID returns username by user id. Returns empty string if not found