diff --git a/README.md b/README.md index d085aeb..5bf0849 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This library allows you to connect to Telegram and control a user programmatically (or a bot, but [WTelegramBot](https://www.nuget.org/packages/WTelegramBot) is much easier for that). All the Telegram Client APIs (MTProto) are supported so you can do everything the user could do with a full Telegram GUI client. -Library was developed solely by one unemployed guy. [Donations are welcome](https://buymeacoffee.com/wizou). +Library was developed solely by one unemployed guy. [Donations](https://buymeacoffee.com/wizou) or [Patreon memberships are welcome](https://patreon.com/wizou). This ReadMe is a **quick but important tutorial** to learn the fundamentals about this library. Please read it all. diff --git a/src/Client.Helpers.cs b/src/Client.Helpers.cs index 3cc888f..2dd3c59 100644 --- a/src/Client.Helpers.cs +++ b/src/Client.Helpers.cs @@ -535,18 +535,20 @@ namespace WTelegram case Messages_DialogsSlice mds: var dialogList = new List(); var messageList = new List(); - while (dialogs.Dialogs.Length != 0) + int skip = 0; + while (dialogs.Dialogs.Length > skip) { - dialogList.AddRange(dialogs.Dialogs); + dialogList.AddRange(skip == 0 ? dialogs.Dialogs : dialogs.Dialogs[skip..]); messageList.AddRange(dialogs.Messages); + skip = 0; int last = dialogs.Dialogs.Length - 1; var lastDialog = dialogs.Dialogs[last]; + retryDate: var lastPeer = dialogs.UserOrChat(lastDialog).ToInputPeer(); var lastMsgId = lastDialog.TopMessage; - retryDate: var lastDate = dialogs.Messages.LastOrDefault(m => m.Peer.ID == lastDialog.Peer.ID && m.ID == lastDialog.TopMessage)?.Date ?? default; if (lastDate == default) - if (--last < 0) break; else { lastDialog = dialogs.Dialogs[last]; goto retryDate; } + if (--last < 0) break; else { ++skip; lastDialog = dialogs.Dialogs[last]; goto retryDate; } dialogs = await this.Messages_GetDialogs(lastDate, lastMsgId, lastPeer, folder_id: folder_id); if (dialogs is not Messages_Dialogs md) break; foreach (var (key, value) in md.chats) mds.chats[key] = value;