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

标签 telegram

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

相关文章:

php - 在 PHP 中使用 Telegram API

java - 我应该如何修复这个由于在 Heroku 上运行而导致的 Java 错误?

Telegram bot api 模拟用户交互

security - 防止将 Telegram 机器人添加到任何组或 channel (允许将其添加到白名单组/ channel )

Telegram BOT API : how to change a photo (not the caption)

javascript - 聊天字段上的 Telegram Bot 键盘

java - Telegram 最新层

telegram - Telegram Bot 共享文本的深层链接是什么?

php - 使用 Telegram 的 API 创建群组

python - 使用 Python 发送 Telegram 键盘