gpt4 book ai didi

Telegram bot - 用纯文本回答内联查询?

转载 作者:行者123 更新时间:2023-12-03 19:26:27 30 4
gpt4 key购买 nike

我正在尝试制作一个内联 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/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com