From 838e786abdc0ca75c6006055fc60129d6d203a33 Mon Sep 17 00:00:00 2001 From: Camilo Sperberg Date: Fri, 30 Jun 2017 16:07:21 +0200 Subject: [PATCH] Implements new Bot API v3.1 changes. Close #40 --- src/InternalFunctionality/TelegramRawData.php | 6 +- src/Telegram/Methods/DeleteChatPhoto.php | 4 +- src/Telegram/Methods/SetChatPhoto.php | 4 +- src/Telegram/Methods/SetChatTitle.php | 4 +- src/Telegram/Types/ChatMember.php | 93 ++++++++++++++++++- 5 files changed, 101 insertions(+), 10 deletions(-) diff --git a/src/InternalFunctionality/TelegramRawData.php b/src/InternalFunctionality/TelegramRawData.php index b4568cc..6b17c5c 100644 --- a/src/InternalFunctionality/TelegramRawData.php +++ b/src/InternalFunctionality/TelegramRawData.php @@ -59,7 +59,8 @@ public function getResult(): array } /** - * Hack: for some requests Telegram sends back an array, integer, string or a boolean value, convert it to boolean here + * Hack: for some requests Telegram sends back an array, integer, string or a boolean value, convert it to boolean + * here * @return bool */ public function getResultBoolean(): bool @@ -77,7 +78,8 @@ public function getResultInt(): int } /** - * Hack: for some requests Telegram send back an array, integer, string or a boolean value, convert it to string here + * Hack: for some requests Telegram send back an array, integer, string or a boolean value, convert it to string + * here * @return string */ public function getResultString(): string diff --git a/src/Telegram/Methods/DeleteChatPhoto.php b/src/Telegram/Methods/DeleteChatPhoto.php index d1a502d..6a1946e 100644 --- a/src/Telegram/Methods/DeleteChatPhoto.php +++ b/src/Telegram/Methods/DeleteChatPhoto.php @@ -14,8 +14,8 @@ * Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator * in the chat for this to work and must have the appropriate admin rights. Returns True on success * - * Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off - * in the target group + * Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is + * off in the target group * * Objects defined as-is july 2017 * diff --git a/src/Telegram/Methods/SetChatPhoto.php b/src/Telegram/Methods/SetChatPhoto.php index 5cb9773..9e12e43 100644 --- a/src/Telegram/Methods/SetChatPhoto.php +++ b/src/Telegram/Methods/SetChatPhoto.php @@ -15,8 +15,8 @@ * Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be * an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success * - * Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off - * in the target group + * Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is + * off in the target group * * Objects defined as-is july 2017 * diff --git a/src/Telegram/Methods/SetChatTitle.php b/src/Telegram/Methods/SetChatTitle.php index cceaf5f..1d69ff2 100644 --- a/src/Telegram/Methods/SetChatTitle.php +++ b/src/Telegram/Methods/SetChatTitle.php @@ -14,8 +14,8 @@ * Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an * administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success * - * Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off - * in the target group + * Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is + * off in the target group * * Objects defined as-is july 2017 * diff --git a/src/Telegram/Types/ChatMember.php b/src/Telegram/Types/ChatMember.php index 45be3ee..2f8af78 100644 --- a/src/Telegram/Types/ChatMember.php +++ b/src/Telegram/Types/ChatMember.php @@ -9,7 +9,7 @@ /** * This object contains information about one member of the chat * - * Objects defined as-is july 2016 + * Objects defined as-is july 2017 * * @see https://core.telegram.org/bots/api#chatmember */ @@ -22,11 +22,100 @@ class ChatMember extends TelegramTypes public $user; /** - * The member's status in the chat. Can be "creator", "administrator", "member", "left" or "kicked" + * The member's status in the chat. Can be "creator", "administrator", "member", "restricted", "left" or "kicked" * @var string */ public $status = ''; + /** + * Optional. Restricted and kicked only. Date when restrictions will be lifted for this user, unix time + * @var int + */ + public $until_date = 0; + + /** + * Optional. Administrators only. True, if the bot is allowed to edit administrator privileges of that user + * @var bool + */ + public $can_be_edited = false; + + /** + * Optional. Administrators only. True, if the administrator can change the chat title, photo and other settings + * @var bool + */ + public $can_change_info = false; + + /** + * Optional. Administrators only. True, if the administrator can post in the channel, channels only + * @var bool + */ + public $can_post_messages = false; + + /** + * Optional. Administrators only. True, if the administrator can edit messages of other users, channels only + * @var bool + */ + public $can_edit_messages = false; + + /** + * Optional. Administrators only. True, if the administrator can delete messages of other users + * @var bool + */ + public $can_delete_messages = false; + + /** + * Optional. Administrators only. True, if the administrator can invite new users to the chat + * @var bool + */ + public $can_invite_users = false; + + /** + * Optional. Administrators only. True, if the administrator can restrict, ban or unban chat members + * @var bool + */ + public $can_restrict_members = false; + + /** + * Optional. Administrators only. True, if the administrator can pin messages, supergroups only + * @var bool + */ + public $can_pin_messages = false; + + /** + * Optional. Administrators only. True, if the administrator can add new administrators with a subset of his own + * privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators + * that were appointed by the user) + * @var bool + */ + public $can_promote_members = false; + + /** + * Optional. Restricted only. True, if the user can send text messages, contacts, locations and venues + * @var bool + */ + public $can_send_messages = false; + + /** + * Optional. Restricted only. True, if the user can send audios, documents, photos, videos, video notes and voice + * notes, implies can_send_messages + * @var bool + */ + public $can_send_media_messages = false; + + /** + * Optional. Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies + * can_send_media_messages + * @var bool + */ + public $can_send_other_messages = false; + + /** + * Optional. Restricted only. True, if user may add web page previews to his messages, implies + * can_send_media_messages + * @var bool + */ + public $can_add_web_page_previews = false; + public function mapSubObjects(string $key, array $data): TelegramTypes { switch ($key) {