db

package
v0.0.0-...-f0180c5 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TEXT types of senders
	TEXT      int = 1
	STICKER   int = 2
	DOCUMENT  int = 3
	PHOTO     int = 4
	AUDIO     int = 5
	VOICE     int = 6
	VIDEO     int = 7
	VideoNote int = 8
)
View Source
const (
	DefaultWelcome = "Hey {first}, how are you?"
	DefaultGoodbye = "Sad to see you leaving {first}"
)

default strings when no settings are set

Variables

This section is empty.

Functions

func AddBlacklist

func AddBlacklist(chatId int64, trigger string)

func AddDev

func AddDev(userID int64)

func AddFilter

func AddFilter(chatID int64, keyWord, replyText, fileID string, buttons []Button, filtType int)

func AddNote

func AddNote(chatID int64, noteName, replyText, fileID string, buttons []Button, filtType int, pvtOnly, grpOnly, adminOnly, webPrev, isProtected, noNotif bool)

func AddSudo

func AddSudo(userID int64)

func BlockReportUser

func BlockReportUser(chatId, userId int64)

func ChangeGroupLanguage

func ChangeGroupLanguage(GroupID int64, lang string)

func ChangeUserLanguage

func ChangeUserLanguage(UserID int64, lang string)

func ConnectId

func ConnectId(UserID, chatID int64)

func CountFilters

func CountFilters(chatID int64) (filtersNum int64)

func DisableCMD

func DisableCMD(chatID int64, cmd string)

DisableCMD Disable CMD in chat

func DisconnectId

func DisconnectId(UserID int64)

func DoesFilterExists

func DoesFilterExists(chatId int64, keyword string) bool

func DoesNoteExists

func DoesNoteExists(chatID int64, noteName string) bool

func EnableCMD

func EnableCMD(chatID int64, cmd string)

EnableCMD Enable CMD in chat

func EnsureBotInDb

func EnsureBotInDb(b *gotgbot.Bot)

func GetAllChatWarns

func GetAllChatWarns(chatId int64) int

func GetAllChats

func GetAllChats() map[int64]Chat

func GetChannelIdByUserName

func GetChannelIdByUserName(username string) int64

func GetChannelInfoById

func GetChannelInfoById(userId int64) (username, name string, found bool)

func GetChatDisabledCMDs

func GetChatDisabledCMDs(chatId int64) []string

GetChatDisabledCMDs Get disabled comands of chat

func GetFiltersList

func GetFiltersList(chatID int64) (allFilterWords []string)

func GetLanguage

func GetLanguage(ctx *ext.Context) string

func GetNotesList

func GetNotesList(chatID int64, admin bool) (allNotes []string)

func GetTeamMembers

func GetTeamMembers() map[int64]string

func GetUserIdByUserName

func GetUserIdByUserName(username string) int64

func GetUserInfoById

func GetUserInfoById(userId int64) (username, name string, found bool)

func GetWarns

func GetWarns(userId, chatId int64) (int, []string)

func IsCommandDisabled

func IsCommandDisabled(chatId int64, cmd string) bool

IsCommandDisabled Check if command is disabled or not

func IsPermLocked

func IsPermLocked(chatID int64, perm string) bool

func LoadAllStats

func LoadAllStats() string

func LoadAntifloodStats

func LoadAntifloodStats() (antiCount int64)

func LoadBlacklistsStats

func LoadBlacklistsStats() (blacklistTriggers, blacklistChats int64)

func LoadChannelStats

func LoadChannelStats() (count int64)

func LoadChatStats

func LoadChatStats() (activeChats, inactiveChats int)

func LoadConnectionStats

func LoadConnectionStats() (connectedUsers, connectedChats int64)

func LoadDisableStats

func LoadDisableStats() (disabledCmds, disableEnabledChats int64)

func LoadFilterStats

func LoadFilterStats() (filtersNum, filtersUsingChats int64)

func LoadGreetingsStats

func LoadGreetingsStats() (enabledWelcome, enabledGoodbye, cleanServiceEnabled, cleanWelcomeEnabled, cleanGoodbyeEnabled int64)

func LoadNotesStats

func LoadNotesStats() (notesNum, notesUsingChats int64)

func LoadPinStats

func LoadPinStats() (acCount, clCount int64)

func LoadReportStats

func LoadReportStats() (uRCount, gRCount int64)

func LoadRulesStats

func LoadRulesStats() (setRules, pvtRules int64)

func LoadUsersStats

func LoadUsersStats() (count int64)

func MapLockType

func MapLockType(locks Locks) map[string]bool

func ReconnectId

