Skip to content

OnMessage not working after restart the Application #44

@Xeddon

Description

@Xeddon

This is my Code. On first run everything worked correctly. But when the program is closed and reopened again than UpdateHandler not get called anymore. client.IsUserAuthorized() gives true. When i delete Session.dat i can reenter my code and it will work. After 5 runs of the programm i have to wait 24 hours because of flood error.

    public class Program
    {
        static void Main(string[] args)
        {
                Program program = new Program();
                Task.Run(async () => await program.Run()).Wait();
        }

        public async Task Run()
        {
                TelegramClient client = new TelegramClient(new FileSessionStore(), 129340, "...", new DeviceInfo("Telegram Test", "Telegram Test", "Telegram Test", "en"));
                client.UpdateMessage += UpdateHandler;
                await client.Start();
                if (!client.IsUserAuthorized())
                {
                    var codeRequest = await client.SendCode("+...", VerificationCodeDeliveryType.NumericCodeViaTelegram);
                    string input = "";
                    await client.SignIn("+...", codeRequest.phoneCodeHash, input);
                }
        }

        private void UpdateHandler(object sender, Updates updates)
        {
            if (updates.constructor == Constructor.UpdateShortMessage)
            {
                var updateShortMessageConstructor = updates as UpdateShortMessageConstructor;
            }
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions