Documentation
¶
Index ¶
- func AddMemberToIndexChat(ctx context.Context, chatID int64, userInfo *UserInfo) error
- func AllChatIDs() []int64
- func DeleteApiKey(ctx context.Context, id uint) error
- func DeleteIndexChat(ctx context.Context, chatID int64) error
- func DeleteSubBot(ctx context.Context, botID int64) error
- func Indexed(chatID int64) bool
- func InitDatabase(ctx context.Context) error
- func IsMemberInIndexChat(ctx context.Context, chatID int64, userChatID int64) (bool, error)
- func RemoveMemberFromIndexChat(ctx context.Context, chatID int64, userInfo *UserInfo) error
- func UpdateChannelPts(ctx context.Context, chatID int64, pts int) error
- func UpdateUpdatesState(ctx context.Context, state *UpdatesState) error
- func UpsertApiKey(ctx context.Context, apiKey *ApiKey) error
- func UpsertIndexChat(ctx context.Context, IndexChat *IndexChat) error
- func UpsertSubBot(ctx context.Context, subBot *SubBot) error
- func UpsertUserInfo(ctx context.Context, userInfo *UserInfo) error
- func Watching(chatID int64) bool
- type ApiKey
- type ChatType
- type IndexChat
- type SubBot
- type UpdatesState
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddMemberToIndexChat ¶ added in v0.15.0
func AllChatIDs ¶ added in v0.8.0
func AllChatIDs() []int64
func InitDatabase ¶
func IsMemberInIndexChat ¶ added in v0.15.0
func RemoveMemberFromIndexChat ¶ added in v0.15.0
func UpdateChannelPts ¶ added in v1.1.0
func UpdateUpdatesState ¶ added in v1.1.0
func UpdateUpdatesState(ctx context.Context, state *UpdatesState) error
UpdateUpdatesState 更新 updates state
Types ¶
type ApiKey ¶ added in v0.16.0
type ApiKey struct {
ID uint `gorm:"primaryKey"`
Name string `json:"name"`
KeyHash string `gorm:"uniqueIndex;size:64" json:"-"`
Chats []IndexChat `gorm:"many2many:api_key_chats;constraint:OnDelete:CASCADE;joinForeignKey:ApiKeyID;joinReferences:IndexChatID" json:"chats"`
}
ApiKey 表示 Web API 的子 API Key KeyHash 使用 sha256 的十六进制字符串,Chats 通过关联表描述可访问聊天
func GetApiKeyByHash ¶ added in v0.16.0
func GetApiKeyByID ¶ added in v0.16.0
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"`
Pts int `gorm:"default:0" json:"pts"` // Channel message box sequence for updates
Members []UserInfo `` /* 131-byte string literal not displayed */
}
func GetAllPublicIndexChats ¶
type SubBot ¶
type UpdatesState ¶ added in v1.1.0
type UpdatesState struct {
ID uint `gorm:"primaryKey"`
Pts int `json:"pts"` // Common message box sequence (private chats, basic groups)
Qts int `json:"qts"` // Secondary event sequence (secret chats, certain bot events)
Date int `json:"date"` // Unix timestamp
Seq int `json:"seq"` // Updates sequence number
}
UpdatesState 存储 Telegram updates 的状态信息,用于断线重连时获取错过的消息
func GetUpdatesState ¶ added in v1.1.0
func GetUpdatesState(ctx context.Context) (*UpdatesState, error)
GetUpdatesState 获取 updates state,如果不存在则创建一个默认的
Click to show internal directories.
Click to hide internal directories.