Skip to content

Commit

Permalink
Merge pull request #308 from TelegramBot/feature/copyMessage
Browse files Browse the repository at this point in the history
Add copyMessage method
  • Loading branch information
MyZik authored Jan 13, 2021
2 parents 6a77fc4 + 4718e8a commit 87dba9f
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/BotApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace TelegramBot\Api;

use TelegramBot\Api\Types\ArrayOfChatMemberEntity;
use TelegramBot\Api\Types\ArrayOfMessageEntity;
use TelegramBot\Api\Types\ArrayOfMessages;
use TelegramBot\Api\Types\ArrayOfUpdates;
use TelegramBot\Api\Types\Chat;
Expand Down Expand Up @@ -341,6 +342,50 @@ public function sendMessage(
]));
}

/**
* @param int|string $chatId
* @param int|string $fromChatId
* @param int $messageId
* @param string|null $caption
* @param string|null $parseMode
* @param ArrayOfMessageEntity|null $captionEntities
* @param bool $disableNotification
* @param int|null $replyToMessageId
* @param bool $allowSendingWithoutReply
* @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply|
* Types\ReplyKeyboardRemove|null $replyMarkup
*
* @return Message
* @throws Exception
* @throws HttpException
* @throws InvalidJsonException
*/
public function copyMessage(
$chatId,
$fromChatId,
$messageId,
$caption = null,
$parseMode = null,
$captionEntities = null,
$disableNotification = false,
$replyToMessageId = null,
$allowSendingWithoutReply = false,
$replyMarkup = null
) {
return Message::fromResponse($this->call('sendMessage', [
'chat_id' => $chatId,
'from_chat_id' => $fromChatId,
'message_id' => (int)$messageId,
'caption' => $caption,
'parse_mode' => $parseMode,
'caption_entities' => $captionEntities,
'disable_notification' => (bool)$disableNotification,
'reply_to_message_id' => (int)$replyToMessageId,
'allow_sending_without_reply' => (bool)$allowSendingWithoutReply,
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
]));
}

/**
* Use this method to send phone contacts
*
Expand Down

0 comments on commit 87dba9f

Please sign in to comment.