diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 0d32208ac..3d428f2af 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -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; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 9d16b1095..e7e250609 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/generate/scheme/telegram_api.tl b/td/generate/scheme/telegram_api.tl index 067f911a3..fd7ebbba5 100644 --- a/td/generate/scheme/telegram_api.tl +++ b/td/generate/scheme/telegram_api.tl @@ -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; diff --git a/td/generate/scheme/telegram_api.tlo b/td/generate/scheme/telegram_api.tlo index ea5182bbb..bed8548d7 100644 Binary files a/td/generate/scheme/telegram_api.tlo and b/td/generate/scheme/telegram_api.tlo differ diff --git a/td/telegram/DialogParticipant.cpp b/td/telegram/DialogParticipant.cpp index ad517b33c..77451dc67 100644 --- a/td/telegram/DialogParticipant.cpp +++ b/td/telegram/DialogParticipant.cpp @@ -706,6 +706,17 @@ ChannelParticipantsFilter::get_input_channel_participants_filter() const { return make_tl_object(); case Type::Search: return make_tl_object(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( + flags, query, top_thread_message_id.get_server_message_id().get()); + } case Type::Restricted: return make_tl_object(query); case Type::Banned: @@ -738,6 +749,16 @@ ChannelParticipantsFilter::ChannelParticipantsFilter(const tl_object_ptr(filter.get())->query_; return; + case td_api::supergroupMembersFilterMention::ID: { + auto mention_filter = static_cast(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(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: diff --git a/td/telegram/DialogParticipant.h b/td/telegram/DialogParticipant.h index d98730d24..66b4095ee 100644 --- a/td/telegram/DialogParticipant.h +++ b/td/telegram/DialogParticipant.h @@ -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); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index ecb8bc3d0..4991e6b19 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -2553,17 +2553,21 @@ class CliClient final : public Actor { send_request(td_api::make_object(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(query); } else if (op == "SearchSupergroupMembers") { filter = td_api::make_object(query); + } else if (op == "SearchSupergroupMentions") { + filter = + td_api::make_object(query, as_message_thread_id(message_thread_id)); } send_request(td_api::make_object( as_supergroup_id(supergroup_id), std::move(filter), to_integer(offset), to_integer(limit)));