Improve messageBotWriteAccessAllowed class.

This commit is contained in:
levlam 2023-09-28 15:15:00 +03:00
parent e3d89cf90f
commit b5bf594662
2 changed files with 26 additions and 12 deletions

View File

@ -2724,13 +2724,8 @@ messageUserShared user_id:int53 button_id:int32 = MessageContent;
//@description The current user shared a chat, which was requested by the bot @chat_id Identifier of the shared chat @button_id Identifier of the keyboard button with the request
messageChatShared chat_id:int53 button_id:int32 = MessageContent;
//@description The current user has connected a website by logging in using Telegram Login Widget on it @domain_name Domain name of the connected website
messageWebsiteConnected domain_name:string = MessageContent;
//@description The user allowed the bot to send messages
//@web_app Information about the Web App, which requested the access; may be null if none or the Web App was opened from the attachment menu
//@by_request True, if user allowed the bot to send messages by an explicit call to allowBotToSendMessages
messageBotWriteAccessAllowed web_app:webApp by_request:Bool = MessageContent;
//@description The user allowed the bot to send messages @reason The reason why the bot was allowed to write messages
messageBotWriteAccessAllowed reason:BotWriteAccessAllowReason = MessageContent;
//@description Data from a Web App has been sent to a bot @button_text Text of the keyboardButtonTypeWebApp button, which opened the Web App
messageWebAppDataSent button_text:string = MessageContent;
@ -3450,7 +3445,7 @@ callStateReady protocol:callProtocol servers:vector<callServer> config:string en
callStateHangingUp = CallState;
//@description The call has ended successfully
//@reason The reason, why the call has ended
//@reason The reason why the call has ended
//@need_rating True, if the call rating must be sent to the server
//@need_debug_information True, if the call debug information must be sent to the server
//@need_log True, if the call log must be sent to the server
@ -3705,6 +3700,21 @@ attachmentMenuBot bot_user_id:int53 supports_self_chat:Bool supports_user_chats:
sentWebAppMessage inline_message_id:string = SentWebAppMessage;
//@class BotWriteAccessAllowReason @description Describes a reason why a bot was allowed to write messages to the current user
//@description The user connected a website by logging in using Telegram Login Widget on it @domain_name Domain name of the connected website
botWriteAccessAllowReasonConnectedWebsite domain_name:string = BotWriteAccessAllowReason;
//@description The user added the bot to attachment or side menu using toggleBotIsAddedToAttachmentMenu
botWriteAccessAllowReasonAddedToAttachmentMenu = BotWriteAccessAllowReason;
//@description The user launched a Web App using getWebAppLinkUrl @web_app Information about the Web App
botWriteAccessAllowReasonLaunchedWebApp web_app:webApp = BotWriteAccessAllowReason;
//@description The user accepted bot's request to send messages with allowBotToSendMessages
botWriteAccessAllowReasonAcceptedRequest = BotWriteAccessAllowReason;
//@description Contains an HTTP URL @url The URL
httpUrl url:string = HttpUrl;

View File

@ -5956,7 +5956,8 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
}
case MessageContentType::WebsiteConnected: {
const auto *m = static_cast<const MessageWebsiteConnected *>(content);
return make_tl_object<td_api::messageWebsiteConnected>(m->domain_name);
return td_api::make_object<td_api::messageBotWriteAccessAllowed>(
td_api::make_object<td_api::botWriteAccessAllowReasonConnectedWebsite>(m->domain_name));
}
case MessageContentType::PassportDataSent: {
const auto *m = static_cast<const MessagePassportDataSent *>(content);
@ -6051,7 +6052,8 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
return make_tl_object<td_api::messageSuggestProfilePhoto>(std::move(photo));
}
case MessageContentType::WriteAccessAllowed:
return make_tl_object<td_api::messageBotWriteAccessAllowed>(nullptr, false);
return td_api::make_object<td_api::messageBotWriteAccessAllowed>(
td_api::make_object<td_api::botWriteAccessAllowReasonAddedToAttachmentMenu>());
case MessageContentType::RequestedDialog: {
const auto *m = static_cast<const MessageRequestedDialog *>(content);
if (m->dialog_id.get_type() == DialogType::User) {
@ -6073,7 +6075,8 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
}
case MessageContentType::WebViewWriteAccessAllowed: {
const auto *m = static_cast<const MessageWebViewWriteAccessAllowed *>(content);
return td_api::make_object<td_api::messageBotWriteAccessAllowed>(m->web_app.get_web_app_object(td), false);
return td_api::make_object<td_api::messageBotWriteAccessAllowed>(
td_api::make_object<td_api::botWriteAccessAllowReasonLaunchedWebApp>(m->web_app.get_web_app_object(td)));
}
case MessageContentType::SetBackground: {
const auto *m = static_cast<const MessageSetBackground *>(content);
@ -6087,7 +6090,8 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
m->story_full_id.get_story_id().get(), m->via_mention);
}
case MessageContentType::WriteAccessAllowedByRequest:
return make_tl_object<td_api::messageBotWriteAccessAllowed>(nullptr, true);
return td_api::make_object<td_api::messageBotWriteAccessAllowed>(
td_api::make_object<td_api::botWriteAccessAllowReasonAcceptedRequest>());
default:
UNREACHABLE();
return nullptr;