unreal4u / telegram-api

Complete async capable Telegram bot API implementation for PHP7
https://github.com/unreal4u/telegram-api/wiki
MIT License
784 stars 172 forks source link

How to use MessageEntity? #131

Open tilonuz99 opened 3 years ago

tilonuz99 commented 3 years ago

`<?php use \unreal4u\TelegramAPI\Telegram\Types\Update; use \React\EventLoop\Factory; use \unreal4u\TelegramAPI\HttpClientRequestHandler; use \unreal4u\TelegramAPI\TgLog; use \unreal4u\TelegramAPI\Telegram\Methods\DeleteMessage; use \unreal4u\TelegramAPI\Telegram\Methods\SendMessage; use \unreal4u\TelegramAPI\Telegram\Types\MessageEntity;

$loop = Factory::create(); $tgLog = new TgLog("**:AAFpSHsiJiUbzOnQuscxTAqnKdeH_MXuWl8", new HttpClientRequestHandler($loop)); $updateData = json_decode(file_get_contents('php://input'), true); $update = new Update($updateData); if ($update->message->text == '/start') { $date = new MessageEntity(); $chat_id = $message->chat->id; $sm = new SendMessage(); $sm->text = json_encode($date); $sm->chat_id = $chat_id; $tgLog->performApiRequest($sm); $loop->run(); }`

{"type":"","offset":0,"length":0,"url":"","user":null}

i'm getting an empty type, but I need to get bot_command @unreal4u

unreal4u commented 3 years ago

Take a look at the following example for MessageEntities: https://github.com/unreal4u/telegram-bots/blob/master/src/Bots/Base.php#L408-L436