Skip to content

Commit 87dba9f

Browse files
authored
Merge pull request #308 from TelegramBot/feature/copyMessage
Add copyMessage method
2 parents 6a77fc4 + 4718e8a commit 87dba9f

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/BotApi.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace TelegramBot\Api;
44

55
use TelegramBot\Api\Types\ArrayOfChatMemberEntity;
6+
use TelegramBot\Api\Types\ArrayOfMessageEntity;
67
use TelegramBot\Api\Types\ArrayOfMessages;
78
use TelegramBot\Api\Types\ArrayOfUpdates;
89
use TelegramBot\Api\Types\Chat;
@@ -341,6 +342,50 @@ public function sendMessage(
341342
]));
342343
}
343344

345+
/**
346+
* @param int|string $chatId
347+
* @param int|string $fromChatId
348+
* @param int $messageId
349+
* @param string|null $caption
350+
* @param string|null $parseMode
351+
* @param ArrayOfMessageEntity|null $captionEntities
352+
* @param bool $disableNotification
353+
* @param int|null $replyToMessageId
354+
* @param bool $allowSendingWithoutReply
355+
* @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply|
356+
* Types\ReplyKeyboardRemove|null $replyMarkup
357+
*
358+
* @return Message
359+
* @throws Exception
360+
* @throws HttpException
361+
* @throws InvalidJsonException
362+
*/
363+
public function copyMessage(
364+
$chatId,
365+
$fromChatId,
366+
$messageId,
367+
$caption = null,
368+
$parseMode = null,
369+
$captionEntities = null,
370+
$disableNotification = false,
371+
$replyToMessageId = null,
372+
$allowSendingWithoutReply = false,
373+
$replyMarkup = null
374+
) {
375+
return Message::fromResponse($this->call('sendMessage', [
376+
'chat_id' => $chatId,
377+
'from_chat_id' => $fromChatId,
378+
'message_id' => (int)$messageId,
379+
'caption' => $caption,
380+
'parse_mode' => $parseMode,
381+
'caption_entities' => $captionEntities,
382+
'disable_notification' => (bool)$disableNotification,
383+
'reply_to_message_id' => (int)$replyToMessageId,
384+
'allow_sending_without_reply' => (bool)$allowSendingWithoutReply,
385+
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
386+
]));
387+
}
388+
344389
/**
345390
* Use this method to send phone contacts
346391
*

0 commit comments

Comments
 (0)