A
A
armadillo-cld2020-07-07 14:15:31
C++ / C#
armadillo-cld, 2020-07-07 14:15:31

How to make individual bot settings for each user?

Hello everyone.
In general, there is such a problem.
I have C# Telegram Bot code:

private static TelegramBotClient botclient;
private static bool registered = false;
...
botclient = new TelegramBotClient("************");
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
botclient.OnMessage += Bot_OnMessage;
botclient.StartReceiving();
Console.ReadLine();
...
public static void Bot_OnMessage(Object sender, MessageEventArgs e)
        {
            var text = e.Message.Text;
            if (text == null)
            {
                return;
            }
            
            if(text.StartsWith("/pass ")) {
                string pass = text.Remove(text.IndexOf("/pass ", 6));
                if (pass == "123123") { 
                   registered = true;
                }
            }
         
            if(registered == false)
            {
                botclient.SendTextMessageAsync(e.Message.Chat.Id, "Вы не зарегистрированы! Введите пароль с помощью /pass");
            }
            else {
                   botclient.SendTextMessageAsync(e.Message.Chat.Id, "Вы зарегистрированы!");
            }
        }

But the fact is that if I register, then all other users will display "You are registered".
How can I make sure that variables are applied individually for each user?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
yuopi, 2020-07-07
@yuopi

Screw the database

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question