func ReconnectId(UserID int64) int64

func RemDev

func RemDev(userID int64)

func RemSudo

func RemSudo(userID int64)

func RemoveAllBlacklist

func RemoveAllBlacklist(chatId int64)

func RemoveAllFilters

func RemoveAllFilters(chatID int64)

func RemoveAllNotes

func RemoveAllNotes(chatID int64)

func RemoveBlacklist

func RemoveBlacklist(chatId int64, trigger string)

func RemoveFilter

func RemoveFilter(chatID int64, keyWord string)

func RemoveNote

func RemoveNote(chatID int64, noteName string)

func RemoveWarn

func RemoveWarn(userId, chatId int64) bool

func ResetAllChatWarns

func ResetAllChatWarns(chatId int64) bool

func ResetUserWarns

func ResetUserWarns(userId, chatId int64) (removed bool)

func SetAnonAdminMode

func SetAnonAdminMode(chatID int64, val bool)

SetAnonAdminMode Set anon admin mode for a chat

func SetAntiChannelPin

func SetAntiChannelPin(chatID int64, pref bool)

func SetBlacklistAction

func SetBlacklistAction(chatId int64, action string)

func SetChatReportStatus

func SetChatReportStatus(chatID int64, pref bool)

func SetChatRules

func SetChatRules(chatId int64, rules string)

func SetChatRulesButton

func SetChatRulesButton(chatId int64, rulesButton string)

func SetCleanGoodbyeMsgId

func SetCleanGoodbyeMsgId(chatId, msgId int64)

func SetCleanGoodbyeSetting

func SetCleanGoodbyeSetting(chatID int64, pref bool)

func SetCleanLinked

func SetCleanLinked(chatID int64, pref bool)

func SetCleanWelcomeMsgId

func SetCleanWelcomeMsgId(chatId, msgId int64)

func SetCleanWelcomeSetting

func SetCleanWelcomeSetting(chatID int64, pref bool)

func SetFlood

func SetFlood(chatID int64, limit int)

SetFlood set Flood Setting for a Chat

func SetFloodMode

func SetFloodMode(chatID int64, mode string)

SetFloodMode Set flood mode for a chat

func SetFloodMsgDel

func SetFloodMsgDel(chatID int64, val bool)

SetFloodMsgDel Set flood mode for a chat

func SetGoodbyeText

func SetGoodbyeText(chatID int64, goodbyetext, fileId string, buttons []Button, goodbyeType int)

func SetGoodbyeToggle

func SetGoodbyeToggle(chatID int64, pref bool)

func SetPrivateRules

func SetPrivateRules(chatId int64, pref bool)

func SetShouldAutoApprove

func SetShouldAutoApprove(chatID int64, pref bool)

func SetShouldCleanService

func SetShouldCleanService(chatID int64, pref bool)

func SetUserReportSettings

func SetUserReportSettings(chatID int64, pref bool)

func SetWarnLimit

func SetWarnLimit(chatId int64, warnLimit int)

func SetWarnMode

func SetWarnMode(chatId int64, warnMode string)

func SetWelcomeText

func SetWelcomeText(chatID int64, welcometxt, fileId string, buttons []Button, welcType int)

func SetWelcomeToggle

func SetWelcomeToggle(chatID int64, pref bool)

func ShouldDel

func ShouldDel(chatId int64) bool

ShouldDel Check if cmd del is enabled or not

func ToggleAllowConnect

func ToggleAllowConnect(chatID int64, pref bool)

func ToggleDel

func ToggleDel(chatId int64, pref bool)

ToggleDel Toogle Command Deleting

func ToggleInactiveChat

func ToggleInactiveChat(chatId int64, toggle bool)

func TooglePrivateNote

func TooglePrivateNote(chatID int64, pref bool)

func UnblockReportUser

func UnblockReportUser(chatId, userId int64)

func UpdateChannel

func UpdateChannel(channelId int64, channelName, username string)

func UpdateChat

func UpdateChat(chatId int64, chatname string, userid int64)

func UpdateLock

func UpdateLock(chatID int64, perm string, val bool)

UpdateLock Modify the value of Locks struct and update it in database

func UpdateUser

func UpdateUser(userId int64, username, name string)

func WarnUser

func WarnUser(userId, chatId int64, reason string) (int, []string)

Types

type AdminSettings

type AdminSettings struct {
	ChatId    int64 `bson:"_id,omitempty" json:"_id,omitempty"`
	AnonAdmin bool  `bson:"anon_admin" json:"anon_admin"`
}

AdminSettings Flood Settings struct for chat

