db

package
v0.0.0-...-5c90490 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const SuperAdminChatIDNotSet = -1

Variables

View Source
var (
	ErrNoBackupDir = errors.New("backup directory is not specified")
	ErrNoDater     = errors.New("date generation function not supplied")
)
View Source
var ErrNoMembers = errors.New("member list is empty")

Functions

func GetSuperAdminChatID

func GetSuperAdminChatID() int64

func SetSuperAdminChatID

func SetSuperAdminChatID(chatID int64)

Types

type AdminDB

type AdminDB struct {
	// contains filtered or unexported fields
}

func GetAdminDB

func GetAdminDB() *AdminDB

func (*AdminDB) IsAdmin

func (db *AdminDB) IsAdmin(nick string) bool

func (*AdminDB) IsSuperAdmin

func (db *AdminDB) IsSuperAdmin(nick string) bool

IsSuperAdmin reports whether nick belongs to the Super Admin. Super-admin is the first admin in the admin database.

type AnnouncementSubscription

type AnnouncementSubscription struct {
	UserName string
	ChatID   int64 `json:"ChatId"`
}

type AnnouncementSubscriptionDB

type AnnouncementSubscriptionDB struct {
	// contains filtered or unexported fields
}

func GetAnnouncementSubscriptionDB

func GetAnnouncementSubscriptionDB() *AnnouncementSubscriptionDB

func (*AnnouncementSubscriptionDB) GetSubscriberChatIDs

func (db *AnnouncementSubscriptionDB) GetSubscriberChatIDs() []int64

func (*AnnouncementSubscriptionDB) Subscribe

func (db *AnnouncementSubscriptionDB) Subscribe(chatID int64, userName string)

func (*AnnouncementSubscriptionDB) Unsubscribe

func (db *AnnouncementSubscriptionDB) Unsubscribe(chatID int64)

type BannedChannelDB

type BannedChannelDB struct {
	// contains filtered or unexported fields
}

func GetBannedChannelDB

func GetBannedChannelDB() *BannedChannelDB

func (*BannedChannelDB) Ban

func (db *BannedChannelDB) Ban(ch Channel)

func (*BannedChannelDB) Clear

func (db *BannedChannelDB) Clear() error

func (*BannedChannelDB) Get

func (db *BannedChannelDB) Get() []Channel

func (*BannedChannelDB) IsBanned

func (db *BannedChannelDB) IsBanned(channelID int64) bool

type BannedRegexDB

type BannedRegexDB struct {
	// contains filtered or unexported fields
}

func GetBannedRegexDB

func GetBannedRegexDB() *BannedRegexDB

func (*BannedRegexDB) Ban

func (db *BannedRegexDB) Ban(regex string) error

func (*BannedRegexDB) Get

func (db *BannedRegexDB) Get() []string

func (*BannedRegexDB) Unban

func (db *BannedRegexDB) Unban(regex string) error

type Channel

type Channel struct {
	ID    int64 `json:"Id"`
	Title string
}

type Chat

type Chat struct {
	ID    int64 `json:"Id"`
	Title string
}

type ChatDB

type ChatDB struct {
	// contains filtered or unexported fields
}

func GetChatsDB

func GetChatsDB() *ChatDB

func (*ChatDB) Add

func (db *ChatDB) Add(chat Chat)

func (*ChatDB) Get

func (db *ChatDB) Get() []Chat

func (*ChatDB) GetIDByOrdinal

func (db *ChatDB) GetIDByOrdinal(num int) (int64, bool)

func (ChatDB) GetOrdinalByChatID

func (db ChatDB) GetOrdinalByChatID(chatID int64) (int, bool)

type ChatKillswitchDB

type ChatKillswitchDB struct {
	// contains filtered or unexported fields
}

func GetChatKillswitchDB

func GetChatKillswitchDB() *ChatKillswitchDB

func (*ChatKillswitchDB) Get

func (db *ChatKillswitchDB) Get(chatOrdinal int) bool

func (*ChatKillswitchDB) Set

func (db *ChatKillswitchDB) Set(chatOrdinal int, toggle bool)

type EventPickCountDB

type EventPickCountDB struct {
	// contains filtered or unexported fields
}

EventPickCountDB stores the amount of times each person was randomly selected by the /event command.

func GetEventPickCountDB

