From d525150b258729cfe8f11ec41c1244d2c25eaf92 Mon Sep 17 00:00:00 2001 From: Serhii Andriichuk Date: Thu, 12 Dec 2024 06:36:55 +0200 Subject: [PATCH 1/2] Add messages bulk delete method --- src/Methods/EditMessage.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Methods/EditMessage.php b/src/Methods/EditMessage.php index dcfce9cb..029e5a16 100644 --- a/src/Methods/EditMessage.php +++ b/src/Methods/EditMessage.php @@ -172,4 +172,29 @@ public function deleteMessage(array $params) { return $this->post('deleteMessage', $params)->getResult(); } + + /** + * Delete multiple messages simultaneously. If some of the specified messages can't be found, they are skipped. Returns True on success. + * + * + * $params = [ + * 'chat_id' => '', // int|string - Required. Unique identifier for the target chat or username of the target channel (in the format "@channelusername") + * 'message_ids' => [], // int[] - Required. List of 1-100 identifiers of messages to delete. @see self::deleteMessage() for limitations on which messages can be deleted + * ] + * + * + * @link https://core.telegram.org/bots/api#deletemessages + * + * @return bool + * + * @throws TelegramSDKException + */ + public function deleteMessages(array $params) + { + if (isset($params['message_ids'])) { + $params['message_ids'] = json_encode($params['message_ids'], JSON_THROW_ON_ERROR); + } + + return $this->post('deleteMessages', $params)->getResult(); + } } From 68502f50563fe7a050ca2fc1dbb89d428e4cf5a9 Mon Sep 17 00:00:00 2001 From: Serhii Andriichuk Date: Thu, 12 Dec 2024 06:46:15 +0200 Subject: [PATCH 2/2] Add methods to facade --- src/Laravel/Facades/Telegram.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Laravel/Facades/Telegram.php b/src/Laravel/Facades/Telegram.php index af23e080..233cb341 100644 --- a/src/Laravel/Facades/Telegram.php +++ b/src/Laravel/Facades/Telegram.php @@ -65,7 +65,8 @@ * @method static \Telegram\Bot\Objects\Message editMessageMedia(array $params) * @method static \Telegram\Bot\Objects\Message editMessageReplyMarkup(array $params) * @method static \Telegram\Bot\Objects\Poll stopPoll(array $params) - * @method static void deleteMessage(array $params) + * @method static bool deleteMessage(array $params) + * @method static bool deleteMessages(array $params) * @method static \Telegram\Bot\Objects\Message sendGame(array $params) * @method static \Telegram\Bot\Objects\Message setGameScore(array $params) * @method static array getGameHighScores(array $params)