Skip to content

Commit

Permalink
Add messages bulk delete method (#1151)
Browse files Browse the repository at this point in the history
* Add messages bulk delete method

* Add methods to facade

---------

Co-authored-by: Serhii Andriichuk <andriichuk29@gmail.com>
  • Loading branch information
serge-webspark and andriichuk authored Dec 28, 2024
1 parent 945aecd commit 6d372cb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Laravel/Facades/Telegram.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 25 additions & 0 deletions src/Methods/EditMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* <code>
* $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
* ]
* </code>
*
* @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();
}
}

0 comments on commit 6d372cb

Please sign in to comment.