【发布时间】:2021-08-23 17:41:18
【问题描述】:
在使用 C# 的 ASP.NET MVC 中,我无法接收 CallbackQuery。我有InlineKeyoardButton,但是当我在电报机器人中点击它时,它不起作用。
一切正常,所以内联按钮不起作用。
这是我的代码:
using System;
using System.Web.Mvc;
using Telegram.Bot;
using Telegram.Bot.Args;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups;
namespace FinalBot.Controllers
{
public class HomeController : Controller
{
public static long chatId;
public static string message;
public static TelegramBotClient bot;
[HttpPost()]
public void Index(Update update)
{
bot = new TelegramBotClient("bot token");
chatId = update.Message.Chat.Id;
message = update.Message.Text;
if (message.Contains("start"))
{
InlineKeyboardButton a = new InlineKeyboardButton()
{
Text = "about",
CallbackData = "a"
};
InlineKeyboardButton[] row1 =
{
a
};
InlineKeyboardMarkup inline = new InlineKeyboardMarkup(row1);
bot.SendTextMessageAsync(update.Message.Chat.Id, "select", replyMarkup: inline);
}
if (update.CallbackQuery != null)
{
bot.SendTextMessageAsync("myChat ID", "callback is ok");
}
}
}
}
现在当有人点击内联按钮时,什么都不会发生我尝试了很多东西我仍然无法解决问题
//帮助//
【问题讨论】:
-
嗨。你在botfother中设置了回调延迟吗?在
botfother中检查您的机器人设置 -
嗨。我检查了我的机器人的设置,但设置中没有回调延迟(在 botfather 中)
-
我仔细检查了一下,有
/setinlinefeedback设置。设置那个 -
还没有工作。你有内联按钮和回调的示例代码吗??
标签: c# asp.net-mvc bots telegram