diff --git a/src/TgBotLib/Enums/Methods.php b/src/TgBotLib/Enums/Methods.php index 128b606..308f9a4 100644 --- a/src/TgBotLib/Enums/Methods.php +++ b/src/TgBotLib/Enums/Methods.php @@ -47,6 +47,7 @@ use TgBotLib\Methods\SendVoice; use TgBotLib\Methods\SetChatAdministratorCustomTitle; use TgBotLib\Methods\SetChatPermissions; + use TgBotLib\Methods\SetChatPhoto; use TgBotLib\Methods\SetMessageReaction; use TgBotLib\Methods\SetWebhook; use TgBotLib\Methods\UnbanChatMember; @@ -100,6 +101,7 @@ case REVOKE_CHAT_INVITE_LINK = 'revokeChatInviteLink'; case APPROVE_CHAT_JOIN_REQUEST = 'approveChatJoinRequest'; case DECLINE_CHAT_JOIN_REQUEST = 'declineChatJoinRequest'; + case SET_CHAT_PHOTO = 'setChatPhoto'; /** * Executes a command on the provided bot with the given parameters. @@ -159,6 +161,7 @@ self::REVOKE_CHAT_INVITE_LINK => RevokeChatInviteLink::execute($bot, $parameters), self::APPROVE_CHAT_JOIN_REQUEST => ApproveChatJoinRequest::execute($bot, $parameters), self::DECLINE_CHAT_JOIN_REQUEST => DeclineChatJoinRequest::execute($bot, $parameters), + self::SET_CHAT_PHOTO => SetChatPhoto::execute($bot, $parameters), }; } } diff --git a/src/TgBotLib/Methods/SetChatPhoto.php b/src/TgBotLib/Methods/SetChatPhoto.php new file mode 100644 index 0000000..8be2f32 --- /dev/null +++ b/src/TgBotLib/Methods/SetChatPhoto.php @@ -0,0 +1,53 @@ +value, 'photo', $photo, array_diff_key($parameters, ['photo' => null])); + return (bool)(self::executeCurl($curl)); + } + } + + // If photo is a file_id or URL, use regular POST method + return (bool)(self::executeCurl(self::buildPost($bot, Methods::SET_CHAT_PHOTO->value, $parameters))); + } + + /** + * @inheritDoc + */ + public static function getRequiredParameters(): ?array + { + return [ + 'chat_id', + 'photo' + ]; + } + + /** + * @inheritDoc + */ + public static function getOptionalParameters(): ?array + { + return null; + } + } \ No newline at end of file