Answer the question
In order to leave comments, you need to log in
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, "Вы зарегистрированы!");
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question