mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
Helper simplified method for Channels_GetAdminLog
This commit is contained in:
parent
e7ec282ac1
commit
389f110cfb
|
|
@ -579,6 +579,29 @@ namespace WTelegram
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Helper simplified method: Get the admin log of a <a href="https://corefork.telegram.org/api/channel">channel/supergroup</a> <para>See <a href="https://corefork.telegram.org/method/channels.getAdminLog"/></para> <para>Possible <see cref="RpcException"/> codes: 400,403 (<a href="https://corefork.telegram.org/method/channels.getAdminLog#possible-errors">details</a>)</para></summary>
|
||||
/// <param name="channel">Channel</param>
|
||||
/// <param name="q">Search query, can be empty</param>
|
||||
/// <param name="events_filter">Event filter</param>
|
||||
/// <param name="admin">Only show events from this admin</param>
|
||||
public async Task<Channels_AdminLogResults> Channels_GetAdminLog(InputChannelBase channel, ChannelAdminLogEventsFilter.Flags events_filter = 0, string q = null, InputUserBase admin = null)
|
||||
{
|
||||
var admins = admin == null ? null : new[] { admin };
|
||||
var result = await this.Channels_GetAdminLog(channel, q, events_filter: events_filter, admins: admins);
|
||||
if (result.events.Length < 100) return result;
|
||||
var resultFull = result;
|
||||
List<ChannelAdminLogEvent> events = new(result.events);
|
||||
do
|
||||
{
|
||||
result = await this.Channels_GetAdminLog(channel, q, max_id: result.events[^1].id, events_filter: events_filter, admins: admins);
|
||||
events.AddRange(result.events);
|
||||
foreach (var kvp in result.chats) resultFull.chats[kvp.Key] = kvp.Value;
|
||||
foreach (var kvp in result.users) resultFull.users[kvp.Key] = kvp.Value;
|
||||
} while (result.events.Length >= 100);
|
||||
resultFull.events = events.ToArray();
|
||||
return resultFull;
|
||||
}
|
||||
|
||||
private const string OnlyChatChannel = "This method works on Chat & Channel only";
|
||||
/// <summary>Generic helper: Adds a single user to a Chat or Channel <para>See <a href="https://corefork.telegram.org/method/messages.addChatUser"/><br/> and <a href="https://corefork.telegram.org/method/channels.inviteToChannel"/></para> <para>Possible <see cref="RpcException"/> codes: 400,403</para></summary>
|
||||
/// <param name="peer">Chat/Channel</param>
|
||||
|
|
|
|||
|
|
@ -562,6 +562,11 @@ namespace TL
|
|||
|
||||
partial class PhoneCallBase { public static implicit operator InputPhoneCall(PhoneCallBase call) => new() { id = call.ID, access_hash = call.AccessHash }; }
|
||||
|
||||
partial class ChannelAdminLogEventsFilter
|
||||
{
|
||||
public static implicit operator ChannelAdminLogEventsFilter(Flags flags) => new() { flags = flags };
|
||||
}
|
||||
|
||||
partial class InputMessage
|
||||
{
|
||||
public static implicit operator InputMessage(int id) => new InputMessageID { id = id };
|
||||
|
|
|
|||
|
|
@ -10108,7 +10108,7 @@ namespace TL
|
|||
|
||||
/// <summary>Filter only certain admin log events <para>See <a href="https://corefork.telegram.org/constructor/channelAdminLogEventsFilter"/></para></summary>
|
||||
[TLDef(0xEA107AE4)]
|
||||
public class ChannelAdminLogEventsFilter : IObject
|
||||
public partial class ChannelAdminLogEventsFilter : IObject
|
||||
{
|
||||
/// <summary>Flags, see <a href="https://corefork.telegram.org/mtproto/TL-combinators#conditional-fields">TL conditional fields</a></summary>
|
||||
public Flags flags;
|
||||
|
|
|
|||
Loading…
Reference in a new issue