mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2026-02-02 05:34:23 +01:00
cancellationToken for Channels_GetAllParticipants
This commit is contained in:
parent
07fcb2d9e4
commit
d0d63547b4
|
|
@ -369,7 +369,7 @@ static StreamWriter WTelegramLogs = new StreamWriter("WTelegram.log", true, Enco
|
|||
...
|
||||
WTelegram.Helpers.Log = (lvl, str) => WTelegramLogs.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} [{"TDIWE!"[lvl]}] {str}");
|
||||
|
||||
// • In an ASP.NET service, you will typically send logs to a `ILogger`:
|
||||
// • In an ASP.NET service, you will typically send logs to a ILogger:
|
||||
WTelegram.Helpers.Log = (lvl, str) => _logger.Log((LogLevel)lvl, str);
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -1659,9 +1659,10 @@ namespace WTelegram
|
|||
/// <param name="includeKickBan">Also fetch the kicked/banned members?</param>
|
||||
/// <param name="alphabet1">first letters used to search for in participants names<br/>(default values crafted with ♥ to find most latin and cyrillic names)</param>
|
||||
/// <param name="alphabet2">second (and further) letters used to search for in participants names</param>
|
||||
/// <param name="cancellationToken">Can be used to abort the work of this method</param>
|
||||
/// <returns>Field count indicates the total count of members. Field participants contains those that were successfully fetched</returns>
|
||||
/// <remarks>⚠ This method can take a few minutes to complete on big broadcast channels. It likely won't be able to obtain the full total count of members</remarks>
|
||||
public async Task<Channels_ChannelParticipants> Channels_GetAllParticipants(InputChannelBase channel, bool includeKickBan = false, string alphabet1 = "АБCДЕЄЖФГHИІJКЛМНОПQРСТУВWХЦЧШЩЫЮЯЗ", string alphabet2 = "АCЕHИJЛМНОРСТУВWЫ")
|
||||
public async Task<Channels_ChannelParticipants> Channels_GetAllParticipants(InputChannelBase channel, bool includeKickBan = false, string alphabet1 = "АБCДЕЄЖФГHИІJКЛМНОПQРСТУВWХЦЧШЩЫЮЯЗ", string alphabet2 = "АCЕHИJЛМНОРСТУВWЫ", CancellationToken cancellationToken = default)
|
||||
{
|
||||
alphabet2 ??= alphabet1;
|
||||
var result = new Channels_ChannelParticipants { chats = new(), users = new() };
|
||||
|
|
@ -1689,6 +1690,7 @@ namespace WTelegram
|
|||
int maxCount = 0;
|
||||
for (int offset = 0; ;)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
ccp = await this.Channels_GetParticipants(channel, filter, offset, 1024, 0);
|
||||
if (ccp.count > maxCount) maxCount = ccp.count;
|
||||
foreach (var kvp in ccp.chats) result.chats[kvp.Key] = kvp.Value;
|
||||
|
|
|
|||
Loading…
Reference in a new issue