func GetAdminSettings

func GetAdminSettings(chatID int64) *AdminSettings

GetAdminSettings Get admin settings for a chat

type BlacklistSettings

type BlacklistSettings struct {
	ChatId   int64    `bson:"_id,omitempty" json:"_id,omitempty"`
	Action   string   `bson:"action,omitempty" json:"action,omitempty"`
	Triggers []string `bson:"triggers,omitempty" json:"triggers,omitempty"`
	Reason   string   `bson:"reason,omitempty" json:"reason,omitempty"`
}

BlacklistSettings Flood Control struct for user

func GetBlacklistSettings

func GetBlacklistSettings(chatId int64) *BlacklistSettings

type Button

type Button struct {
	Name     string `bson:"name,omitempty" json:"name,omitempty"`
	Url      string `bson:"url,omitempty" json:"url,omitempty"`
	SameLine bool   `bson:"btn_sameline" json:"btn_sameline" default:"false"`
}

func GetGoodbyeButtons

func GetGoodbyeButtons(chatId int64) []Button

func GetWelcomeButtons

func GetWelcomeButtons(chatId int64) []Button

type Channel

type Channel struct {
	ChannelId   int64  `bson:"_id,omitempty" json:"_id,omitempty"`
	ChannelName string `bson:"channel_name" json:"channel_name" default:"nil"`
	Username    string `bson:"username" json:"username" default:"nil"`
}

func GetChannelSettings

func GetChannelSettings(channelId int64) (channelSrc *Channel)

type Chat

type Chat struct {
	ChatId     int64   `bson:"_id,omitempty" json:"_id,omitempty"`
	ChatName   string  `bson:"chat_name" json:"chat_name" default:"nil"`
	Language   string  `bson:"language" json:"language" default:"nil"`
	Users      []int64 `bson:"users" json:"users" default:"nil"`
	IsInactive bool    `bson:"is_inactive" json:"is_inactive" default:"false"`
}

func GetChatSettings

func GetChatSettings(chatId int64) (chatSrc *Chat)

type ChatFilters

type ChatFilters struct {
	ChatId      int64    `bson:"chat_id,omitempty" json:"chat_id,omitempty"`
	KeyWord     string   `bson:"keyword,omitempty" json:"keyword,omitempty"`
	FilterReply string   `bson:"filter_reply,omitempty" json:"filter_reply,omitempty"`
	MsgType     int      `bson:"msgtype,omitempty" json:"msgtype,omitempty"`
	FileID      string   `bson:"fileid,omitempty" json:"fileid,omitempty"`
	NoNotif     bool     `bson:"nonotif,omitempty" json:"nonotif,omitempty"`
	Buttons     []Button `bson:"filter_buttons,omitempty" json:"filter_buttons,omitempty"`
}

func GetAllFilters

func GetAllFilters(chatID int64) (allFilters []*ChatFilters)

func GetFilter

func GetFilter(chatID int64, keyword string) (filtSrc *ChatFilters)

type ChatNotes

type ChatNotes struct {
	ChatId      int64    `bson:"chat_id,omitempty" json:"chat_id,omitempty"`
	NoteName    string   `bson:"note_name,omitempty" json:"note_name,omitempty"`
	NoteContent string   `bson:"note_content,omitempty" json:"note_content,omitempty"`
	MsgType     int      `bson:"msgtype" json:"msgtype" default:"1"`
	FileID      string   `bson:"fileid,omitempty" json:"fileid,omitempty"`
	PrivateOnly bool     `bson:"private_only,omitempty" json:"private_only,omitempty"`
	GroupOnly   bool     `bson:"group_only,omitempty" json:"group_only,omitempty"`
	AdminOnly   bool     `bson:"admin_only,omitempty" json:"admin_only,omitempty"`
	WebPreview  bool     `bson:"webpreview,omitempty" json:"webpreview,omitempty"`
	IsProtected bool     `bson:"is_protected,omitempty" json:"is_protected,omitempty"`
	NoNotif     bool     `bson:"no_notif,omitempty" json:"no_notif,omitempty"`
	Buttons     []Button `bson:"note_buttons,omitempty" json:"note_buttons,omitempty"`
}

func GetNote

func GetNote(chatID int64, keyword string) (noteSrc *ChatNotes)

type ChatReportSettings

type ChatReportSettings struct {
	ChatId      int64   `bson:"_id,omitempty" json:"_id,omitempty"`
	Status      bool    `bson:"status,omitempty" json:"status,omitempty"`
	BlockedList []int64 `bson:"blocked_list,omitempty" json:"blocked_list,omitempty"`
}

