Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add messages bulk delete method #1151

Open
wants to merge 2 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
{
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)

Check warning on line 192 in src/Methods/EditMessage.php

View check run for this annotation

Codecov / codecov/patch

src/Methods/EditMessage.php#L192

Added line #L192 was not covered by tests
{
if (isset($params['message_ids'])) {
$params['message_ids'] = json_encode($params['message_ids'], JSON_THROW_ON_ERROR);

Check warning on line 195 in src/Methods/EditMessage.php

View check run for this annotation

Codecov / codecov/patch

src/Methods/EditMessage.php#L194-L195

Added lines #L194 - L195 were not covered by tests
}

return $this->post('deleteMessages', $params)->getResult();

Check warning on line 198 in src/Methods/EditMessage.php

View check run for this annotation

Codecov / codecov/patch

src/Methods/EditMessage.php#L198

Added line #L198 was not covered by tests
}
}
Loading