using Telegram.Bot; using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; using var cts = new CancellationTokenSource(); var bot = new TelegramBotClient(Environment.GetEnvironmentVariable("TELEGRAM_BOT_TOKEN"), cancellationToken:cts.Token); var me = bot.GetMe(); bot.OnMessage += OnMessage; Console.ReadLine(); cts.Cancel(); async Task OnMessage(Message msg, UpdateType type) { //Discard any message that is not a text message if (msg.Type != MessageType.Text) return; //Check if the message contains the bot's username if (msg.Text!.Contains(me.Result.Username!, StringComparison.OrdinalIgnoreCase)) await bot.SendMessage(msg.Chat, "You mentioned me!"); //Check if the message is a reply to a message sent by the bot else if(msg.ReplyToMessage != null && msg.ReplyToMessage.From!.Id == me.Result.Id){ await bot.SendMessage(msg.Chat, "You replied to a message!"); } //We can safely return otherwise } HttpClient AiClient = new HttpClient(); string getNemesisMsg() { //AiClient.GetAsync() return ""; }