Add setDefaultGroupAdministratorRights/setDefaultChannelAdministratorRights.
This commit is contained in:
parent
fd00755bec
commit
dd6a741f8a
@ -473,7 +473,7 @@ user id:int53 first_name:string last_name:string username:string phone_number:st
|
||||
//@share_text The text that is shown on the bot's profile page and is sent together with the link when users share the bot
|
||||
//@param_description The text shown in the chat with the bot if the chat is empty
|
||||
//@commands List of the bot commands
|
||||
//@default_group_administrator_rights Default administrator rights for adding the bot to basic groups and supergroups; may be null
|
||||
//@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 share_text:string description:string commands:vector<botCommand> default_group_administrator_rights:chatAdministratorRights default_channel_administrator_rights:chatAdministratorRights = BotInfo;
|
||||
|
||||
@ -790,7 +790,7 @@ messageReplyInfo reply_count:int32 recent_replier_ids:vector<MessageSender> last
|
||||
//@reaction Text representation of the reaction
|
||||
//@total_count Number of times the reaction was added
|
||||
//@is_chosen True, if the reaction is chosen by the current user
|
||||
//@recent_sender_ids Identifiers of at most 3 recent message senders, added the reaction; available in private chats, basic groups and supergroups
|
||||
//@recent_sender_ids Identifiers of at most 3 recent message senders, added the reaction; available in private, basic group and supergroup chats
|
||||
messageReaction reaction:string total_count:int32 is_chosen:Bool recent_sender_ids:vector<MessageSender> = MessageReaction;
|
||||
|
||||
//@description Contains information about interactions with a message
|
||||
@ -912,10 +912,10 @@ foundFileDownloads total_counts:downloadedFileCounts files:vector<fileDownload>
|
||||
//@description Notification settings applied to all private and secret chats when the corresponding chat setting has a default value
|
||||
notificationSettingsScopePrivateChats = NotificationSettingsScope;
|
||||
|
||||
//@description Notification settings applied to all basic groups and supergroups when the corresponding chat setting has a default value
|
||||
//@description Notification settings applied to all basic group and supergroup chats when the corresponding chat setting has a default value
|
||||
notificationSettingsScopeGroupChats = NotificationSettingsScope;
|
||||
|
||||
//@description Notification settings applied to all channels when the corresponding chat setting has a default value
|
||||
//@description Notification settings applied to all channel chats when the corresponding chat setting has a default value
|
||||
notificationSettingsScopeChannelChats = NotificationSettingsScope;
|
||||
|
||||
|
||||
@ -5712,6 +5712,12 @@ deleteCommands scope:BotCommandScope language_code:string = Ok;
|
||||
//@language_code A two-letter ISO 639-1 language code or an empty string
|
||||
getCommands scope:BotCommandScope language_code:string = BotCommands;
|
||||
|
||||
//@description Sets default administrator rights for adding the bot to basic group and supergroup chats; for bots only @default_group_administrator_rights Default administrator rights for adding the bot to basic group and supergroup chats; may be null
|
||||
setDefaultGroupAdministratorRights default_group_administrator_rights:chatAdministratorRights = Ok;
|
||||
|
||||
//@description Sets default administrator rights for adding the bot to channel chats; for bots only @default_channel_administrator_rights Default administrator rights for adding the bot to channels; may be null
|
||||
setDefaultChannelAdministratorRights default_channel_administrator_rights:chatAdministratorRights = Ok;
|
||||
|
||||
|
||||
//@description Returns all active sessions of the current user
|
||||
getActiveSessions = Sessions;
|
||||
|
@ -393,6 +393,62 @@ class ResetWebAuthorizationsQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class SetBotGroupDefaultAdminRightsQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
public:
|
||||
explicit SetBotGroupDefaultAdminRightsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(AdministratorRights administrator_rights) {
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::bots_setBotGroupDefaultAdminRights(administrator_rights.get_chat_admin_rights())));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::bots_setBotGroupDefaultAdminRights>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
bool result = result_ptr.move_as_ok();
|
||||
LOG_IF(WARNING, !result) << "Failed to set group default administrator rights";
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class SetBotBroadcastDefaultAdminRightsQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
public:
|
||||
explicit SetBotBroadcastDefaultAdminRightsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(AdministratorRights administrator_rights) {
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::bots_setBotBroadcastDefaultAdminRights(administrator_rights.get_chat_admin_rights())));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::bots_setBotBroadcastDefaultAdminRights>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
bool result = result_ptr.move_as_ok();
|
||||
LOG_IF(WARNING, !result) << "Failed to set channel default administrator rights";
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
void set_account_ttl(Td *td, int32 account_ttl, Promise<Unit> &&promise) {
|
||||
td->create_handler<SetAccountTtlQuery>(std::move(promise))->send(account_ttl);
|
||||
}
|
||||
@ -453,4 +509,13 @@ void disconnect_all_websites(Td *td, Promise<Unit> &&promise) {
|
||||
td->create_handler<ResetWebAuthorizationsQuery>(std::move(promise))->send();
|
||||
}
|
||||
|
||||
void set_default_group_administrator_rights(Td *td, AdministratorRights administrator_rights, Promise<Unit> &&promise) {
|
||||
td->create_handler<SetBotGroupDefaultAdminRightsQuery>(std::move(promise))->send(administrator_rights);
|
||||
}
|
||||
|
||||
void set_default_channel_administrator_rights(Td *td, AdministratorRights administrator_rights,
|
||||
Promise<Unit> &&promise) {
|
||||
td->create_handler<SetBotBroadcastDefaultAdminRightsQuery>(std::move(promise))->send(administrator_rights);
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -6,6 +6,7 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/DialogParticipant.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
|
||||
#include "td/actor/PromiseFuture.h"
|
||||
@ -41,4 +42,9 @@ void disconnect_website(Td *td, int64 website_id, Promise<Unit> &&promise);
|
||||
|
||||
void disconnect_all_websites(Td *td, Promise<Unit> &&promise);
|
||||
|
||||
void set_default_group_administrator_rights(Td *td, AdministratorRights administrator_rights, Promise<Unit> &&promise);
|
||||
|
||||
void set_default_channel_administrator_rights(Td *td, AdministratorRights administrator_rights,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
} // namespace td
|
||||
|
@ -18,6 +18,20 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
AdministratorRights::AdministratorRights(
|
||||
const td_api::object_ptr<td_api::chatAdministratorRights> &administrator_rights) {
|
||||
if (administrator_rights == nullptr) {
|
||||
flags_ = 0;
|
||||
return;
|
||||
}
|
||||
*this = AdministratorRights(administrator_rights->is_anonymous_, administrator_rights->can_manage_chat_,
|
||||
administrator_rights->can_change_info_, administrator_rights->can_post_messages_,
|
||||
administrator_rights->can_edit_messages_, administrator_rights->can_delete_messages_,
|
||||
administrator_rights->can_invite_users_, administrator_rights->can_restrict_members_,
|
||||
administrator_rights->can_pin_messages_, administrator_rights->can_promote_members_,
|
||||
administrator_rights->can_manage_video_chats_);
|
||||
}
|
||||
|
||||
AdministratorRights::AdministratorRights(bool is_anonymous, bool can_manage_dialog, bool can_change_info,
|
||||
bool can_post_messages, bool can_edit_messages, bool can_delete_messages,
|
||||
bool can_invite_users, bool can_restrict_members, bool can_pin_messages,
|
||||
|
@ -50,6 +50,8 @@ class AdministratorRights {
|
||||
AdministratorRights() : flags_(0) {
|
||||
}
|
||||
|
||||
explicit AdministratorRights(const td_api::object_ptr<td_api::chatAdministratorRights> &administrator_rights);
|
||||
|
||||
AdministratorRights(bool is_anonymous, bool can_manage_dialog, bool can_change_info, bool can_post_messages,
|
||||
bool can_edit_messages, bool can_delete_messages, bool can_invite_users,
|
||||
bool can_restrict_members, bool can_pin_messages, bool can_promote_members,
|
||||
|
@ -6789,6 +6789,20 @@ void Td::on_request(uint64 id, td_api::getCommands &request) {
|
||||
get_commands(this, std::move(request.scope_), std::move(request.language_code_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::setDefaultGroupAdministratorRights &request) {
|
||||
CHECK_IS_BOT();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
set_default_group_administrator_rights(this, AdministratorRights(request.default_group_administrator_rights_),
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::setDefaultChannelAdministratorRights &request) {
|
||||
CHECK_IS_BOT();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
set_default_channel_administrator_rights(this, AdministratorRights(request.default_channel_administrator_rights_),
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::setLocation &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
|
@ -999,6 +999,10 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::getCommands &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::setDefaultGroupAdministratorRights &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::setDefaultChannelAdministratorRights &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::setLocation &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setProfilePhoto &request);
|
||||
|
Loading…
Reference in New Issue
Block a user