Documentation
¶
Index ¶
- type ChatEntry
- type ChatStore
- func (s *ChatStore) Count() int
- func (s *ChatStore) Get(chatID int64) (*ChatEntry, bool)
- func (s *ChatStore) OrderedChats() []*ChatEntry
- func (s *ChatStore) Set(chat *telegram.Chat)
- func (s *ChatStore) UpdateLastMessage(chatID int64, msg *telegram.Message)
- func (s *ChatStore) UpdateReadInbox(chatID int64, unreadCount int32)
- type FileState
- type FileStore
- type MessageStore
- func (s *MessageStore) Append(chatID int64, msg *telegram.Message)
- func (s *MessageStore) Clear(chatID int64)
- func (s *MessageStore) Count(chatID int64) int
- func (s *MessageStore) Delete(chatID int64, messageIDs []int64)
- func (s *MessageStore) DeleteFromAll(messageIDs []int64)
- func (s *MessageStore) Get(chatID int64) []*telegram.Message
- func (s *MessageStore) OldestMessageId(chatID int64) int64
- func (s *MessageStore) Prepend(chatID int64, msgs []*telegram.Message)
- func (s *MessageStore) ReplaceMessageId(chatID int64, oldID int64, newMsg *telegram.Message)
- func (s *MessageStore) UpdateMessage(chatID int64, messageID int64, newMsg *telegram.Message)
- type Store
- type UserStore
- func (s *UserStore) All() []*telegram.User
- func (s *UserStore) DisplayName(userID int64) string
- func (s *UserStore) Get(userID int64) (*telegram.User, bool)
- func (s *UserStore) IsOnline(userID int64) bool
- func (s *UserStore) Set(user *telegram.User)
- func (s *UserStore) UpdateStatus(userID int64, status telegram.UserStatus)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatEntry ¶
type ChatEntry struct {
Chat *telegram.Chat
LastMessage *telegram.Message
UnreadCount int32
Pinned bool
Order int64
}
ChatEntry holds chat metadata and its position in the main list.
type ChatStore ¶
type ChatStore struct {
// contains filtered or unexported fields
}
ChatStore is a thread-safe in-memory cache of chats.
func NewChatStore ¶
func NewChatStore() *ChatStore
func (*ChatStore) OrderedChats ¶
OrderedChats returns all chats: pinned first, then by last message date (descending).
func (*ChatStore) UpdateLastMessage ¶
UpdateLastMessage updates a chat's last message and sort order.
func (*ChatStore) UpdateReadInbox ¶
UpdateReadInbox updates the unread count for a chat.
type FileState ¶
type FileState struct {
File *telegram.File
LocalPath string
IsComplete bool
Progress float64 // 0.0 to 1.0
}
FileState tracks the download state of a file.
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore tracks file download states.
func NewFileStore ¶
func NewFileStore() *FileStore
func (*FileStore) IsComplete ¶
IsComplete checks if a file download is complete.
type MessageStore ¶
type MessageStore struct {
// contains filtered or unexported fields
}
MessageStore caches messages per chat.
func NewMessageStore ¶
func NewMessageStore() *MessageStore
func (*MessageStore) Append ¶
func (s *MessageStore) Append(chatID int64, msg *telegram.Message)
Append adds a new message to the end of the chat's message list.
func (*MessageStore) Clear ¶
func (s *MessageStore) Clear(chatID int64)
Clear removes all cached messages for a chat.
func (*MessageStore) Count ¶
func (s *MessageStore) Count(chatID int64) int
Count returns the number of cached messages for a chat.
func (*MessageStore) Delete ¶
func (s *MessageStore) Delete(chatID int64, messageIDs []int64)
Delete removes messages from the store.
func (*MessageStore) DeleteFromAll ¶
func (s *MessageStore) DeleteFromAll(messageIDs []int64)
DeleteFromAll removes messages from every chat. Used for non-channel delete updates, which carry no peer (ChatId == 0).
func (*MessageStore) Get ¶
func (s *MessageStore) Get(chatID int64) []*telegram.Message
Get returns all cached messages for a chat.
func (*MessageStore) OldestMessageId ¶
func (s *MessageStore) OldestMessageId(chatID int64) int64
OldestMessageId returns the oldest cached message ID for a chat.
func (*MessageStore) Prepend ¶
func (s *MessageStore) Prepend(chatID int64, msgs []*telegram.Message)
Prepend adds older messages to the beginning of the chat's message list.
func (*MessageStore) ReplaceMessageId ¶
func (s *MessageStore) ReplaceMessageId(chatID int64, oldID int64, newMsg *telegram.Message)
ReplaceMessageId replaces a temporary message ID with the real one (after send).
func (*MessageStore) UpdateMessage ¶
func (s *MessageStore) UpdateMessage(chatID int64, messageID int64, newMsg *telegram.Message)
UpdateMessage replaces a message in the store (for edits).
type Store ¶
type Store struct {
Chats *ChatStore
Messages *MessageStore
Users *UserStore
Files *FileStore
}
Store is the aggregate store holding all caches.
type UserStore ¶
type UserStore struct {
// contains filtered or unexported fields
}
UserStore caches user information.
func NewUserStore ¶
func NewUserStore() *UserStore
func (*UserStore) DisplayName ¶
DisplayName returns a formatted display name for a user.
func (*UserStore) UpdateStatus ¶
func (s *UserStore) UpdateStatus(userID int64, status telegram.UserStatus)
UpdateStatus updates a user's online status.