tg_cli: simplify testing of td_api::getSupergroupMembers.

GitOrigin-RevId: bd28265cc385b5daf1b5b54241b94a26e3272e84
This commit is contained in:
levlam 2019-03-18 05:45:36 +03:00
parent bc736d0cc5
commit d22ba35f88

View File

@ -2192,30 +2192,17 @@ class CliClient final : public Actor {
} else if (op == "GetChatAdministrators") { } else if (op == "GetChatAdministrators") {
string chat_id = args; string chat_id = args;
send_request(td_api::make_object<td_api::getChatAdministrators>(as_chat_id(chat_id))); send_request(td_api::make_object<td_api::getChatAdministrators>(as_chat_id(chat_id)));
} else if (op == "GetSupergroupAdministrators") { } else if (op == "GetSupergroupAdministrators" || op == "GetSupergroupBanned" || op == "GetSupergroupBots" ||
string supergroup_id; op == "GetSupergroupMembers" || op == "SearchSupergroupMembers" || op == "GetSupergroupRestricted") {
string offset;
string limit;
std::tie(supergroup_id, args) = split(args);
std::tie(offset, limit) = split(args);
if (offset.empty()) {
offset = "0";
}
if (limit.empty()) {
limit = "10";
}
send_request(td_api::make_object<td_api::getSupergroupMembers>(
as_supergroup_id(supergroup_id), td_api::make_object<td_api::supergroupMembersFilterAdministrators>(),
to_integer<int32>(offset), to_integer<int32>(limit)));
} else if (op == "GetSupergroupBanned") {
string supergroup_id; string supergroup_id;
string query; string query;
string offset; string offset;
string limit; string limit;
std::tie(supergroup_id, args) = split(args); std::tie(supergroup_id, args) = split(args);
std::tie(query, args) = split(args); if (op == "GetSupergroupBanned" || op == "SearchSupergroupMembers" || op == "GetSupergroupRestricted") {
std::tie(query, args) = split(args);
}
std::tie(offset, limit) = split(args); std::tie(offset, limit) = split(args);
if (offset.empty()) { if (offset.empty()) {
offset = "0"; offset = "0";
@ -2223,77 +2210,22 @@ class CliClient final : public Actor {
if (limit.empty()) { if (limit.empty()) {
limit = "10"; limit = "10";
} }
send_request(td_api::make_object<td_api::getSupergroupMembers>( td_api::object_ptr<td_api::SupergroupMembersFilter> filter;
as_supergroup_id(supergroup_id), td_api::make_object<td_api::supergroupMembersFilterBanned>(query), if (op == "GetSupergroupAdministrators") {
to_integer<int32>(offset), to_integer<int32>(limit))); filter = td_api::make_object<td_api::supergroupMembersFilterAdministrators>();
} else if (op == "GetSupergroupBots") { } else if (op == "GetSupergroupBanned") {
string supergroup_id; filter = td_api::make_object<td_api::supergroupMembersFilterBanned>(query);
string offset; } else if (op == "GetSupergroupBots") {
string limit; filter = td_api::make_object<td_api::supergroupMembersFilterBots>();
} else if (op == "GetSupergroupMembers") {
std::tie(supergroup_id, args) = split(args); filter = td_api::make_object<td_api::supergroupMembersFilterRecent>();
std::tie(offset, limit) = split(args); } else if (op == "SearchSupergroupMembers") {
if (offset.empty()) { filter = td_api::make_object<td_api::supergroupMembersFilterSearch>(query);
offset = "0"; } else if (op == "GetSupergroupBanned") {
} filter = td_api::make_object<td_api::supergroupMembersFilterRestricted>(query);
if (limit.empty()) {
limit = "10";
} }
send_request(td_api::make_object<td_api::getSupergroupMembers>( send_request(td_api::make_object<td_api::getSupergroupMembers>(
as_supergroup_id(supergroup_id), td_api::make_object<td_api::supergroupMembersFilterBots>(), as_supergroup_id(supergroup_id), std::move(filter), to_integer<int32>(offset), to_integer<int32>(limit)));
to_integer<int32>(offset), to_integer<int32>(limit)));
} else if (op == "GetSupergroupMembers") {
string supergroup_id;
string offset;
string limit;
std::tie(supergroup_id, args) = split(args);
std::tie(offset, limit) = split(args);
if (offset.empty()) {
offset = "0";
}
if (limit.empty()) {
limit = "10";
}
send_request(td_api::make_object<td_api::getSupergroupMembers>(
as_supergroup_id(supergroup_id), td_api::make_object<td_api::supergroupMembersFilterRecent>(),
to_integer<int32>(offset), to_integer<int32>(limit)));
} else if (op == "SearchSupergroupMembers") {
string supergroup_id;
string query;
string offset;
string limit;
std::tie(supergroup_id, args) = split(args);
std::tie(query, args) = split(args);
std::tie(offset, limit) = split(args);
if (offset.empty()) {
offset = "0";
}
if (limit.empty()) {
limit = "10";
}
send_request(td_api::make_object<td_api::getSupergroupMembers>(
as_supergroup_id(supergroup_id), td_api::make_object<td_api::supergroupMembersFilterSearch>(query),
to_integer<int32>(offset), to_integer<int32>(limit)));
} else if (op == "GetSupergroupRestricted") {
string supergroup_id;
string query;
string offset;
string limit;
std::tie(supergroup_id, args) = split(args);
std::tie(query, args) = split(args);
std::tie(offset, limit) = split(args);
if (offset.empty()) {
offset = "0";
}
if (limit.empty()) {
limit = "10";
}
send_request(td_api::make_object<td_api::getSupergroupMembers>(
as_supergroup_id(supergroup_id), td_api::make_object<td_api::supergroupMembersFilterRestricted>(query),
to_integer<int32>(offset), to_integer<int32>(limit)));
} else if (op == "gdialog" || op == "gd") { } else if (op == "gdialog" || op == "gd") {
send_request(td_api::make_object<td_api::getChat>(as_chat_id(args))); send_request(td_api::make_object<td_api::getChat>(as_chat_id(args)));
} else if (op == "open") { } else if (op == "open") {