database

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllChatIDs added in v0.8.0

func AllChatIDs() []int64

func DeleteIndexChat

func DeleteIndexChat(ctx context.Context, chatID int64) error

func DeleteSubBot

func DeleteSubBot(ctx context.Context, botID int64) error

func InitDatabase

func InitDatabase(ctx context.Context) error

func UpsertIndexChat

func UpsertIndexChat(ctx context.Context, IndexChat *IndexChat) error

func UpsertSubBot

func UpsertSubBot(ctx context.Context, subBot *SubBot) error

func UpsertUserInfo

func UpsertUserInfo(ctx context.Context, userInfo *UserInfo) error

func Watching

func Watching(chatID int64) bool

Types

type ChatType

type ChatType int
const (
	ChatTypePrivate ChatType = iota
	ChatTypeChannel
)

type IndexChat

type IndexChat struct {
	ChatID   int64  `gorm:"primaryKey" json:"chat_id"`
	Title    string `json:"title"`
	Username string `json:"username"`
	Type     int    `json:"type"`
	Watching bool   `gorm:"default:true" json:"watching"`
	NoDelete bool   `json:"no_delete"`
	Public   bool   `gorm:"default:false" json:"public"`
}

func GetAllIndexChats

func GetAllIndexChats(ctx context.Context) ([]*IndexChat, error)

func GetAllPublicIndexChats

func GetAllPublicIndexChats(ctx context.Context) ([]*IndexChat, error)

func GetIndexChat

func GetIndexChat(ctx context.Context, chatID int64) (*IndexChat, error)

func (*IndexChat) AfterSave

func (ic *IndexChat) AfterSave(tx *gorm.DB) error

func (*IndexChat) BeforeDelete

func (ic *IndexChat) BeforeDelete(tx *gorm.DB) error

type SubBot

type SubBot struct {
	BotID int64 `gorm:"primaryKey"`
	Token string
	// which chats this bot can search
	ChatIDs []int64 `gorm:"serializer:json;type:json"`
}

func GetAllSubBots

func GetAllSubBots(ctx context.Context) ([]*SubBot, error)

func GetSubBot

func GetSubBot(ctx context.Context, botID int64) (*SubBot, error)

type UserInfo

type UserInfo struct {
	ChatID    int64 `gorm:"primaryKey"`
	Username  string
	FirstName string
	LastName  string
}

func GetUserInfo

func GetUserInfo(ctx context.Context, chatID int64) (*UserInfo, error)

Jump to

Keyboard shortcuts

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