我正在尝试制作一个内联 Telegram 机器人,它会以某种方式修改用户输入。因此,我想用简单的文本回答查询,但这似乎不可能,我想知道它是否真的不是,或者我遗漏了什么。
根据 Telegram,有 20 handy result types ,但似乎没有简单的纯文本。真的是这样吗?那我怎样才能达到我想要的结果呢?
最佳答案
我遇到了同样的问题并使用 InlineQueryResultArticle
解决了它.
您的 OnInlineQuery
的示例代码方法:
// Check for invalid queries
if (e.InlineQuery.Query == null)
return;
if (e.InlineQuery.Query == "")
return;
InlineQueryResultBase[] results = {
new InlineQueryResultArticle(
// id's should be unique for each type of response
id: "1",
// Title of the option
title: "sample title",
// This is what is returned
new InputTextMessageContent("text that is returned") {ParseMode = Telegram.Bot.Types.Enums.ParseMode.Default })
{
// This is just the description shown for the option
Description = "You could also put your output text for a preview here too."
}
};
// Send the response
try
{
// If your method is not async you have to remove the await
await client.AnswerInlineQueryAsync(e.InlineQuery.Id, results);
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"Error responding to Inline Query! {ex.Message}");
}
关于Telegram bot - 用纯文本回答内联查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57119776/