telegram

package
v1.9.6 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const TelegramAuthDone string = "Authorization is done already"
View Source
const TelegramNotInitialized string = "Telegram connection is not initialized yet"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Session *persistence.Session

	DelayedStatuses     map[int64]*DelayedStatus
	DelayedStatusesLock sync.Mutex

	SendMessageLock sync.Mutex
	// contains filtered or unexported fields
}

Client stores the metadata for lazily invoked TDlib instance

func NewClient

func NewClient(conf config.TelegramConfig, jid string, component *xmpp.Component, session *persistence.Session) (*Client, error)

NewClient instantiates a Telegram App

func (*Client) AddToEditOutbox added in v1.9.0

func (c *Client) AddToEditOutbox(xmppId, resource string)

AddToEditOutbox temporarily store the resource from which a replace message with given ID was sent

func (*Client) AddToOutbox added in v1.7.0

func (c *Client) AddToOutbox(xmppId, resource string)

AddToOutbox remembers the resource from which a message with given ID was sent

func (*Client) Connect

func (c *Client) Connect(resource string) error

Connect starts TDlib connection

func (*Client) Disconnect

func (c *Client) Disconnect(resource string, quit bool) bool

Disconnect drops TDlib connection and returns the flag indicating if disconnecting is permitted

func (*Client) DownloadFile

func (c *Client) DownloadFile(id int32, priority int32, synchronous bool) (*client.File, error)

DownloadFile actually obtains a file by id given by TDlib

func (*Client) ForceOpenFile added in v1.6.0

func (c *Client) ForceOpenFile(tgFile *client.File, priority int32) (*os.File, string, error)

ForceOpenFile reliably obtains a file if possible

func (*Client) GetChatDescription added in v1.2.1

func (c *Client) GetChatDescription(chat *client.Chat) string

GetChatDescription obtains bio or description according to the chat type

func (*Client) GetContactByID

func (c *Client) GetContactByID(id int64, chat *client.Chat) (*client.Chat, *client.User, error)

GetContactByID gets user and chat information from cache (or tries to retrieve it, if missing)

func (*Client) GetContactByUsername

func (c *Client) GetContactByUsername(username string) (*client.Chat, *client.User, error)

GetContactByUsername resolves username to user id retrieves user and chat information

func (*Client) GetVcardInfo added in v1.6.0

func (c *Client) GetVcardInfo(toID int64) (VCardInfo, error)

func (*Client) IsPM added in v1.5.0

func (c *Client) IsPM(id int64) (bool, error)

IsPM checks if a chat is PM

func (*Client) LastSeenStatus

func (c *Client) LastSeenStatus(timestamp int64) string

LastSeenStatus formats a timestamp to a "Last seen at" string

func (*Client) MarkAsRead added in v1.9.0

func (c *Client) MarkAsRead(chatId, messageId int64)

MarkAsRead marks a message as read

func (*Client) Online

func (c *Client) Online() bool

Online checks if the updates listener is alive

func (*Client) PermastoreFile added in v1.6.0

func (c *Client) PermastoreFile(file *client.File, clone bool) (string, string)

PermastoreFile steals a file out of TDlib control into an independent shared directory

func (*Client) PrepareOutgoingMessageContent added in v1.6.0

func (c *Client) PrepareOutgoingMessageContent(text string) client.InputMessageContent

PrepareMessageContent creates a simple text message

func (*Client) ProcessChatCommand

func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)

ProcessChatCommand executes a command sent in a mapped chat and returns a response and the status of command support

func (*Client) ProcessIncomingMessage added in v1.2.0

func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message)

ProcessIncomingMessage transfers a message to XMPP side and marks it as read on Telegram side

func (*Client) ProcessOutgoingMessage

func (c *Client) ProcessOutgoingMessage(chatID int64, text string, returnJid string, replyId int64, replaceId int64) int64

ProcessOutgoingMessage executes commands or sends messages to mapped chats, returns message id

func (*Client) ProcessStatusUpdate

func (c *Client) ProcessStatusUpdate(chatID int64, status string, show string, oldArgs ...args.V) error

ProcessStatusUpdate sets contact status

func (*Client) ProcessTransportCommand

func (c *Client) ProcessTransportCommand(cmdline string, resource string) string

ProcessTransportCommand executes a command sent directly to the component and returns a response

func (*Client) SetPhoneNumber added in v1.8.0

func (c *Client) SetPhoneNumber(login string) error

func (*Client) StatusesRange

func (c *Client) StatusesRange() chan *cache.Status

StatusesRange proxies the following function from unexported cache

func (*Client) TryLogin added in v1.8.0

func (c *Client) TryLogin(resource string, login string) error

func (*Client) UpdateChatNicknames added in v1.7.0

func (c *Client) UpdateChatNicknames()

func (*Client) UpdateLastChatMessageId added in v1.9.0

func (c *Client) UpdateLastChatMessageId(chatId int64, messageId string)

type DelayedStatus

type DelayedStatus struct {
	TimestampOnline  int64
	TimestampExpired int64
}

DelayedStatus describes an online status expiring on timeout

type VCardInfo added in v1.6.0

type VCardInfo struct {
	Fn        string
	Photo     *client.File
	Nicknames []string
	Given     string
	Family    string
	Tel       string
	Info      string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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