store

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

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) Count

func (s *ChatStore) Count() int

Count returns the number of cached chats.

func (*ChatStore) Get

func (s *ChatStore) Get(chatID int64) (*ChatEntry, bool)

Get returns a chat entry by ID.

func (*ChatStore) OrderedChats

func (s *ChatStore) OrderedChats() []*ChatEntry

OrderedChats returns all chats: pinned first, then by last message date (descending).

func (*ChatStore) Set

func (s *ChatStore) Set(chat *telegram.Chat)

Set adds or updates a chat entry.

func (*ChatStore) UpdateLastMessage

func (s *ChatStore) UpdateLastMessage(chatID int64, msg *telegram.Message)

UpdateLastMessage updates a chat's last message and sort order.

func (*ChatStore) UpdateReadInbox

func (s *ChatStore) UpdateReadInbox(chatID int64, unreadCount int32)

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) Get

func (s *FileStore) Get(fileID string) (*FileState, bool)

Get returns the state of a file.

func (*FileStore) IsComplete

func (s *FileStore) IsComplete(fileID string) bool

IsComplete checks if a file download is complete.

func (*FileStore) LocalPath

func (s *FileStore) LocalPath(fileID string) string

LocalPath returns the local path of a downloaded file.

func (*FileStore) Progress

func (s *FileStore) Progress(fileID string) float64

Progress returns the download progress of a file (0.0 to 1.0).

func (*FileStore) Update

func (s *FileStore) Update(file *telegram.File)

Update processes a file update.

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.

func NewStore

func NewStore() *Store

NewStore creates a new aggregate store.

type UserStore

type UserStore struct {
	// contains filtered or unexported fields
}

UserStore caches user information.

func NewUserStore

func NewUserStore() *UserStore

func (*UserStore) All

func (s *UserStore) All() []*telegram.User

All returns all cached users.

func (*UserStore) DisplayName

func (s *UserStore) DisplayName(userID int64) string

DisplayName returns a formatted display name for a user.

func (*UserStore) Get

func (s *UserStore) Get(userID int64) (*telegram.User, bool)

Get returns a cached user by ID.

func (*UserStore) IsOnline

func (s *UserStore) IsOnline(userID int64) bool

IsOnline checks if a user is currently online.

func (*UserStore) Set

func (s *UserStore) Set(user *telegram.User)

Set adds or updates a user in the cache.

func (*UserStore) UpdateStatus

func (s *UserStore) UpdateStatus(userID int64, status telegram.UserStatus)

UpdateStatus updates a user's online status.

Jump to

Keyboard shortcuts

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