From 58b35ecb2a5b756945d8d1e58d176a96883ebf6d Mon Sep 17 00:00:00 2001 From: Netkas Date: Sun, 12 Feb 2023 23:19:33 -0500 Subject: [PATCH] Added \TgBotLib\Objects > KeyboardButtonRequestChat --- .../Objects/KeyboardButtonRequestChat.php | 180 ++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 src/TgBotLib/Objects/KeyboardButtonRequestChat.php diff --git a/src/TgBotLib/Objects/KeyboardButtonRequestChat.php b/src/TgBotLib/Objects/KeyboardButtonRequestChat.php new file mode 100644 index 0000000..96fe54a --- /dev/null +++ b/src/TgBotLib/Objects/KeyboardButtonRequestChat.php @@ -0,0 +1,180 @@ +request_id; + } + + /** + * Pass True to request a channel chat, pass False to request a group or a supergroup chat. + * + * @return bool + */ + public function isChatIsChannel(): bool + { + return $this->chat_is_channel; + } + + /** + * Optional. Pass True to request a forum supergroup, pass False to request a non-forum chat. + * If not specified, no additional restrictions are applied. + * + * @return bool + */ + public function isChatIsForum(): bool + { + return $this->chat_is_forum; + } + + /** + * Optional. Pass True to request a supergroup or a channel with a username, pass False to request a chat + * without a username. If not specified, no additional restrictions are applied. + * + * @return bool + */ + public function isChatHasUsername(): bool + { + return $this->chat_has_username; + } + + /** + * Optional. Pass True to request a chat owned by the user. Otherwise, no additional restrictions are applied. + * + * @return bool + */ + public function isChatIsCreated(): bool + { + return $this->chat_is_created; + } + + /** + * Optional. A JSON-serialized object listing the required administrator rights of the user in the chat. + * The rights must be a superset of bot_administrator_rights. If not specified, no additional + * restrictions are applied. + * + * @return ChatAdministratorRights|null + */ + public function getUserAdministratorRights(): ?ChatAdministratorRights + { + return $this->user_administrator_rights; + } + + /** + * Optional. A JSON-serialized object listing the required administrator rights of the bot in the chat. + * The rights must be a subset of user_administrator_rights. If not specified, no additional restrictions + * are applied. + * + * @return ChatAdministratorRights|null + */ + public function getBotAdministratorRights(): ?ChatAdministratorRights + { + return $this->bot_administrator_rights; + } + + /** + * Optional. Pass True to request a chat with the bot as a member. + * Otherwise, no additional restrictions are applied. + * + * @return bool + */ + public function isBotIsMember(): bool + { + return $this->bot_is_member; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'request_id' => $this->request_id, + 'chat_is_channel' => $this->chat_is_channel, + 'chat_is_forum' => $this->chat_is_forum, + 'chat_has_username' => $this->chat_has_username, + 'chat_is_created' => $this->chat_is_created, + 'user_administrator_rights' => ($this->user_administrator_rights instanceof ChatAdministratorRights) ? $this->user_administrator_rights->toArray() : null, + 'bot_administrator_rights' => ($this->bot_administrator_rights instanceof ChatAdministratorRights) ? $this->bot_administrator_rights->toArray() : null, + 'bot_is_member' => $this->bot_is_member, + ]; + } + + /** + * Constructs object from an array representation + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + + $object->request_id = $data['request_id']; + $object->chat_is_channel = $data['chat_is_channel']; + $object->chat_is_forum = $data['chat_is_forum']; + $object->chat_has_username = $data['chat_has_username']; + $object->chat_is_created = $data['chat_is_created']; + $object->user_administrator_rights = ($data['user_administrator_rights'] !== null) ? ChatAdministratorRights::fromArray($data['user_administrator_rights']) : null; + $object->bot_administrator_rights = ($data['bot_administrator_rights'] !== null) ? ChatAdministratorRights::fromArray($data['bot_administrator_rights']) : null; + $object->bot_is_member = $data['bot_is_member']; + + return $object; + } + } \ No newline at end of file