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

Getting argument for Updates_GetDifference in UpdateNewMessage event #140

Closed SergeevGregory closed 1 year ago

SergeevGregory commented 1 year ago

Dear wiz0u, I have question about situation like this (programmatically click a button in a Bot): https://github.com/wiz0u/WTelegramClient/issues/58 (https://stackoverflow.com/questions/72198289/c-sharp-wtelegramclient-telegram-api-how-to-programmatically-click-a-button-in-a/72228923#72228923)

I haven't problems with clicking a button, but I can't understand how get pts, date, qts for correct execution of Updates_GetDifference in OnUpdate (UpdateNewMessage):

          ...

           client.OnUpdate += async (arg) =>
            {
                if (arg is not UpdatesBase updates) return;
                foreach (var update in updates.UpdateList)
                {
                    Console.WriteLine(update);
                    switch (update)
                    {
                        case UpdateNewMessage unm:
                          var differenceMessages = Updates_GetDifference(???,???,???); <= Here problem with arguments
                          MyProcessButton(differenceMessages, ...);
                    }
                }
            }

            var resolved = await client.Contacts_ResolveUsername("sample");
            var res = await client.SendMessageAsync(resolved, "test");

If I execute Updates_GetDifference like this:

var differenceMessages = await client.Updates_GetDifference(unm.pts, unm.message.Date, 0/*qts*/);

Often Updates_GetDifference doesn't return needed message with ReplyInlineMarkup

Сan you help with advice? Thx

wiz0u commented 1 year ago

That's an interesting question about Telegram API usage. However it is not an issue with the library itself, so here is not the right place to ask.

This kind of question should be asked on StackOverflow so it can benefits the community: https://stackoverflow.com/questions/ask?tags=c%23+wtelegramclient+telegram-api

Also I'm not very familiar in this topic so I won't be of much help, and I'm not sure why you need to call that method for UpdateNewMessage. For me, the only reason to call it is to get more info in case of UpdateShortMessage