Documentation
¶
Index ¶
- type ChatSettings
- type Database
- func (db *Database) AddUser(userid int64) error
- func (db *Database) ConnectUser(userID, chatID int64)
- func (db *Database) DeleteConnection(userID int64)
- func (db *Database) DeleteMfilter(chatID int64, key string)
- func (db *Database) GetAlert(uniqueID string, index int) string
- func (db *Database) GetCachedSetting(chatID int64) *ChatSettings
- func (db *Database) GetConnection(userID int64) (int64, bool)
- func (db *Database) GetMfilter(chatID int64, key string) (bson.M, bool)
- func (db *Database) GetMfilters(chatID int64) (*mongo.Cursor, error)
- func (db *Database) RecacheSettings(chatID int64)
- func (db *Database) SaveMfilter(data *Filter)
- func (db *Database) SearchMfilterClassic(chatID int64, input string) (results []*Filter)
- func (db *Database) SearchMfilterNew(chatID int64, fields []string, multiFilter bool) (results []*Filter)
- func (db *Database) SetChatSetting(chatID int64, key string, value any)
- func (db *Database) SetDefaultSettings(chatID int64)
- func (db *Database) StartGfilter(chatID int64, key string)
- func (db *Database) Stats() string
- func (db *Database) StopGfilter(chatID int64, key string)
- func (db *Database) StringMfilter(chatID int64) string
- type Filter
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatSettings ¶
type ChatSettings struct { // Stopped Global Filters Stopped []string }
type Database ¶
type Database struct { // Mongo Client Client *mongo.Client // Database DB *mongo.Database // Users Collection Ucol *mongo.Collection // Main Collection Col *mongo.Collection // Manual Filters Collection Mcol *mongo.Collection }
func NewDatabase ¶
func NewDatabase() *Database
func (*Database) ConnectUser ¶
func (*Database) DeleteConnection ¶
func (*Database) DeleteMfilter ¶
func (*Database) GetCachedSetting ¶
func (db *Database) GetCachedSetting(chatID int64) *ChatSettings
func (*Database) GetMfilter ¶
func (*Database) GetMfilters ¶
Returns all manual filters for a chat.
func (*Database) RecacheSettings ¶
A Function To Update Cached Settings With Latest From DB
func (*Database) SaveMfilter ¶
func (*Database) SearchMfilterClassic ¶
SearchMfilterClassic uses the traditional way of fetching mfilters by fetching all mfilters of a chat and doing regex queries individually. This method is more resource intensive but could be faster for large scale bots with several hundred/thousand groups.
func (*Database) SearchMfilterNew ¶
func (db *Database) SearchMfilterNew(chatID int64, fields []string, multiFilter bool) (results []*Filter)
SearchMfilterNew does a regex query on the database shifting some load to mongodb.
func (*Database) SetChatSetting ¶
func (*Database) SetDefaultSettings ¶
func (*Database) StartGfilter ¶
func (*Database) StopGfilter ¶
func (*Database) StringMfilter ¶
type Filter ¶
type Filter struct { // Unique id of the filter ID string `bson:"_id"` // Chat where the filter is in effect ChatID int64 `bson:"group_id"` // The key/text which is filtered Text string `bson:"text"` // The text content/caption saved Content string `bson:"content,omitempty"` // The id of a media saved for the filter if any FileID string `bson:"file,omitempty"` // Buttons/markup saved for a filter if any Markup [][]map[string]string `bson:"button,omitempty"` // Alerts saved for a filter if any Alerts []string `bson:"alert,omitempty"` // Length of the text according to which filters are sorted Length int `bson:"length"` // Type of media saved if any MediaType string `bson:"mediaType,omitempty"` }
A filter object stored in the database
Click to show internal directories.
Click to hide internal directories.