From ebea95b93009b0f7dbb2a55d7ce39a54a23ca733 Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 8 Oct 2024 12:32:36 -0400 Subject: [PATCH] Updated Formatting --- src/TgBotLib/Methods/ForwardMessage.php | 87 +++++++++++----------- src/TgBotLib/Methods/ForwardMessages.php | 92 ++++++++++++------------ 2 files changed, 89 insertions(+), 90 deletions(-) diff --git a/src/TgBotLib/Methods/ForwardMessage.php b/src/TgBotLib/Methods/ForwardMessage.php index adffb80..bdc455b 100644 --- a/src/TgBotLib/Methods/ForwardMessage.php +++ b/src/TgBotLib/Methods/ForwardMessage.php @@ -1,51 +1,50 @@ value, $parameters))); - } + /** + * Use this method to forward messages of any kind. Service messages and messages with protected content can't be + * forwarded. On success, the sent Message is returned. + * + * @param Bot $bot + * @param array $parameters + * @return Message + * @throws TelegramException + */ + public static function execute(Bot $bot, array $parameters = []): Message + { + return Message::fromArray(self::executeCurl(self::buildPost($bot, Methods::FORWARD_MESSAGE->value, $parameters))); + } - /** - * @inheritDoc - */ - public static function getRequiredParameters(): array - { - return [ - 'chat_id', - 'from_chat_id', - 'message_id' - ]; - } + /** + * @inheritDoc + */ + public static function getRequiredParameters(): array + { + return [ + 'chat_id', + 'from_chat_id', + 'message_id' + ]; + } - /** - * @inheritDoc - */ - public static function getOptionalParameters(): array - { - return [ - 'message_thread_id', - 'disable_notification', - 'protect_content' - ]; - } -} \ No newline at end of file + /** + * @inheritDoc + */ + public static function getOptionalParameters(): array + { + return [ + 'message_thread_id', + 'disable_notification', + 'protect_content' + ]; + } + } \ No newline at end of file diff --git a/src/TgBotLib/Methods/ForwardMessages.php b/src/TgBotLib/Methods/ForwardMessages.php index ba52dbb..0376eea 100644 --- a/src/TgBotLib/Methods/ForwardMessages.php +++ b/src/TgBotLib/Methods/ForwardMessages.php @@ -1,53 +1,53 @@ MessageId::fromArray($messageId), - self::executeCurl(self::buildPost($bot, Methods::FORWARD_MESSAGES->value, $parameters)) - ); - } + /** + * Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or + * forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. + * Album grouping is kept for forwarded messages. On success, an array of MessageId of the sent messages is returned. + * + * @param Bot $bot + * @param array $parameters + * @return MessageId[] + * @throws TelegramException + */ + public static function execute(Bot $bot, array $parameters = []): array + { + return array_map(fn($messageId) => MessageId::fromArray($messageId), + self::executeCurl(self::buildPost($bot, Methods::FORWARD_MESSAGES->value, $parameters)) + ); + } - /** - * @inheritDoc - */ - public static function getRequiredParameters(): ?array - { - return [ - 'chat_id', - 'from_chat_id', - 'message_ids' - ]; - } + /** + * @inheritDoc + */ + public static function getRequiredParameters(): ?array + { + return [ + 'chat_id', + 'from_chat_id', + 'message_ids' + ]; + } - /** - * @inheritDoc - */ - public static function getOptionalParameters(): ?array - { - return [ - 'message_thread_id', - 'disable_notification', - 'protect_content' - ]; - } -} \ No newline at end of file + /** + * @inheritDoc + */ + public static function getOptionalParameters(): ?array + { + return [ + 'message_thread_id', + 'disable_notification', + 'protect_content' + ]; + } + } \ No newline at end of file