diff --git a/src/TgBotLib/Enums/Methods.php b/src/TgBotLib/Enums/Methods.php index f97b53b..b128974 100644 --- a/src/TgBotLib/Enums/Methods.php +++ b/src/TgBotLib/Enums/Methods.php @@ -27,6 +27,7 @@ use TgBotLib\Methods\EditChatSubscriptionInviteLink; use TgBotLib\Methods\EditForumTopic; use TgBotLib\Methods\EditGeneralForumTopic; + use TgBotLib\Methods\EditMessageText; use TgBotLib\Methods\ExportChatInviteLink; use TgBotLib\Methods\ForwardMessage; use TgBotLib\Methods\ForwardMessages; @@ -186,6 +187,7 @@ case GET_CHAT_MENU_BUTTON = 'getChatMenuButton'; case SET_MY_DEFAULT_ADMINISTRATOR_RIGHTS = 'setMyDefaultAdministratorRights'; case GET_MY_DEFAULT_ADMINISTRATOR_RIGHTS = 'getMyDefaultAdministratorRights'; + case EDIT_MESSAGE_TEXT = 'editMessageText'; /** * Executes a command on the provided bot with the given parameters. @@ -288,6 +290,7 @@ self::GET_CHAT_MENU_BUTTON => GetChatMenuButton::execute($bot, $parameters), self::SET_MY_DEFAULT_ADMINISTRATOR_RIGHTS => SetMyDefaultAdministratorRights::execute($bot, $parameters), self::GET_MY_DEFAULT_ADMINISTRATOR_RIGHTS => GetMyDefaultAdministratorRights::execute($bot, $parameters), + self::EDIT_MESSAGE_TEXT => EditMessageText::execute($bot, $parameters), }; } } diff --git a/src/TgBotLib/Methods/EditMessageText.php b/src/TgBotLib/Methods/EditMessageText.php new file mode 100644 index 0000000..8cac129 --- /dev/null +++ b/src/TgBotLib/Methods/EditMessageText.php @@ -0,0 +1,85 @@ +toArray(); + } + else + { + $entities[] = $entity; + } + } + + $parameters['entities'] = $entities; + } + + if (isset($parameters['reply_markup'])) + { + if ($parameters['reply_markup'] instanceof ObjectTypeInterface) + { + $parameters['reply_markup'] = json_encode($parameters['reply_markup']->toArray()); + } + elseif (is_array($parameters['reply_markup'])) + { + $parameters['reply_markup'] = json_encode($parameters['reply_markup']); + } + } + + if(isset($parameters['link_preview_options']) && $parameters['link_preview_options'] instanceof ObjectTypeInterface) + { + $parameters['link_preview_options'] = $parameters['link_preview_options']->toArray(); + } + + return Message::fromArray(self::executeCurl(self::buildPost($bot, Methods::EDIT_MESSAGE_TEXT->value, $parameters))); + } + + /** + * @inheritDoc + */ + public static function getRequiredParameters(): ?array + { + return [ + 'text' + ]; + } + + /** + * @inheritDoc + */ + public static function getOptionalParameters(): ?array + { + return [ + 'business_connection_id', + 'chat_id', + 'message_id', + 'inline_message_id', + 'parse_mode', + 'entities', + 'link_preview_options', + 'reply_markup' + ]; + } + } \ No newline at end of file