telegram

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthErrorMsg

type AuthErrorMsg struct {
	Err error
}

type AuthorizedMsg

type AuthorizedMsg struct{}

type Chat

type Chat struct {
	ID          int64
	AccessHash  int64
	Title       string
	Type        ChatType
	UnreadCount int
	Pinned      bool
	LastMessage *Message
}

type ChatType

type ChatType int
const (
	ChatTypePrivate ChatType = iota
	ChatTypeGroup
	ChatTypeChannel
)

type Client

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

func NewClient

func NewClient(cfg *config.Config) *Client

func (*Client) API

func (c *Client) API() *tg.Client

func (*Client) Context

func (c *Client) Context() context.Context

func (*Client) DownloadPhoto added in v0.1.1

func (c *Client) DownloadPhoto(msgID int, info *MediaInfo) func() interface{}

func (*Client) DownloadToFile added in v0.1.1

func (c *Client) DownloadToFile(msgID int, info *MediaInfo, destPath string) func() interface{}

DownloadToFile saves a media file (photo or document) to disk.

func (*Client) FetchDialogs

func (c *Client) FetchDialogs() func() interface{}

func (*Client) FetchHistory

func (c *Client) FetchHistory(chat Chat) func() interface{}

func (*Client) FetchOlderHistory added in v0.2.0

func (c *Client) FetchOlderHistory(chat Chat, offsetID int) func() interface{}

func (*Client) ForwardMessages added in v0.2.0

func (c *Client) ForwardMessages(fromChat Chat, messageIDs []int, toChat Chat) func() interface{}

func (*Client) LoggedIn added in v0.2.0

func (c *Client) LoggedIn() qrlogin.LoggedIn

func (*Client) Run

func (c *Client) Run() error

func (*Client) SearchHistory added in v0.2.0

func (c *Client) SearchHistory(chat Chat, query string) func() interface{}

func (*Client) SelfID

func (c *Client) SelfID() int64

func (*Client) SendCode

func (c *Client) SendCode(phone string) func() interface{}

func (*Client) SendMessage

func (c *Client) SendMessage(chat Chat, text string) func() interface{}

func (*Client) SetProgram

func (c *Client) SetProgram(p *tea.Program)

func (*Client) SignIn

func (c *Client) SignIn(phone, code, phoneCodeHash string) func() interface{}

func (*Client) StartQRLogin added in v0.2.0

func (c *Client) StartQRLogin(loggedIn qrlogin.LoggedIn) func() interface{}

func (*Client) Stop

func (c *Client) Stop()

func (*Client) Submit2FA

func (c *Client) Submit2FA(password string) func() interface{}

type CodeSentMsg

type CodeSentMsg struct {
	PhoneCodeHash string
	CodeType      string // hint about where code was sent
}

type DialogsErrorMsg

type DialogsErrorMsg struct {
	Err error
}

type DialogsLoadedMsg

type DialogsLoadedMsg struct {
	Chats []Chat
}

type DownloadPhotoErrorMsg added in v0.1.1

type DownloadPhotoErrorMsg struct {
	MessageID int
	Err       error
}

type DownloadPhotoMsg added in v0.1.1

type DownloadPhotoMsg struct {
	MessageID int
	Data      []byte
}

type FileSessionStorage

type FileSessionStorage struct {
	Path string
}

func (*FileSessionStorage) LoadSession

func (s *FileSessionStorage) LoadSession(_ context.Context) ([]byte, error)

func (*FileSessionStorage) StoreSession

func (s *FileSessionStorage) StoreSession(_ context.Context, data []byte) error

type ForwardErrorMsg added in v0.2.0

type ForwardErrorMsg struct {
	Err error
}

type ForwardedMsg added in v0.2.0

type ForwardedMsg struct {
	FromChatID int64
	ToChatID   int64
	Count      int
}

type HistoryErrorMsg

type HistoryErrorMsg struct {
	Err error
}

type HistoryLoadedMsg

type HistoryLoadedMsg struct {
	ChatID   int64
	Messages []Message
}

type MediaInfo added in v0.1.1

type MediaInfo struct {
	Type     MediaType
	Label    string // Pre-formatted: "[Photo]", "[Video 0:32]", etc.
	FileName string
	FileSize int64
	MimeType string
	Width    int
	Height   int
	// Photo download fields
	PhotoID         int64
	PhotoAccessHash int64
	PhotoFileRef    []byte
	PhotoDCID       int
	PhotoThumbSize  string
	// Document download fields (videos, audio, files, etc.)
	DocID         int64
	DocAccessHash int64
	DocFileRef    []byte
	DocDCID       int
}

type MediaType added in v0.1.1

type MediaType int
const (
	MediaPhoto MediaType = iota
	MediaVideo
	MediaDocument
	MediaAudio
	MediaVoice
	MediaSticker
	MediaAnimation
	MediaContact
	MediaLocation
	MediaPoll
	MediaOther
)

type Message

type Message struct {
	ID        int
	ChatID    int64
	SenderID  int64
	Sender    string
	Text      string
	Date      int
	Out       bool
	Entities  []tg.MessageEntityClass
	Media     *MediaInfo
	Reactions []Reaction
}

type MessageSendErrorMsg

type MessageSendErrorMsg struct {
	Err error
}

type MessageSentMsg

type MessageSentMsg struct {
	ChatID int64
}

type Need2FAMsg

type Need2FAMsg struct{}

type NeedAuthMsg

type NeedAuthMsg struct{}

type NewMessageMsg

type NewMessageMsg struct {
	Message Message
}

type OlderHistoryErrorMsg added in v0.2.0

type OlderHistoryErrorMsg struct {
	Err error
}

type OlderHistoryLoadedMsg added in v0.2.0

type OlderHistoryLoadedMsg struct {
	ChatID   int64
	Messages []Message
}

type QRAuthDoneMsg added in v0.2.0

type QRAuthDoneMsg struct{}

type QRTokenMsg added in v0.2.0

type QRTokenMsg struct {
	URL string // tg://login?token=... to encode as QR
}

type Reaction added in v0.2.0

type Reaction struct {
	Emoji  string
	Count  int
	Chosen bool // current user also sent this reaction
}

type ReactionsUpdatedMsg added in v0.2.0

type ReactionsUpdatedMsg struct {
	ChatID    int64
	MsgID     int
	Reactions []Reaction
}

type SaveFileErrorMsg added in v0.1.1

type SaveFileErrorMsg struct {
	MessageID int
	Err       error
}

type SaveFileMsg added in v0.1.1

type SaveFileMsg struct {
	MessageID int
	Path      string
}

type SearchErrorMsg added in v0.2.0

type SearchErrorMsg struct {
	Err error
}

type SearchResultMsg added in v0.2.0

type SearchResultMsg struct {
	ChatID   int64
	Query    string
	Messages []Message
}

Jump to

Keyboard shortcuts

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