func GetChatReportSettings

func GetChatReportSettings(chatID int64) (reportsrc *ChatReportSettings)

type ConnectionSettings

type ConnectionSettings struct {
	ChatId       int64 `bson:"_id,omitempty" json:"_id,omitempty"`
	AllowConnect bool  `bson:"can_connect" json:"can_connect" default:"false"`
}

func GetChatConnectionSetting

func GetChatConnectionSetting(chatID int64) (connectionSrc *ConnectionSettings)

type Connections

type Connections struct {
	UserId    int64 `bson:"_id,omitempty" json:"_id,omitempty"`
	ChatId    int64 `bson:"chat_id,omitempty" json:"chat_id,omitempty"`
	Connected bool  `bson:"connected" json:"connected" default:"false"`
}

func Connection

func Connection(UserID int64) *Connections

type DisableCommand

type DisableCommand struct {
	ChatID       int64    `bson:"_id,omitempty" json:"_id,omitempty"`
	Commands     []string `bson:"commands" json:"commands" default:"none"`
	ShouldDelete bool     `bson:"should_delete" json:"should_delete" default:"false"`
}

type FloodSettings

type FloodSettings struct {
	ChatId                 int64  `bson:"_id,omitempty" json:"_id,omitempty"`
	Limit                  int    `bson:"limit" json:"limit"`
	Mode                   string `bson:"mode,omitempty" json:"mode,omitempty"`
	DeleteAntifloodMessage bool   `bson:"del_msg" json:"del_msg"`
}

FloodSettings Flood Settings struct for chat

func GetFlood

func GetFlood(chatID int64) *FloodSettings

GetFlood Get flood settings for a chat

type GoodbyeSettings

type GoodbyeSettings struct {
	CleanGoodbye  bool     `bson:"clean_old" json:"clean_old" default:"false"`
	LastMsgId     int64    `bson:"last_msg_id,omitempty" json:"last_msg_id,omitempty"`
	ShouldGoodbye bool     `bson:"enabled" json:"enabled" default:"true"`
	GoodbyeText   string   `bson:"text,omitempty" json:"text,omitempty"`
	FileID        string   `bson:"file_id,omitempty" json:"file_id,omitempty"`
	GoodbyeType   int      `bson:"type,omitempty" json:"type,omitempty"`
	Button        []Button `bson:"btns,omitempty" json:"btns,omitempty"`
}

type GreetingSettings

type GreetingSettings struct {
	ChatID             int64            `bson:"_id,omitempty" json:"_id,omitempty"`
	ShouldCleanService bool             `bson:"clean_service_settings" json:"clean_service_settings" default:"false"`
	WelcomeSettings    *WelcomeSettings `bson:"welcome_settings" json:"welcome_settings" default:"false"`
	GoodbyeSettings    *GoodbyeSettings `bson:"goodbye_settings" json:"goodbye_settings" default:"false"`
	ShouldAutoApprove  bool             `bson:"auto_approve" json:"auto_approve" default:"false"`
}

func GetGreetingSettings

func GetGreetingSettings(chatID int64) *GreetingSettings

type Locks

type Locks struct {
	ChatId       int64         `bson:"_id,omitempty" json:"_id,omitempty"`
	Permissions  *Permissions  `bson:"permissions,omitempty" json:"permissions,omitempty"`
	Restrictions *Restrictions `bson:"restrictions,omitempty" json:"restrictions,omitempty"`
}

func GetChatLocks

func GetChatLocks(chatID int64) *Locks

type NoteSettings

type NoteSettings struct {
	ChatId              int64 `bson:"_id,omitempty" json:"_id,omitempty"`
	PrivateNotesEnabled bool  `bson:"private_notes" json:"private_notes" default:"false"`
}

func GetNotes

func GetNotes(chatID int64) *NoteSettings

type Permissions

type Permissions struct {
	Sticker       bool `bson:"sticker,omitempty" json:"sticker,omitempty"`
	Audio         bool `bson:"audio,omitempty" json:"audio,omitempty"`
	Voice         bool `bson:"voice,omitempty" json:"voice,omitempty"`
	Video         bool `bson:"video,omitempty" json:"video,omitempty"`
	Document      bool `bson:"document,omitempty" json:"document,omitempty"`
	VideoNote     bool `bson:"video_note,omitempty" json:"video_note,omitempty"`
	Contact       bool `bson:"contact,omitempty" json:"contact,omitempty"`
	Photo         bool `bson:"photo,omitempty" json:"photo,omitempty"`
	Gif           bool `bson:"gif,omitempty" json:"gif,omitempty"`
	Url           bool `bson:"url,omitempty" json:"url,omitempty"`
	Bot           bool `bson:"bot,omitempty" json:"bot,omitempty"`
	Forward       bool `bson:"forward,omitempty" json:"forward,omitempty"`
	Game          bool `bson:"game,omitempty" json:"game,omitempty"`
	Location      bool `bson:"location,omitempty" json:"location,omitempty"`
	Arab          bool `bson:"arab_chars,omitempty" json:"arab_chars,omitempty"`
	SendAsChannel bool `bson:"send_as_channel,omitempty" json:"send_as_channel,omitempty"`
}

