TelegramAdapter
in package
implements
Adapter, HandlesActions, HandlesReactions, HandlesSlashCommands, HasAuthorInfo, SupportsDeleteMessages, SupportsEditMessages
Table of Contents
Interfaces
- Adapter
- HandlesActions
- HandlesReactions
- HandlesSlashCommands
- HasAuthorInfo
- SupportsDeleteMessages
- SupportsEditMessages
Constants
- ATTACHMENT_UPLOADS : mixed = ['audio' => ['field' => 'audio', 'method' => 's...
Properties
- $apiUrl : string
- $botToken : string
- $botUserId : string|null
- $formatConverter : TelegramFormatConverter
- $httpClient : ClientInterface
- $psrFactory : Psr17Factory|null
- $secretToken : string|null
- $pendingCallbackQueryId : string|null
Methods
- __construct() : mixed
- acknowledgeAction() : ResponseInterface|null
- Acknowledge the action to the platform (e.g. Telegram answerCallbackQuery).
- addReaction() : void
- channelIdFromThreadId() : string
- createResponse() : ResponseInterface|null
- decodeThreadId() : mixed
- deleteMessage() : void
- disconnect() : void
- editMessage() : SentMessage
- encodeThreadId() : string
- fetchChannelInfo() : ChannelInfo|null
- fetchMessages() : FetchResult
- fetchThread() : ThreadInfo
- getAuthorInfo() : Author
- getBotUserId() : string|null
- getFormatConverter() : FormatConverter|null
- getName() : string
- getUser() : UserInfo|null
- initialize() : void
- openDM() : string|null
- parseAction() : Author, actionId: string, value: ?string, threadId: string, messageId: string, userId: string, isBot: bool, isMe: bool, triggerId: ?string, raw: mixed, callbackQueryId: ?string, originId: ?string}|null
- parseReaction() : Author, emoji: string, rawEmoji: string, added: bool, threadId: string, messageId: string, userId: string, raw: mixed, originId: ?string}|null
- parseSlashCommand() : Author, command: string, text: string, userId: string, isBot: bool, isMe: bool, channelId: string, triggerId: ?string, raw: mixed}|null
- parseWebhook() : Message
- postMessage() : SentMessage
- removeReaction() : void
- startTyping() : void
- stream() : SentMessage|null
- verifyWebhook() : ResponseInterface|null
- apiCall() : array<string|int, mixed>
- apiCallMultipart() : array<string|int, mixed>
- applyEntities() : string
- extractAttachments() : array<string|int, Attachment>
- getTextContent() : string
Constants
ATTACHMENT_UPLOADS
private
mixed
ATTACHMENT_UPLOADS
= ['audio' => ['field' => 'audio', 'method' => 'sendAudio'], 'file' => ['field' => 'document', 'method' => 'sendDocument'], 'image' => ['field' => 'photo', 'method' => 'sendPhoto'], 'video' => ['field' => 'video', 'method' => 'sendVideo']]
Properties
$apiUrl read-only
protected
string
$apiUrl
= 'https://api.telegram.org'
$botToken read-only
protected
string
$botToken
$botUserId
protected
string|null
$botUserId
= null
$formatConverter
protected
TelegramFormatConverter
$formatConverter
$httpClient read-only
protected
ClientInterface
$httpClient
$psrFactory read-only
protected
Psr17Factory|null
$psrFactory
= null
$secretToken
protected
string|null
$secretToken
$pendingCallbackQueryId
private
string|null
$pendingCallbackQueryId
= null
Methods
__construct()
public
__construct(string $botToken, ClientInterface $httpClient[, string|null $secretToken = null ][, string $apiUrl = 'https://api.telegram.org' ][, Psr17Factory|null $psrFactory = null ]) : mixed
Parameters
- $botToken : string
- $httpClient : ClientInterface
- $secretToken : string|null = null
- $apiUrl : string = 'https://api.telegram.org'
- $psrFactory : Psr17Factory|null = null
acknowledgeAction()
Acknowledge the action to the platform (e.g. Telegram answerCallbackQuery).
public
acknowledgeAction(string|null $callbackQueryId) : ResponseInterface|null
Parameters
- $callbackQueryId : string|null
Return values
ResponseInterface|nulladdReaction()
public
addReaction(string $threadId, string $messageId, string $emoji) : void
Parameters
- $threadId : string
- $messageId : string
- $emoji : string
channelIdFromThreadId()
public
channelIdFromThreadId(string $threadId) : string
Parameters
- $threadId : string
Return values
stringcreateResponse()
public
createResponse() : ResponseInterface|null
Return values
ResponseInterface|nulldecodeThreadId()
public
decodeThreadId(string $threadId) : mixed
Parameters
- $threadId : string
deleteMessage()
public
deleteMessage(string $threadId, string $messageId) : void
Parameters
- $threadId : string
- $messageId : string
disconnect()
public
disconnect() : void
editMessage()
public
editMessage(string $threadId, string $messageId, PostableMessage $message) : SentMessage
Parameters
- $threadId : string
- $messageId : string
- $message : PostableMessage
Return values
SentMessageencodeThreadId()
public
encodeThreadId(mixed $platformData) : string
Parameters
- $platformData : mixed
Return values
stringfetchChannelInfo()
public
fetchChannelInfo(string $channelId) : ChannelInfo|null
Parameters
- $channelId : string
Return values
ChannelInfo|nullfetchMessages()
public
fetchMessages(string $threadId[, FetchOptions|null $options = null ]) : FetchResult
Parameters
- $threadId : string
- $options : FetchOptions|null = null
Return values
FetchResultfetchThread()
public
fetchThread(string $threadId) : ThreadInfo
Parameters
- $threadId : string
Return values
ThreadInfogetAuthorInfo()
public
getAuthorInfo(Author $author) : Author
Parameters
- $author : Author
Return values
AuthorgetBotUserId()
public
getBotUserId() : string|null
Return values
string|nullgetFormatConverter()
public
getFormatConverter() : FormatConverter|null
Return values
FormatConverter|nullgetName()
public
getName() : string
Return values
stringgetUser()
public
getUser(string $userId) : UserInfo|null
Parameters
- $userId : string
Return values
UserInfo|nullinitialize()
public
initialize(Chat $chat) : void
Parameters
- $chat : Chat
openDM()
public
openDM(string $userId) : string|null
Parameters
- $userId : string
Return values
string|nullparseAction()
public
parseAction(ServerRequestInterface $request) : Author, actionId: string, value: ?string, threadId: string, messageId: string, userId: string, isBot: bool, isMe: bool, triggerId: ?string, raw: mixed, callbackQueryId: ?string, originId: ?string}|null
Parameters
- $request : ServerRequestInterface
Return values
Author, actionId: string, value: ?string, threadId: string, messageId: string, userId: string, isBot: bool, isMe: bool, triggerId: ?string, raw: mixed, callbackQueryId: ?string, originId: ?string}|nullparseReaction()
public
parseReaction(ServerRequestInterface $request) : Author, emoji: string, rawEmoji: string, added: bool, threadId: string, messageId: string, userId: string, raw: mixed, originId: ?string}|null
Parameters
- $request : ServerRequestInterface
Return values
Author, emoji: string, rawEmoji: string, added: bool, threadId: string, messageId: string, userId: string, raw: mixed, originId: ?string}|nullparseSlashCommand()
public
parseSlashCommand(ServerRequestInterface $request) : Author, command: string, text: string, userId: string, isBot: bool, isMe: bool, channelId: string, triggerId: ?string, raw: mixed}|null
Parameters
- $request : ServerRequestInterface
Return values
Author, command: string, text: string, userId: string, isBot: bool, isMe: bool, channelId: string, triggerId: ?string, raw: mixed}|nullparseWebhook()
public
parseWebhook(ServerRequestInterface $request) : Message
Parameters
- $request : ServerRequestInterface
Return values
MessagepostMessage()
public
postMessage(string $threadId, PostableMessage $message) : SentMessage
Parameters
- $threadId : string
- $message : PostableMessage
Return values
SentMessageremoveReaction()
public
removeReaction(string $threadId, string $messageId, string $emoji) : void
Parameters
- $threadId : string
- $messageId : string
- $emoji : string
startTyping()
public
startTyping(string $threadId) : void
Parameters
- $threadId : string
stream()
public
stream(string $threadId, iterable<string|int, mixed> $textStream[, array<string|int, mixed> $options = [] ]) : SentMessage|null
Parameters
- $threadId : string
- $textStream : iterable<string|int, mixed>
- $options : array<string|int, mixed> = []
Return values
SentMessage|nullverifyWebhook()
public
verifyWebhook(ServerRequestInterface $request) : ResponseInterface|null
Parameters
- $request : ServerRequestInterface
Return values
ResponseInterface|nullapiCall()
protected
apiCall(string $method, array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $method : string
- $params : array<string|int, mixed>
Return values
array<string|int, mixed>apiCallMultipart()
protected
apiCallMultipart(string $method, array<string|int, mixed> $params[, FileUpload|null $file = null ]) : array<string|int, mixed>
Parameters
- $method : string
- $params : array<string|int, mixed>
- $file : FileUpload|null = null
Return values
array<string|int, mixed>applyEntities()
protected
applyEntities(string $text, array<string|int, mixed> $entities) : string
Parameters
- $text : string
- $entities : array<string|int, mixed>
Return values
stringextractAttachments()
protected
extractAttachments(array<string|int, mixed> $tgMessage) : array<string|int, Attachment>
Parameters
- $tgMessage : array<string|int, mixed>
Return values
array<string|int, Attachment>getTextContent()
private
getTextContent(PostableMessage $message) : string
Parameters
- $message : PostableMessage