Add methods for General topic management.

This commit is contained in:
levlam 2022-12-29 21:02:15 +03:00
parent 9b47c90de9
commit 849d48e858
2 changed files with 66 additions and 0 deletions

View File

@ -268,6 +268,11 @@ bool Client::init_methods() {
methods_.emplace("reopenforumtopic", &Client::process_reopen_forum_topic_query); methods_.emplace("reopenforumtopic", &Client::process_reopen_forum_topic_query);
methods_.emplace("deleteforumtopic", &Client::process_delete_forum_topic_query); methods_.emplace("deleteforumtopic", &Client::process_delete_forum_topic_query);
methods_.emplace("unpinallforumtopicmessages", &Client::process_unpin_all_forum_topic_messages_query); methods_.emplace("unpinallforumtopicmessages", &Client::process_unpin_all_forum_topic_messages_query);
methods_.emplace("editgeneralforumtopic", &Client::process_edit_general_forum_topic_query);
methods_.emplace("closegeneralforumtopic", &Client::process_close_general_forum_topic_query);
methods_.emplace("reopengeneralforumtopic", &Client::process_reopen_general_forum_topic_query);
methods_.emplace("hidegeneralforumtopic", &Client::process_hide_general_forum_topic_query);
methods_.emplace("unhidegeneralforumtopic", &Client::process_unhide_general_forum_topic_query);
methods_.emplace("getchatmember", &Client::process_get_chat_member_query); methods_.emplace("getchatmember", &Client::process_get_chat_member_query);
methods_.emplace("getchatadministrators", &Client::process_get_chat_administrators_query); methods_.emplace("getchatadministrators", &Client::process_get_chat_administrators_query);
methods_.emplace("getchatmembercount", &Client::process_get_chat_member_count_query); methods_.emplace("getchatmembercount", &Client::process_get_chat_member_count_query);
@ -8435,6 +8440,58 @@ td::Status Client::process_unpin_all_forum_topic_messages_query(PromisedQueryPtr
return Status::OK(); return Status::OK();
} }
td::Status Client::process_edit_general_forum_topic_query(PromisedQueryPtr &query) {
auto chat_id = query->arg("chat_id");
auto name = query->arg("name");
check_chat(chat_id, AccessRights::Write, std::move(query),
[this, name = name.str()](int64 chat_id, PromisedQueryPtr query) {
send_request(make_object<td_api::editForumTopic>(chat_id, GENERAL_MESSAGE_THREAD_ID, name, false, 0),
td::make_unique<TdOnOkQueryCallback>(std::move(query)));
});
return Status::OK();
}
td::Status Client::process_close_general_forum_topic_query(PromisedQueryPtr &query) {
auto chat_id = query->arg("chat_id");
check_chat(chat_id, AccessRights::Write, std::move(query), [this](int64 chat_id, PromisedQueryPtr query) {
send_request(make_object<td_api::toggleForumTopicIsClosed>(chat_id, GENERAL_MESSAGE_THREAD_ID, true),
td::make_unique<TdOnOkQueryCallback>(std::move(query)));
});
return Status::OK();
}
td::Status Client::process_reopen_general_forum_topic_query(PromisedQueryPtr &query) {
auto chat_id = query->arg("chat_id");
check_chat(chat_id, AccessRights::Write, std::move(query), [this](int64 chat_id, PromisedQueryPtr query) {
send_request(make_object<td_api::toggleForumTopicIsClosed>(chat_id, GENERAL_MESSAGE_THREAD_ID, false),
td::make_unique<TdOnOkQueryCallback>(std::move(query)));
});
return Status::OK();
}
td::Status Client::process_hide_general_forum_topic_query(PromisedQueryPtr &query) {
auto chat_id = query->arg("chat_id");
check_chat(chat_id, AccessRights::Write, std::move(query), [this](int64 chat_id, PromisedQueryPtr query) {
send_request(make_object<td_api::toggleGeneralForumTopicIsHidden>(chat_id, true),
td::make_unique<TdOnOkQueryCallback>(std::move(query)));
});
return Status::OK();
}
td::Status Client::process_unhide_general_forum_topic_query(PromisedQueryPtr &query) {
auto chat_id = query->arg("chat_id");
check_chat(chat_id, AccessRights::Write, std::move(query), [this](int64 chat_id, PromisedQueryPtr query) {
send_request(make_object<td_api::toggleGeneralForumTopicIsHidden>(chat_id, false),
td::make_unique<TdOnOkQueryCallback>(std::move(query)));
});
return Status::OK();
}
td::Status Client::process_get_chat_member_query(PromisedQueryPtr &query) { td::Status Client::process_get_chat_member_query(PromisedQueryPtr &query) {
auto chat_id = query->arg("chat_id"); auto chat_id = query->arg("chat_id");
TRY_RESULT(user_id, get_user_id(query.get())); TRY_RESULT(user_id, get_user_id(query.get()));
@ -11035,6 +11092,8 @@ td::int64 Client::get_basic_group_chat_id(int64 basic_group_id) {
return -basic_group_id; return -basic_group_id;
} }
constexpr Client::int64 Client::GENERAL_MESSAGE_THREAD_ID;
constexpr Client::int64 Client::GREAT_MINDS_SET_ID; constexpr Client::int64 Client::GREAT_MINDS_SET_ID;
constexpr Client::Slice Client::GREAT_MINDS_SET_NAME; constexpr Client::Slice Client::GREAT_MINDS_SET_NAME;

View File

@ -68,6 +68,8 @@ class Client final : public WebhookActor::Callback {
static constexpr bool USE_MESSAGE_DATABASE = false; static constexpr bool USE_MESSAGE_DATABASE = false;
static constexpr int64 GENERAL_MESSAGE_THREAD_ID = 1 << 20;
static constexpr int32 MAX_CERTIFICATE_FILE_SIZE = 3 << 20; static constexpr int32 MAX_CERTIFICATE_FILE_SIZE = 3 << 20;
static constexpr int32 MAX_DOWNLOAD_FILE_SIZE = 20 << 20; static constexpr int32 MAX_DOWNLOAD_FILE_SIZE = 20 << 20;
@ -540,6 +542,11 @@ class Client final : public WebhookActor::Callback {
Status process_reopen_forum_topic_query(PromisedQueryPtr &query); Status process_reopen_forum_topic_query(PromisedQueryPtr &query);
Status process_delete_forum_topic_query(PromisedQueryPtr &query); Status process_delete_forum_topic_query(PromisedQueryPtr &query);
Status process_unpin_all_forum_topic_messages_query(PromisedQueryPtr &query); Status process_unpin_all_forum_topic_messages_query(PromisedQueryPtr &query);
Status process_edit_general_forum_topic_query(PromisedQueryPtr &query);
Status process_close_general_forum_topic_query(PromisedQueryPtr &query);
Status process_reopen_general_forum_topic_query(PromisedQueryPtr &query);
Status process_hide_general_forum_topic_query(PromisedQueryPtr &query);
Status process_unhide_general_forum_topic_query(PromisedQueryPtr &query);
Status process_get_chat_member_query(PromisedQueryPtr &query); Status process_get_chat_member_query(PromisedQueryPtr &query);
Status process_get_chat_administrators_query(PromisedQueryPtr &query); Status process_get_chat_administrators_query(PromisedQueryPtr &query);
Status process_get_chat_member_count_query(PromisedQueryPtr &query); Status process_get_chat_member_count_query(PromisedQueryPtr &query);