M
M
Michael2018-05-20 13:18:24
C++ / C#
Michael, 2018-05-20 13:18:24

Why can't I launch the bot on Telegram.Bot?

Hello. I'm trying to write a bot using Telegram.Bot. The code is like this:

var Bot = new Telegram.Bot.TelegramBotClient("221525126:AAFNt2Hgidk_rnIovjwNqj4pzPWZetnOVNs"); // Инициализируем
await Bot.SetWebhookAsync(""); // Убираем старую привязку к WebHook

Bot.OnUpdate += async (object su, Telegram.Bot.Args.UpdateEventArgs updates) =>
                {
                    Console.WriteLine("Text");
                    if (updates.Update.CallbackQuery != null || updates.Update.InlineQuery != null) return;
                    var update = updates.Update;
                    var message = update.Message;
                    if (message == null) return;

                    if (message.Type == Telegram.Bot.Types.Enums.MessageType.Text)
                    {
                        await Bot.SendTextMessageAsync(message.Chat.Id, "dd", replyToMessageId: message.MessageId);
                    }
                };

Bot.StartReceiving();

The bot starts successfully, but does not respond to messages. No errors are caught (I wrapped it in try-catch). I tried to set breakpoints, but they show that the message handler is not called.
What is the problem?
Z. Y. Valid token

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Bashinsky, 2018-05-20
@BashkaMen

how is this code called?
in console?

F
fast0490f, 2018-05-20
@fast0490f

Does Roskomnadzor bother you by any chance?

O
Oleh, 2019-01-23
@key_a1tos

Is inline mode enabled in botfather?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question