Telegram Bot in ASP.Net Web Form

≯℡__Kan透↙ 提交于 2020-06-29 03:42:30

问题


I have this "Net Core Console App" code for Telegram Bot

class Program
{
    private static readonly TelegramBotClient bot = new TelegramBotClient(MyToken);

    static void Main(string[] args)
    {
        bot.OnMessage += tgramBotTestMSG;
        bot.StartReceiving();
        Console.ReadLine();
        bot.StopReceiving();
    }

    private static void tgramBotTestMSG(object sender, MessageEventArgs e)
    {
        if (e.Message.Type == Telegram.Bot.Types.Enums.MessageType.Text)
            PrepareQuestionnaires(e);
    }

    public static void PrepareQuestionnaires(MessageEventArgs e)
    {
        if (e.Message.Text.ToLower() == "hi")
            bot.SendTextMessageAsync(e.Message.Chat.Id, "hello");
    }
}

Is it possible that I would write this code in a class file in my ASP.net Web Forms Project and run this class on Page Load? If so, how can I do that? And if not, what are other ways to integrate my Telegram bot and most importantly RECEIVE and SEND messages on my Bot using ASP.net Web forms?

来源:https://stackoverflow.com/questions/62503881/telegram-bot-in-asp-net-web-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!