database:
remove multi-database support
change `DatabaseBackend` as a interface
db_struct:
change some fields to `map` type
yaml_db:
refactor to implement the `DatabaseBackend` interface
add some lock changes
move auto save as a single goroutine
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package db_struct
|
|
|
|
import (
|
|
"github.com/go-telegram/bot/models"
|
|
)
|
|
|
|
type ChatInfo struct {
|
|
// normal data
|
|
ID int64 `yaml:"ID"`
|
|
ChatName string `yaml:"ChatName"`
|
|
ChatType models.ChatType `yaml:"ChatType"`
|
|
AddTime string `yaml:"AddTime"`
|
|
|
|
Flag map[Flag ]string `yaml:"Flag,omitempty"`
|
|
Status map[Status]bool `yaml:"Status,omitempty"`
|
|
|
|
LatestData map[LatestData]string `yaml:"LatestData,omitempty"`
|
|
UsageCount map[UsageCount]int `yaml:"UsageCount,omitempty"`
|
|
}
|
|
|
|
type Flag string
|
|
const (
|
|
DefaultInlinePlugin Flag = "DefaultInlinePlugin"
|
|
)
|
|
|
|
type Status string
|
|
const (
|
|
IsBanned Status = "IsBanned"
|
|
)
|
|
|
|
type LatestData string
|
|
const (
|
|
LatestMessage LatestData = "LatestMessage"
|
|
|
|
LatestInlineQuery LatestData = "LatestInlineQuery"
|
|
LatestInlineResult LatestData = "LatestInlineResult"
|
|
|
|
LatestCallbackQueryData LatestData = "LatestCallbackQueryData"
|
|
)
|
|
|
|
type UsageCount string
|
|
const (
|
|
MessageNormal UsageCount = "MessageNormal"
|
|
MessageCommand UsageCount = "MessageCommand"
|
|
CallbackQuery UsageCount = "CallbackQuery"
|
|
InlineRequest UsageCount = "InlineRequest"
|
|
InlineResult UsageCount = "InlineResult"
|
|
|
|
StickerDownloaded UsageCount = "StickerDownloaded"
|
|
StickerSetDownloaded UsageCount = "StickerSetDownloaded"
|
|
)
|