wiz0u / WTelegramClient

Telegram Client API (MTProto) library written 100% in C# and .NET
https://wiz0u.github.io/WTelegramClient/
MIT License
996 stars 164 forks source link

How to pull the message history not from the group, but from the dialogue with the user? #108

Closed Ma-ZaHaKa closed 1 year ago

Ma-ZaHaKa commented 1 year ago

How to pull the history of messages not from a group but from a dialog?

awskt commented 1 year ago
WTelegram.Client tg = new(Config);

var my = await tg.LoginUserIfNeeded();

if (await tg.Messages_GetDialogs() is not TL.Messages_DialogsSlice chats) {
    return;
}
var a = chats.users.FirstOrDefault();

var messages = await tg.Messages_GetHistory(a.Value);
Console.WriteLine(string.Join('\n', messages.Messages.OfType<Message>().Select(x => x.Date + " " + x.message)));
wiz0u commented 1 year ago
foreach (Dialog dialog in dialogs.Dialogs)
{
    var peer = dialogs.UserOrChat(dialog);
    var history = await client.Messages_GetHistory(peer.ToInputPeer());
}