Add supergroupMembersFilterMention.

GitOrigin-RevId: 370a3880a371879aaefb41ad520917db3e33d679
This commit is contained in:
levlam 2020-10-19 01:33:31 +03:00
parent 27f63e9e2e
commit 80d19432bf
7 changed files with 39 additions and 4 deletions

View File

@ -524,6 +524,9 @@ supergroupMembersFilterAdministrators = SupergroupMembersFilter;
//@description Used to search for supergroup or channel members via a (string) query @query Query to search for
supergroupMembersFilterSearch query:string = SupergroupMembersFilter;
//@description Returns users which can be mentioned in the supergroup @query Query to search for @message_thread_id If non-zero, the identifier of the current message thread
supergroupMembersFilterMention query:string message_thread_id:int53 = SupergroupMembersFilter;
//@description Returns restricted supergroup members; can be used only by administrators @query Query to search for
supergroupMembersFilterRestricted query:string = SupergroupMembersFilter;

Binary file not shown.

View File

@ -595,6 +595,7 @@ channelParticipantCreator#447dca4b flags:# user_id:int admin_rights:ChatAdminRig
channelParticipantAdmin#ccbebbaf flags:# can_edit:flags.0?true self:flags.1?true user_id:int inviter_id:flags.1?int promoted_by:int date:int admin_rights:ChatAdminRights rank:flags.2?string = ChannelParticipant;
channelParticipantBanned#1c0facaf flags:# left:flags.0?true user_id:int kicked_by:int date:int banned_rights:ChatBannedRights = ChannelParticipant;
channelParticipantLeft#c3c6796b user_id:int = ChannelParticipant;
channelParticipantsMentions#e04b5ceb flags:# q:flags.0?string top_msg_id:flags.1?int = ChannelParticipantsFilter;
channelParticipantsRecent#de3f3c79 = ChannelParticipantsFilter;
channelParticipantsAdmins#b4608969 = ChannelParticipantsFilter;

Binary file not shown.

View File

@ -706,6 +706,17 @@ ChannelParticipantsFilter::get_input_channel_participants_filter() const {
return make_tl_object<telegram_api::channelParticipantsAdmins>();
case Type::Search:
return make_tl_object<telegram_api::channelParticipantsSearch>(query);
case Type::Mention: {
int32 flags = 0;
if (!query.empty()) {
flags |= telegram_api::channelParticipantsMentions::Q_MASK;
}
if (!top_thread_message_id.is_valid()) {
flags |= telegram_api::channelParticipantsMentions::TOP_MSG_ID_MASK;
}
return make_tl_object<telegram_api::channelParticipantsMentions>(
flags, query, top_thread_message_id.get_server_message_id().get());
}
case Type::Restricted:
return make_tl_object<telegram_api::channelParticipantsBanned>(query);
case Type::Banned:
@ -738,6 +749,16 @@ ChannelParticipantsFilter::ChannelParticipantsFilter(const tl_object_ptr<td_api:
type = Type::Search;
query = static_cast<const td_api::supergroupMembersFilterSearch *>(filter.get())->query_;
return;
case td_api::supergroupMembersFilterMention::ID: {
auto mention_filter = static_cast<const td_api::supergroupMembersFilterMention *>(filter.get());
type = Type::Mention;
query = mention_filter->query_;
top_thread_message_id = MessageId(mention_filter->message_thread_id_);
if (!top_thread_message_id.is_valid() || !top_thread_message_id.is_server()) {
top_thread_message_id = MessageId();
}
return;
}
case td_api::supergroupMembersFilterRestricted::ID:
type = Type::Restricted;
query = static_cast<const td_api::supergroupMembersFilterRestricted *>(filter.get())->query_;
@ -765,6 +786,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipan
return string_builder << "Administrators";
case ChannelParticipantsFilter::Type::Search:
return string_builder << "Search \"" << filter.query << '"';
case ChannelParticipantsFilter::Type::Mention:
return string_builder << "Mention \"" << filter.query << "\" in thread of " << filter.top_thread_message_id;
case ChannelParticipantsFilter::Type::Restricted:
return string_builder << "Restricted \"" << filter.query << '"';
case ChannelParticipantsFilter::Type::Banned:

View File

@ -6,9 +6,9 @@
//
#pragma once
#include "td/telegram/MessageId.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/UserId.h"
#include "td/utils/common.h"
@ -401,8 +401,9 @@ struct DialogParticipant {
StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipant &dialog_participant);
class ChannelParticipantsFilter {
enum class Type : int32 { Recent, Contacts, Administrators, Search, Restricted, Banned, Bots } type;
enum class Type : int32 { Recent, Contacts, Administrators, Search, Mention, Restricted, Banned, Bots } type;
string query;
MessageId top_thread_message_id;
friend StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipantsFilter &filter);

View File

@ -2553,17 +2553,21 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::getChatAdministrators>(as_chat_id(chat_id)));
} else if (op == "GetSupergroupAdministrators" || op == "GetSupergroupBanned" || op == "GetSupergroupBots" ||
op == "GetSupergroupContacts" || op == "GetSupergroupMembers" || op == "GetSupergroupRestricted" ||
op == "SearchSupergroupMembers") {
op == "SearchSupergroupMembers" || op == "SearchSupergroupMentions") {
string supergroup_id;
string query;
string message_thread_id;
string offset;
string limit;
std::tie(supergroup_id, args) = split(args);
if (op == "GetSupergroupBanned" || op == "GetSupergroupContacts" || op == "GetSupergroupRestricted" ||
op == "SearchSupergroupMembers") {
op == "SearchSupergroupMembers" || op == "SearchSupergroupMentions") {
std::tie(query, args) = split(args);
}
if (op == "SearchSupergroupMentions") {
std::tie(message_thread_id, args) = split(args);
}
std::tie(offset, limit) = split(args);
if (offset.empty()) {
offset = "0";
@ -2586,6 +2590,9 @@ class CliClient final : public Actor {
filter = td_api::make_object<td_api::supergroupMembersFilterRestricted>(query);
} else if (op == "SearchSupergroupMembers") {
filter = td_api::make_object<td_api::supergroupMembersFilterSearch>(query);
} else if (op == "SearchSupergroupMentions") {
filter =
td_api::make_object<td_api::supergroupMembersFilterMention>(query, as_message_thread_id(message_thread_id));
}
send_request(td_api::make_object<td_api::getSupergroupMembers>(
as_supergroup_id(supergroup_id), std::move(filter), to_integer<int32>(offset), to_integer<int32>(limit)));