database

package
v0.15.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMemberToIndexChat added in v0.15.0

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

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 IsMemberInIndexChat added in v0.15.0

func IsMemberInIndexChat(ctx context.Context, chatID int64, userChatID int64) (bool, error)

func RemoveMemberFromIndexChat added in v0.15.0

func RemoveMemberFromIndexChat(ctx context.Context, chatID int64, userInfo *UserInfo) 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"`

	Members []UserInfo `` /* 131-byte string literal not displayed */
}

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)

func (*SubBot) UserCanSearchChats added in v0.15.0

func (s *SubBot) UserCanSearchChats(ctx context.Context, userId int64) []int64

public + user joined chats

type UserInfo

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

	IndexChats []IndexChat `` /* 135-byte string literal not displayed */
}

func GetUserInfo

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

func (*UserInfo) FullName added in v0.15.0

func (u *UserInfo) FullName() string

Jump to

Keyboard shortcuts

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