Add shorthand requests getContacts, joinChat and leaveChat.
GitOrigin-RevId: 95ce6e52aaefafd8bb1c7a70fd096b2156d1a164
This commit is contained in:
parent
23c03a97f4
commit
16b33f67c7
@ -2766,6 +2766,12 @@ toggleChatDefaultDisableNotification chat_id:int53 default_disable_notification:
|
||||
//@description Changes client data associated with a chat @chat_id Chat identifier @client_data New value of client_data
|
||||
setChatClientData chat_id:int53 client_data:string = Ok;
|
||||
|
||||
//@description Adds current user as a new member to a chat. Private and secret chats can't be joined using this method @chat_id Chat identifier
|
||||
joinChat chat_id:int53 = Ok;
|
||||
|
||||
//@description Removes current user from chat members. Private and secret chats can't be left using this method @chat_id Chat identifier
|
||||
leaveChat chat_id:int53 = Ok;
|
||||
|
||||
//@description Adds a new member to a chat. Members can't be added to private or secret chats. Members will not be added until the chat state has been synchronized with the server
|
||||
//@chat_id Chat identifier @user_id Identifier of the user @forward_limit The number of earlier messages from the chat to be forwarded to the new member; up to 300. Ignored for supergroups and channels
|
||||
addChatMember chat_id:int53 user_id:int32 forward_limit:int32 = Ok;
|
||||
@ -2877,6 +2883,9 @@ getBlockedUsers offset:int32 limit:int32 = Users;
|
||||
//@description Adds new contacts or edits existing contacts; contacts' user identifiers are ignored @contacts The list of contacts to import or edit, contact's vCard are ignored and are not imported
|
||||
importContacts contacts:vector<contact> = ImportedContacts;
|
||||
|
||||
//@description Returns all user contacts
|
||||
getContacts = Users;
|
||||
|
||||
//@description Searches for the specified query in the first names, last names and usernames of the known user contacts @query Query to search for; can be empty to return all contacts @limit Maximum number of users to be returned
|
||||
searchContacts query:string limit:int32 = Users;
|
||||
|
||||
|
Binary file not shown.
@ -5458,6 +5458,20 @@ void Td::on_request(uint64 id, td_api::setChatClientData &request) {
|
||||
id, messages_manager_->set_dialog_client_data(DialogId(request.chat_id_), std::move(request.client_data_)));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::joinChat &request) {
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
messages_manager_->set_dialog_participant_status(DialogId(request.chat_id_), contacts_manager_->get_my_id("joinChat"),
|
||||
td_api::make_object<td_api::chatMemberStatusMember>(),
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::leaveChat &request) {
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
messages_manager_->set_dialog_participant_status(
|
||||
DialogId(request.chat_id_), contacts_manager_->get_my_id("leaveChat"),
|
||||
td_api::make_object<td_api::chatMemberStatusLeft>(), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::addChatMember &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
@ -5624,6 +5638,11 @@ void Td::on_request(uint64 id, td_api::importContacts &request) {
|
||||
CREATE_REQUEST(ImportContactsRequest, std::move(request.contacts_));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getContacts &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST(SearchContactsRequest, string(), 1000000);
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::searchContacts &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.query_);
|
||||
|
@ -589,6 +589,10 @@ class Td final : public NetQueryCallback {
|
||||
|
||||
void on_request(uint64 id, td_api::setChatClientData &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::joinChat &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::leaveChat &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::addChatMember &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::addChatMembers &request);
|
||||
@ -633,6 +637,8 @@ class Td final : public NetQueryCallback {
|
||||
|
||||
void on_request(uint64 id, td_api::importContacts &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getContacts &request);
|
||||
|
||||
void on_request(uint64 id, td_api::searchContacts &request);
|
||||
|
||||
void on_request(uint64 id, td_api::removeContacts &request);
|
||||
|
@ -118,8 +118,7 @@ static void reactivate_readline() {
|
||||
}
|
||||
|
||||
static char *command_generator(const char *text, int state) {
|
||||
static const vector<CSlice> commands{"GetContacts",
|
||||
"GetChats",
|
||||
static const vector<CSlice> commands{"GetChats",
|
||||
"GetHistory",
|
||||
"SetVerbosity",
|
||||
"SendVideo",
|
||||
@ -1454,12 +1453,12 @@ class CliClient final : public Actor {
|
||||
send_request(make_tl_object<td_api::checkChangePhoneNumberCode>(args));
|
||||
} else if (op == "rcpc" || op == "ResendChangePhoneCode") {
|
||||
send_request(make_tl_object<td_api::resendChangePhoneNumberCode>());
|
||||
} else if (op == "GetContacts") {
|
||||
auto limit = to_integer<int32>(args);
|
||||
if (limit == 0) {
|
||||
limit = 10000;
|
||||
} else if (op == "gco") {
|
||||
if (args.empty()) {
|
||||
send_request(make_tl_object<td_api::getContacts>());
|
||||
} else {
|
||||
send_request(make_tl_object<td_api::searchContacts>("", to_integer<int32>(args)));
|
||||
}
|
||||
send_request(make_tl_object<td_api::searchContacts>("", limit));
|
||||
} else if (op == "ImportContacts" || op == "cic") {
|
||||
vector<string> contacts_str = full_split(args, ';');
|
||||
vector<tl_object_ptr<td_api::contact>> contacts;
|
||||
@ -3049,6 +3048,10 @@ class CliClient final : public Actor {
|
||||
std::tie(chat_id, limit) = split(args);
|
||||
send_request(make_tl_object<td_api::getChatEventLog>(as_chat_id(chat_id), "", 0, to_integer<int32>(limit),
|
||||
nullptr, vector<int32>()));
|
||||
} else if (op == "join") {
|
||||
send_request(make_tl_object<td_api::joinChat>(as_chat_id(args)));
|
||||
} else if (op == "leave") {
|
||||
send_request(make_tl_object<td_api::leaveChat>(as_chat_id(args)));
|
||||
} else if (op == "dcm") {
|
||||
string chat_id;
|
||||
string user_id_str;
|
||||
|
Reference in New Issue
Block a user