我正在尝试制作一个嵌入式Telegram机器人,该机器人将以某种方式修改用户输入。因此,我想用简单的文本回答查询,但这似乎是不可能的,我想知道它是否确实不是,或者我错过了什么。
根据电报,有20 handy result types,但似乎没有简单的纯文本。真的是这样吗?那我怎样才能达到我想要的结果呢?
答案 0 :(得分:1)
我遇到了同样的问题,并用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}");
}
答案 1 :(得分:0)
使用“ InlineQueryResultArticle”并将“ url”的值设置为undefined或不设置“ url” fileld。