问题
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