type Pins

type Pins struct {
	ChatId         int64 `bson:"_id,omitempty" json:"_id,omitempty"`
	AntiChannelPin bool  `bson:"antichannelpin" json:"antichannelpin" default:"false"`
	CleanLinked    bool  `bson:"cleanlinked" json:"cleanlinked" default:"false"`
}

func GetPinData

func GetPinData(chatID int64) (pinrc *Pins)

type Restrictions

type Restrictions struct {
	Messages        bool `bson:"messages,omitempty" json:"messages,omitempty"`
	ChannelComments bool `bson:"channel_comments,omitempty" json:"channel_comments,omitempty"`
	Media           bool `bson:"media,omitempty" json:"media,omitempty"`
	Other           bool `bson:"other,omitempty" json:"other,omitempty"`
	Previews        bool `bson:"previews,omitempty" json:"previews,omitempty"`
	All             bool `bson:"all,omitempty" json:"all,omitempty"`
}

type Rules

type Rules struct {
	ChatId   int64  `bson:"_id,omitempty" json:"_id,omitempty"`
	Rules    string `bson:"rules" json:"rules" default:""`
	Private  bool   `bson:"privrules" json:"privrules"`
	RulesBtn string `bson:"rules_button,omitempty" json:"rules_button,omitempty"`
}

func GetChatRulesInfo

func GetChatRulesInfo(chatId int64) *Rules

type Team

type Team struct {
	UserId int64 `bson:"_id,omitempty" json:"_id,omitempty"`
	Dev    bool  `bson:"dev" json:"dev" default:"false"`
	Sudo   bool  `bson:"sudo" json:"sudo" default:"false"`
}

func GetTeamMemInfo

func GetTeamMemInfo(userID int64) (devrc *Team)

type User

type User struct {
	UserId   int64  `bson:"_id,omitempty" json:"_id,omitempty"`
	UserName string `bson:"username" json:"username" default:"nil"`
	Name     string `bson:"name" json:"name" default:"nil"`
	Language string `bson:"language" json:"language" default:"en"`
}

type UserReportSettings

type UserReportSettings struct {
	UserId int64 `bson:"_id,omitempty" json:"_id,omitempty"`
	Status bool  `bson:"status,omitempty" json:"status,omitempty"`
}

func GetUserReportSettings

func GetUserReportSettings(userId int64) (reportsrc *UserReportSettings)

type WarnSettings

type WarnSettings struct {
	ChatId    int64  `bson:"_id,omitempty" json:"_id,omitempty"`
	WarnLimit int    `bson:"warn_limit" json:"warn_limit" default:"3"`
	WarnMode  string `bson:"warn_mode,omitempty" json:"warn_mode,omitempty"`
}

func GetWarnSetting

func GetWarnSetting(chatId int64) *WarnSettings

type Warns

type Warns struct {
	UserId   int64    `bson:"user_id,omitempty" json:"user_id,omitempty"`
	ChatId   int64    `bson:"chat_id,omitempty" json:"chat_id,omitempty"`
	NumWarns int      `bson:"num_warns,omitempty" json:"num_warns,omitempty"`
	Reasons  []string `bson:"warns" json:"warns" default:"[]"`
}

type WelcomeSettings

type WelcomeSettings struct {
	CleanWelcome  bool     `bson:"clean_old" json:"clean_old" default:"false"`
	LastMsgId     int64    `bson:"last_msg_id,omitempty" json:"last_msg_id,omitempty"`
	ShouldWelcome bool     `bson:"enabled" json:"welcome_enabled" default:"true"`
	WelcomeText   string   `bson:"text,omitempty" json:"welcome_text,omitempty"`
	FileID        string   `bson:"file_id,omitempty" json:"file_id,omitempty"`
	WelcomeType   int      `bson:"type,omitempty" json:"welcome_type,omitempty"`
	Button        []Button `bson:"btns,omitempty" json:"btns,omitempty"`
}

Jump to

Keyboard shortcuts

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