From a02074c6c556ab76a79792122f4ddf997f1c2e2f Mon Sep 17 00:00:00 2001 From: Mahdi Date: Thu, 3 Aug 2023 19:14:57 +0330 Subject: [PATCH] Fix the translate method bug - Add phpDoc for CallbackQuery class methods --- src/EventHandler/CallbackQuery.php | 18 ++++++++++++++++++ src/EventHandler/Message.php | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/EventHandler/CallbackQuery.php b/src/EventHandler/CallbackQuery.php index 6eb438343..e362f18b9 100644 --- a/src/EventHandler/CallbackQuery.php +++ b/src/EventHandler/CallbackQuery.php @@ -46,6 +46,12 @@ final class CallbackQuery extends Update $this->gameShortName = $rawCallback['game_short_name'] ?? ''; } + /** + * @param string $message Popup to show + * @param bool $alert Whether to show the message as a popup instead of a toast notification + * @param string|null $url URL to open + * @param int $cacheTime Cache validity (default set to 5 min based on telegram official docs ...) + */ public function answer( string $message, bool $alert = false, @@ -64,6 +70,18 @@ final class CallbackQuery extends Update ); } + /** + * Edit message text. + * + * @param string $message New message + * @param array|null $replyMarkup Reply markup for inline keyboards + * @param array|null $entities Message entities for styled text + * @param ParseMode $parseMode Whether to parse HTML or Markdown markup in the message + * @param int|null $scheduleDate Scheduled message date for scheduled messages + * @param bool $noWebpage Disable webpage preview + * + */ + public function edit( ?string $message, ?array $replyMarkup = null, diff --git a/src/EventHandler/Message.php b/src/EventHandler/Message.php index 127ab57a8..e27734a01 100644 --- a/src/EventHandler/Message.php +++ b/src/EventHandler/Message.php @@ -270,7 +270,9 @@ abstract class Message extends AbstractMessage public function translate( string $toLang = 'en' ): string { - Assert::notEmpty($this->message); + if (empty($message = $this->message)) { + return $message; + } $result = $this->getClient()->methodCallAsyncRead( 'messages.translateText', [