Add supergroupMembersFilterContacts.

GitOrigin-RevId: 56dee642cebc5f71918be82219a39d4ad3e4f615
This commit is contained in:
levlam 2019-03-18 05:36:47 +03:00
parent ed3e4b7d67
commit bc736d0cc5
6 changed files with 20 additions and 5 deletions

View File

@ -389,6 +389,9 @@ chatMembersFilterBots = ChatMembersFilter;
//@description Returns recently active users in reverse chronological order //@description Returns recently active users in reverse chronological order
supergroupMembersFilterRecent = SupergroupMembersFilter; supergroupMembersFilterRecent = SupergroupMembersFilter;
//@description Returns contacts, which are members of the supergroup or channel @query Query to search for
supergroupMembersFilterContacts query:string = SupergroupMembersFilter;
//@description Returns the creator and administrators //@description Returns the creator and administrators
supergroupMembersFilterAdministrators = SupergroupMembersFilter; supergroupMembersFilterAdministrators = SupergroupMembersFilter;

Binary file not shown.

View File

@ -7516,7 +7516,7 @@ void ContactsManager::on_get_channel_participants_success(
result.push_back(get_dialog_participant(channel_id, std::move(participant_ptr))); result.push_back(get_dialog_participant(channel_id, std::move(participant_ptr)));
if ((filter.is_bots() && !is_user_bot(result.back().user_id)) || if ((filter.is_bots() && !is_user_bot(result.back().user_id)) ||
(filter.is_administrators() && !result.back().status.is_administrator()) || (filter.is_administrators() && !result.back().status.is_administrator()) ||
((filter.is_recent() || filter.is_search()) && !result.back().status.is_member()) || ((filter.is_recent() || filter.is_contacts() || filter.is_search()) && !result.back().status.is_member()) ||
(filter.is_restricted() && !result.back().status.is_restricted()) || (filter.is_restricted() && !result.back().status.is_restricted()) ||
(filter.is_banned() && !result.back().status.is_banned())) { (filter.is_banned() && !result.back().status.is_banned())) {
bool skip_error = filter.is_administrators() && is_user_deleted(result.back().user_id); bool skip_error = filter.is_administrators() && is_user_deleted(result.back().user_id);

View File

@ -408,6 +408,8 @@ ChannelParticipantsFilter::get_input_channel_participants_filter() const {
switch (type) { switch (type) {
case Type::Recent: case Type::Recent:
return make_tl_object<telegram_api::channelParticipantsRecent>(); return make_tl_object<telegram_api::channelParticipantsRecent>();
case Type::Contacts:
return make_tl_object<telegram_api::channelParticipantsContacts>(query);
case Type::Administrators: case Type::Administrators:
return make_tl_object<telegram_api::channelParticipantsAdmins>(); return make_tl_object<telegram_api::channelParticipantsAdmins>();
case Type::Search: case Type::Search:
@ -433,6 +435,10 @@ ChannelParticipantsFilter::ChannelParticipantsFilter(const tl_object_ptr<td_api:
case td_api::supergroupMembersFilterRecent::ID: case td_api::supergroupMembersFilterRecent::ID:
type = Type::Recent; type = Type::Recent;
return; return;
case td_api::supergroupMembersFilterContacts::ID:
type = Type::Contacts;
query = static_cast<const td_api::supergroupMembersFilterContacts *>(filter.get())->query_;
return;
case td_api::supergroupMembersFilterAdministrators::ID: case td_api::supergroupMembersFilterAdministrators::ID:
type = Type::Administrators; type = Type::Administrators;
return; return;
@ -461,6 +467,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipan
switch (filter.type) { switch (filter.type) {
case ChannelParticipantsFilter::Type::Recent: case ChannelParticipantsFilter::Type::Recent:
return string_builder << "Recent"; return string_builder << "Recent";
case ChannelParticipantsFilter::Type::Contacts:
return string_builder << "Contacts \"" << filter.query << '"';
case ChannelParticipantsFilter::Type::Administrators: case ChannelParticipantsFilter::Type::Administrators:
return string_builder << "Administrators"; return string_builder << "Administrators";
case ChannelParticipantsFilter::Type::Search: case ChannelParticipantsFilter::Type::Search:

View File

@ -256,7 +256,7 @@ struct DialogParticipant {
StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipant &dialog_participant); StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipant &dialog_participant);
class ChannelParticipantsFilter { class ChannelParticipantsFilter {
enum class Type : int32 { Recent, Administrators, Search, Restricted, Banned, Bots } type; enum class Type : int32 { Recent, Contacts, Administrators, Search, Restricted, Banned, Bots } type;
string query; string query;
friend StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipantsFilter &filter); friend StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipantsFilter &filter);
@ -278,6 +278,10 @@ class ChannelParticipantsFilter {
return type == Type::Recent; return type == Type::Recent;
} }
bool is_contacts() const {
return type == Type::Contacts;
}
bool is_search() const { bool is_search() const {
return type == Type::Search; return type == Type::Search;
} }

View File

@ -2189,6 +2189,9 @@ class CliClient final : public Actor {
std::tie(chat_id, user_id) = split(args); std::tie(chat_id, user_id) = split(args);
send_request(td_api::make_object<td_api::getChatMember>(as_chat_id(chat_id), as_user_id(user_id))); send_request(td_api::make_object<td_api::getChatMember>(as_chat_id(chat_id), as_user_id(user_id)));
} else if (op == "GetChatAdministrators") {
string chat_id = args;
send_request(td_api::make_object<td_api::getChatAdministrators>(as_chat_id(chat_id)));
} else if (op == "GetSupergroupAdministrators") { } else if (op == "GetSupergroupAdministrators") {
string supergroup_id; string supergroup_id;
string offset; string offset;
@ -2205,9 +2208,6 @@ class CliClient final : public Actor {
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::supergroupMembersFilterAdministrators>(), as_supergroup_id(supergroup_id), td_api::make_object<td_api::supergroupMembersFilterAdministrators>(),
to_integer<int32>(offset), to_integer<int32>(limit))); to_integer<int32>(offset), to_integer<int32>(limit)));
} else if (op == "GetChatAdministrators") {
string chat_id = args;
send_request(td_api::make_object<td_api::getChatAdministrators>(as_chat_id(chat_id)));
} else if (op == "GetSupergroupBanned") { } else if (op == "GetSupergroupBanned") {
string supergroup_id; string supergroup_id;
string query; string query;