func GetEventPickCountDB() *EventPickCountDB

func (*EventPickCountDB) Inc

func (e *EventPickCountDB) Inc(userName string)

func (EventPickCountDB) List

type EventPickCountEntry

type EventPickCountEntry struct {
	UserName string
	Count    int
}

type FilterToggleDB

type FilterToggleDB struct {
	// contains filtered or unexported fields
}

func GetFilterToggleDB

func GetFilterToggleDB() *FilterToggleDB

func (*FilterToggleDB) IsFilterEnabled

func (db *FilterToggleDB) IsFilterEnabled(id string) bool

func (*FilterToggleDB) SetFilterEnabled

func (db *FilterToggleDB) SetFilterEnabled(filterID string, enabled bool)

SetFilterEnabled updates the filter enabled state. It does not check the filterID validity, it is assumed to be correct.

type Member

type Member struct {
	UserName string
	Name     string
	Sex      Sex
}

type MemberDB

type MemberDB struct {
	// contains filtered or unexported fields
}

func GetMemberDB

func GetMemberDB() MemberDB

func (MemberDB) GetNameByUserName

func (m MemberDB) GetNameByUserName(userName string) (string, bool)

func (MemberDB) Pick

func (m MemberDB) Pick() (Member, error)

type Mute

type Mute struct {
	UserName       string
	UserID         int64
	StartAt, EndAt time.Time
	IsAnnounced    bool
}

type MuteDB

type MuteDB struct {
	// contains filtered or unexported fields
}

func GetMuteDB

func GetMuteDB() *MuteDB

func (*MuteDB) GetByUserName

func (db *MuteDB) GetByUserName(userName string) *Mute

func (*MuteDB) GetMuteUntil

func (db *MuteDB) GetMuteUntil(userName string) *time.Time

func (*MuteDB) MarkMuteAnnounced

func (db *MuteDB) MarkMuteAnnounced(userName string, userID int64)

func (*MuteDB) MuteUser

func (db *MuteDB) MuteUser(userName string, duration time.Duration)

func (*MuteDB) UnmuteUser

func (db *MuteDB) UnmuteUser(userName string)

type NameReplacementDB

type NameReplacementDB struct {
	// contains filtered or unexported fields
}

func GetNameReplacementDB

func GetNameReplacementDB() *NameReplacementDB

func (*NameReplacementDB) GetNameForUser

func (db *NameReplacementDB) GetNameForUser(user *tgbotapi.User) string

type OncePerDayLimiter

type OncePerDayLimiter struct {
	// contains filtered or unexported fields
}

func GetOncePerDayLimiter

func GetOncePerDayLimiter() *OncePerDayLimiter

func (*OncePerDayLimiter) Try

func (l *OncePerDayLimiter) Try(chatID int64) bool

type RemovedMessageDB

type RemovedMessageDB struct {
	// contains filtered or unexported fields
}

func GetRemovedMessageDB

func GetRemovedMessageDB() *RemovedMessageDB

func (*RemovedMessageDB) Add

func (db *RemovedMessageDB) Add(message *tgbotapi.Message)

type ScrutinyDB

type ScrutinyDB struct {
	// contains filtered or unexported fields
}

func GetScrutinyDB

func GetScrutinyDB() *ScrutinyDB

func (*ScrutinyDB) Add

func (db *ScrutinyDB) Add(nick string)

func (*ScrutinyDB) IsUnderScrutiny

func (db *ScrutinyDB) IsUnderScrutiny(nick string) bool

func (*ScrutinyDB) Remove

func (db *ScrutinyDB) Remove(nick string) bool

type Sex

type Sex string
const (
	SexMale   Sex = "M"
	SexFemale Sex = "F"
)

type StickerDB

type StickerDB struct {
	// contains filtered or unexported fields
}

func GetStickerDB

func GetStickerDB() *StickerDB

func (*StickerDB) Add

func (db *StickerDB) Add(stickerID string)

func (*StickerDB) GetRandomMockStickerFileID

func (db *StickerDB) GetRandomMockStickerFileID() tgbotapi.FileID

func (StickerDB) List

func (db StickerDB) List() []string

func (*StickerDB) Remove

func (db *StickerDB) Remove(stickerID string) bool

Jump to

Keyboard shortcuts

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