Documentation
¶
Index ¶
- Constants
- func CommandToHelpString(name string, cmd command) string
- func GetCommand(typ CommandType, cmd string) (command, bool)
- func GetCommands(typ CommandType) map[string]command
- func IsCommandForChatType(cmd command, chatType ChatType) bool
- func SortedCommandKeys(commandMap map[string]command) []string
- type BotCommand
- type BotLink
- type ChatType
- type Client
- func (c *Client) AddToEditOutbox(xmppId, resource string)
- func (c *Client) AddToOutbox(xmppId, resource string)
- func (c *Client) Connect(resource string) error
- func (c *Client) Disconnect(resource string, quit bool) bool
- func (c *Client) DownloadFile(id int32, priority int32, synchronous bool) (*client.File, error)
- func (c *Client) ForceOpenFile(tgFile *client.File, priority int32) (*os.File, string, error)
- func (c *Client) FormatContact(chatID int64) string
- func (c *Client) GetBotMenu(id int64) (*BotLink, []*BotCommand, error)
- func (c *Client) GetChatDescription(chat *client.Chat) string
- func (c *Client) GetChatMembers(chatID int64, limited bool, query string, membersList MembersList) ([]*client.ChatMember, error)
- func (c *Client) GetChatType(id int64, own bool) (ChatType, error)
- func (c *Client) GetContactByID(id int64, chat *client.Chat, own bool) (*client.Chat, *client.User, error)
- func (c *Client) GetContactByUsername(username string, own bool) (*client.Chat, *client.User, error)
- func (c *Client) GetFile(id int32) (*client.File, error)
- func (c *Client) GetLoginWizardNextStage() string
- func (c *Client) GetPhotoBase64(photo *client.File) string
- func (c *Client) GetPhotoSha1(photo *client.File, chatId int64) string
- func (c *Client) GetPhotoSize(photo *client.File) int64
- func (c *Client) GetSenderId(sender client.MessageSender) (senderId int64)
- func (c *Client) GetTZD() string
- func (c *Client) GetVcardInfo(toID int64) (VCardInfo, error)
- func (c *Client) IsBot(id int64, own bool) (bool, error)
- func (c *Client) IsPM(id int64, own bool) (bool, error)
- func (c *Client) LastSeenStatus(timestamp int64) string
- func (c *Client) MarkAsRead(chatId, messageId int64)
- func (c *Client) Online() bool
- func (c *Client) OwnChatsKeys() []int64
- func (c *Client) PermastoreFile(file *client.File, clone bool) (string, string)
- func (c *Client) PrepareOutgoingMessageContent(text string) client.InputMessageContent
- func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool, bool)
- func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message)
- func (c *Client) ProcessOutgoingMessage(chatID int64, text string, returnJid string, replyId int64, replaceId int64, ...) int64
- func (c *Client) ProcessStatusUpdate(chatID int64, status string, show string, own bool, oldArgs ...args.V) error
- func (c *Client) ProcessTransportCommand(cmdline string, resource string) (string, bool)
- func (c *Client) SetEmptyAvatarHash(chatId int64)
- func (c *Client) SetPhoneNumber(login string) error
- func (c *Client) StartLoginWizard(inCommand bool)
- func (c *Client) StatusesRange() chan *cache.Status
- func (c *Client) StopLoginWizard()
- func (c *Client) TryLogin(resource string, login string) error
- func (c *Client) UpdateChatNicknames()
- func (c *Client) UpdateLastChatMessageId(chatId int64, messageId string)
- type CommandType
- type DelayedStatus
- type HashedAvatar
- type MembersList
- type VCardInfo
Constants ¶
const AVATAR_SIZE_LIMIT int64 = 128 * 1024
const TelegramAuthDone string = "Authorization is done already"
const TelegramNotInitialized string = "Telegram connection is not initialized yet"
Variables ¶
This section is empty.
Functions ¶
func CommandToHelpString ¶ added in v1.10.0
CommandToHelpString builds a text description of a command
func GetCommand ¶ added in v1.10.0
func GetCommand(typ CommandType, cmd string) (command, bool)
GetCommand obtains one command
func GetCommands ¶ added in v1.10.0
func GetCommands(typ CommandType) map[string]command
GetCommands exposes the set of commands
func IsCommandForChatType ¶ added in v1.10.0
IsCommandFor checks the suitability of a command for a chat type
func SortedCommandKeys ¶ added in v1.10.0
SortedCommandKeys sorts a slice with command keys
Types ¶
type BotCommand ¶ added in v1.12.0
type ChatType ¶ added in v1.10.0
type ChatType int
ChatType is an enum of chat types, roughly corresponding to TDLib's one but better
type Client ¶
type Client struct {
Session *persistence.Session
DelayedStatuses map[int64]*DelayedStatus
DelayedStatusesLock sync.Mutex
LastBotCmdString string
XmppClientFeatures map[string]*[]string
XmppClientFeaturesLock sync.Mutex
AvatarHashes map[int64]*HashedAvatar
AvatarHashesLock 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
AddToEditOutbox temporarily store the resource from which a replace message with given ID was sent
func (*Client) AddToOutbox ¶ added in v1.7.0
AddToOutbox remembers the resource from which a message with given ID was sent
func (*Client) Disconnect ¶
Disconnect drops TDlib connection and returns the flag indicating if disconnecting is permitted
func (*Client) DownloadFile ¶
DownloadFile actually obtains a file by id given by TDlib
func (*Client) ForceOpenFile ¶ added in v1.6.0
ForceOpenFile reliably obtains a file if possible
func (*Client) FormatContact ¶ added in v1.10.0
FormatContact retrieves a complete "full name (@usernames)" string for display
func (*Client) GetBotMenu ¶ added in v1.12.0
func (c *Client) GetBotMenu(id int64) (*BotLink, []*BotCommand, error)
GetBotMenu retrieves the bot's attachment menu
func (*Client) GetChatDescription ¶ added in v1.2.1
GetChatDescription obtains bio or description according to the chat type
func (*Client) GetChatMembers ¶ added in v1.10.0
func (c *Client) GetChatMembers(chatID int64, limited bool, query string, membersList MembersList) ([]*client.ChatMember, error)
GetChatMembers retrieves a list of chat members. "Limited" mode works only if there are no more than 20 members at all
func (*Client) GetChatType ¶ added in v1.10.0
GetChatType obtains chat type from its information
func (*Client) GetContactByID ¶
func (c *Client) GetContactByID(id int64, chat *client.Chat, own bool) (*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, own bool) (*client.Chat, *client.User, error)
GetContactByUsername resolves username to user id retrieves user and chat information
func (*Client) GetLoginWizardNextStage ¶ added in v1.11.0
GetLoginWizardNextStage waits for the next stage from the channel
func (*Client) GetPhotoBase64 ¶ added in v1.9.7
GetPhotoBase64 reads file data as Base64
func (*Client) GetPhotoSha1 ¶ added in v1.9.7
GetPhotoSha1 computes the photo hash
func (*Client) GetPhotoSize ¶ added in v1.12.4
GetPhotoSize return at least a rough size
func (*Client) GetSenderId ¶ added in v1.10.0
func (c *Client) GetSenderId(sender client.MessageSender) (senderId int64)
func (*Client) GetVcardInfo ¶ added in v1.6.0
func (*Client) LastSeenStatus ¶
LastSeenStatus formats a timestamp to a "Last seen at" string
func (*Client) MarkAsRead ¶ added in v1.9.0
MarkAsRead marks a message as read
func (*Client) OwnChatsKeys ¶ added in v1.12.6
OwnChatsKeys proxies the following function from unexported cache
func (*Client) PermastoreFile ¶ added in v1.6.0
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 ¶
ProcessChatCommand executes a command sent in a mapped chat and returns a response, the status of command support and the execution success result
func (*Client) ProcessIncomingMessage ¶ added in v1.2.0
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, raw bool) 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, own bool, oldArgs ...args.V) error
ProcessStatusUpdate sets contact status
func (*Client) ProcessTransportCommand ¶
ProcessTransportCommand executes a command sent directly to the component and returns a response and execution success result
func (*Client) SetEmptyAvatarHash ¶ added in v1.9.7
SetEmptyAvatarHash puts a dummy value into the cache to avoid attempting to fetch surely missing avatars
func (*Client) SetPhoneNumber ¶ added in v1.8.0
func (*Client) StartLoginWizard ¶ added in v1.11.0
StartLoginWizard initiates a loginWizard object
func (*Client) StatusesRange ¶
StatusesRange proxies the following function from unexported cache
func (*Client) StopLoginWizard ¶ added in v1.11.0
func (c *Client) StopLoginWizard()
StopLoginWizard safely destroys the loginWizard object
func (*Client) UpdateChatNicknames ¶ added in v1.7.0
func (c *Client) UpdateChatNicknames()
func (*Client) UpdateLastChatMessageId ¶ added in v1.9.0
type CommandType ¶ added in v1.10.0
type CommandType int
CommandType disinguishes command sets by chat
const ( CommandTypeTransport CommandType = iota CommandTypeChat )
type DelayedStatus ¶
DelayedStatus describes an online status expiring on timeout
type HashedAvatar ¶ added in v1.9.7
HashedAvatar stores a SHA-1 hash and a Telegram file ID
type MembersList ¶ added in v1.10.0
type MembersList int
MembersList is an enum of member list filters
const ( MembersListMembers MembersList = iota MembersListRestricted MembersListBanned MembersListBannedAndAdministrators )