go-telegram-bot-api / telegram-bot-api

Golang bindings for the Telegram Bot API
https://go-telegram-bot-api.dev
MIT License
5.62k stars 868 forks source link

answer inline query #577

Closed hamidreza01 closed 1 year ago

hamidreza01 commented 1 year ago

hello I need help answering inline query, no functional, no constructor, nothing! Please show me a code sample of answering inline query if possible.

temamagic commented 1 year ago

Check out wiki

https://github.com/go-telegram-bot-api/telegram-bot-api/wiki/Simple-Inline-Keyboard

AvicennaJr commented 1 year ago

hello I need help answering inline query, no functional, no constructor, nothing! Please show me a code sample of answering inline query if possible.

CallbackConfig is the response type for CallbackQueries. Here's an example on how to use it:

responseMsg := tgbotapi.NewCallbackWithAlert(update.CallbackQuery.ID, "A callback response")
if _, err := bot.Request(responseMsg); err != nil {
                log.Panic(err)
}
SphericalPotatoInVacuum commented 1 year ago

Check out wiki

https://github.com/go-telegram-bot-api/telegram-bot-api/wiki/Simple-Inline-Keyboard

I believe hamidreza01 is talking about the inline mode for the bot and the inline queries in particular

hamidreza01 commented 1 year ago

Check out wiki https://github.com/go-telegram-bot-api/telegram-bot-api/wiki/Simple-Inline-Keyboard

I believe hamidreza01 is talking about the inline mode for the bot and the inline queries in particular

Yes exactly, it is different from inline keyboards

oneart-dev commented 1 year ago
updates := bot.ListenForWebhook("/" + bot.Token)
for update := range updates {

    if update.InlineQuery == nil {
        continue
    }

    result := tgbotapi.InlineQueryResultArticle{
        Type:  "article",
        ID:    "*UNIQUE_ID*",
        Title: "Title",
        InputMessageContent: tgbotapi.InputTextMessageContent{
            Text: "text inserted after clicking on the result",
        },
    }

    _, err := bot.Send(tgbotapi.InlineConfig{
        InlineQueryID: update.InlineQuery.ID,
        Results:       []interface{}{result},
        CacheTime:     60,
        IsPersonal:    true,
    })
}
hamidreza01 commented 1 year ago
updates := bot.ListenForWebhook("/" + bot.Token)
for update := range updates {

    if update.InlineQuery == nil {
        continue
    }

    result := tgbotapi.InlineQueryResultArticle{
        Type:  "article",
        ID:    "*UNIQUE_ID*",
        Title: "Title",
        InputMessageContent: tgbotapi.InputTextMessageContent{
            Text: "text inserted after clicking on the result",
        },
    }

    _, err := bot.Send(tgbotapi.InlineConfig{
        InlineQueryID: update.InlineQuery.ID,
        Results:       []interface{}{result},
        CacheTime:     60,
        IsPersonal:    true,
    })
}

Yes, that is exactly right, thank you