From f019b98b1ff2f88fe4f47fa13023e7629a541fa9 Mon Sep 17 00:00:00 2001 From: eleksir Date: Sun, 16 Apr 2023 16:31:12 +0300 Subject: [PATCH] Add partial BotAPI v6.5 support --- lib/Teapot/Bot/Brain.pm | 4 ++-- lib/Teapot/Bot/Object/ChatMember.pm | 20 ++++++++++++++------ lib/Teapot/Bot/Object/ChatPermissions.pm | 16 +++++++++++----- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/lib/Teapot/Bot/Brain.pm b/lib/Teapot/Bot/Brain.pm index c9a1314..c790da3 100644 --- a/lib/Teapot/Bot/Brain.pm +++ b/lib/Teapot/Bot/Brain.pm @@ -311,9 +311,9 @@ sub muteChatMember { $send_args->{chat_id} = $args->{chat_id}; $send_args->{user_id} = $args->{user_id}; $send_args->{until_date} = $args->{until_date} if exists $args->{until_date}; - # Revoke all known for API v6.2 permissions + # Revoke all known for API v6.4 permissions $send_args->{permissions}->{can_send_messages} = false; - $send_args->{permissions}->{can_send_media_messages} = false; + $send_args->{permissions}->{use_independent_chat_permissions} = false; # https://core.telegram.org/bots/api#restrictchatmember $send_args->{permissions}->{can_send_polls} = false; $send_args->{permissions}->{can_send_other_messages} = false; $send_args->{permissions}->{can_add_web_page_previews} = false; diff --git a/lib/Teapot/Bot/Object/ChatMember.pm b/lib/Teapot/Bot/Object/ChatMember.pm index 65511ea..d33b6cb 100644 --- a/lib/Teapot/Bot/Object/ChatMember.pm +++ b/lib/Teapot/Bot/Object/ChatMember.pm @@ -53,7 +53,12 @@ has 'is_member'; # optional. Restricted only. # has 'can_invite_users'; # optional. Administrators and restricted only. # has 'can_pin_messages'; # optional. Administrators and restricted only. has 'can_send_messages'; # optional. Restricted only. -has 'can_send_media_messages'; # optional. Restricted only. +has 'can_send_audios'; +has 'can_send_documents'; +has 'can_send_photos'; +has 'can_send_videos'; +has 'can_send_video_notes'; +has 'can_send_voice_notes'; has 'can_send_polls'; # optional. Restricted only. has 'can_send_other_messages'; # optional. Restricted only. has 'can_add_web_page_previews'; # optional. Restricted only. @@ -71,11 +76,14 @@ has 'until_date'; # optional. Restricted and kicked only. sub fields { return { - 'scalar' => [qw/status custom_title is_anonymous can_be_edited can_manage_chat can_post_messages - can_edit_messages can_delete_messages can_manage_voice_chats can_restrict_members - can_promote_members can_change_info can_invite_users can_pin_messages is_member - can_send_messages can_send_media_messages can_send_polls can_send_other_messages - can_add_web_page_previews until_date can_manage_topics/], + 'scalar' => [qw/status custom_title is_anonymous can_be_edited can_manage_chat + can_post_messages can_edit_messages can_delete_messages + can_manage_voice_chats can_restrict_members can_promote_members + can_change_info can_invite_users can_pin_messages is_member + can_send_messages can_send_audios can_send_documents can_send_photos + can_send_videos can_send_video_notes can_send_voice_notes can_send_polls + can_send_other_messagescan_add_web_page_previews until_date + can_manage_topics/], 'Teapot::Bot::Object::User' => [qw/user/], }; } diff --git a/lib/Teapot/Bot/Object/ChatPermissions.pm b/lib/Teapot/Bot/Object/ChatPermissions.pm index 1200044..934b9e3 100644 --- a/lib/Teapot/Bot/Object/ChatPermissions.pm +++ b/lib/Teapot/Bot/Object/ChatPermissions.pm @@ -15,8 +15,12 @@ $Teapot::Bot::Object::ChatPermissions::VERSION = '0.025'; # all fields are optional # N.B. Some of the fields "overlaps" other, so in order to guess valid set of permissions you should check all of them has 'can_send_messages'; # True, if the user is allowed to send text messages, contacts, locations and venues -has 'can_send_media_messages'; # True, if the user is allowed to send audios, documents, photos, videos, video notes - # and voice notes, implies can_send_messages +has 'can_send_audios'; # True, if the user is allowed to send audios +has 'can_send_documents'; # True, if the user is allowed to send documents +has 'can_send_photos'; # True, if the user is allowed to send photos +has 'can_send_videos'; # True, if the user is allowed to send videos +has 'can_send_video_notes'; # True, if the user is allowed to send video_notes +has 'can_send_voice_notes'; # True, if the user is allowed to send voice_notes has 'can_send_polls'; # True, if the user is allowed to send polls, implies can_send_messages has 'can_send_other_messages'; # True, if the user is allowed to send animations, games, stickers and use inline bots, # implies can_send_media_messages @@ -31,9 +35,11 @@ has 'can_manage_topics'; # Optional. True, if the user is allowed to cre sub fields { return { - 'scalar' => [qw/can_send_messages can_send_media_messages can_send_polls - can_send_other_messages can_add_web_page_previews can_change_info - can_invite_users can_pin_messages can_manage_topics/], + 'scalar' => [qw/can_send_messages can_send_audios can_send_documents + can_send_photos can_send_videos can_send_video_notes + can_send_voice_notes can_send_polls can_send_other_messages + can_add_web_page_previews can_change_info can_invite_users + can_pin_messages can_manage_topics/], }; }