From c44a2d07b5711ef01bf0700ca621bad9608b8ceb Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 3 Apr 2023 20:26:31 +0300 Subject: [PATCH] Add edit links to userFull. --- td/generate/scheme/td_api.tl | 6 +++++- td/telegram/ContactsManager.cpp | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 2fa00aad0..55f89f00b 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -712,7 +712,11 @@ user id:int53 first_name:string last_name:string usernames:usernames phone_numbe //@commands List of the bot commands //@default_group_administrator_rights Default administrator rights for adding the bot to basic group and supergroup chats; may be null //@default_channel_administrator_rights Default administrator rights for adding the bot to channels; may be null -botInfo short_description:string description:string photo:photo animation:animation menu_button:botMenuButton commands:vector default_group_administrator_rights:chatAdministratorRights default_channel_administrator_rights:chatAdministratorRights = BotInfo; +//@edit_commands_link The internal link, which can be used to edit bot commands; may be null +//@edit_description_link The internal link, which can be used to edit bot description; may be null +//@edit_description_media_link The internal link, which can be used to edit the photo or animation shown in the chat with the bot if the chat is empty; may be null +//@edit_settings_link The internal link, which can be used to edit bot settings; may be null +botInfo short_description:string description:string photo:photo animation:animation menu_button:botMenuButton commands:vector default_group_administrator_rights:chatAdministratorRights default_channel_administrator_rights:chatAdministratorRights edit_commands_link:InternalLinkType edit_description_link:InternalLinkType edit_description_media_link:InternalLinkType edit_settings_link:InternalLinkType = BotInfo; //@description Contains full information about a user //@personal_photo User profile photo set by the current user for the contact; may be null. If null and user.profile_photo is null, then the photo is empty; otherwise, it is unknown. diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 935581634..981321543 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -18590,7 +18590,20 @@ tl_object_ptr ContactsManager::get_user_full_info_object(U : user_full->group_administrator_rights.get_chat_administrator_rights_object(), user_full->broadcast_administrator_rights == AdministratorRights() ? nullptr - : user_full->broadcast_administrator_rights.get_chat_administrator_rights_object()); + : user_full->broadcast_administrator_rights.get_chat_administrator_rights_object(), + nullptr, nullptr, nullptr, nullptr); + const User *u = get_user(user_id); + if (u != nullptr && u->can_be_edited_bot && u->usernames.has_editable_username()) { + auto bot_username = u->usernames.get_editable_username(); + bot_info->edit_commands_link_ = td_api::make_object( + "botfather", PSTRING() << bot_username << "-commands", true); + bot_info->edit_description_link_ = td_api::make_object( + "botfather", PSTRING() << bot_username << "-intro", true); + bot_info->edit_description_media_link_ = td_api::make_object( + "botfather", PSTRING() << bot_username << "-intropic", true); + bot_info->edit_settings_link_ = + td_api::make_object("botfather", bot_username, true); + } } else { FormattedText bio; bio.text = user_full->about;