Rollback for backward compatibility, added NewInlineQueryResultArticleMarkdown and NewInlineQueryResultArticleHTML
This commit is contained in:
parent
0a1b57cdf9
commit
862c67342c
3 changed files with 121 additions and 5 deletions
70
bot_test.go
70
bot_test.go
|
@ -501,7 +501,75 @@ func ExampleAnswerInlineQuery() {
|
|||
continue
|
||||
}
|
||||
|
||||
article := tgbotapi.NewInlineQueryResultArticle(update.InlineQuery.ID, "Echo", update.InlineQuery.Query, "Markdown")
|
||||
article := tgbotapi.NewInlineQueryResultArticle(update.InlineQuery.ID, "Echo", update.InlineQuery.Query)
|
||||
article.Description = update.InlineQuery.Query
|
||||
|
||||
inlineConf := tgbotapi.InlineConfig{
|
||||
InlineQueryID: update.InlineQuery.ID,
|
||||
IsPersonal: true,
|
||||
CacheTime: 0,
|
||||
Results: []interface{}{article},
|
||||
}
|
||||
|
||||
if _, err := bot.AnswerInlineQuery(inlineConf); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleAnswerInlineQueryMarkdown() {
|
||||
bot, err := tgbotapi.NewBotAPI("MyAwesomeBotToken") // create new bot
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
|
||||
log.Printf("Authorized on account %s", bot.Self.UserName)
|
||||
|
||||
u := tgbotapi.NewUpdate(0)
|
||||
u.Timeout = 60
|
||||
|
||||
updates, err := bot.GetUpdatesChan(u)
|
||||
|
||||
for update := range updates {
|
||||
if update.InlineQuery == nil { // if no inline query, ignore it
|
||||
continue
|
||||
}
|
||||
|
||||
article := tgbotapi.NewInlineQueryResultArticleMarkdown(update.InlineQuery.ID, "Echo", update.InlineQuery.Query)
|
||||
article.Description = update.InlineQuery.Query
|
||||
|
||||
inlineConf := tgbotapi.InlineConfig{
|
||||
InlineQueryID: update.InlineQuery.ID,
|
||||
IsPersonal: true,
|
||||
CacheTime: 0,
|
||||
Results: []interface{}{article},
|
||||
}
|
||||
|
||||
if _, err := bot.AnswerInlineQuery(inlineConf); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleAnswerInlineQueryHTML() {
|
||||
bot, err := tgbotapi.NewBotAPI("MyAwesomeBotToken") // create new bot
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
|
||||
log.Printf("Authorized on account %s", bot.Self.UserName)
|
||||
|
||||
u := tgbotapi.NewUpdate(0)
|
||||
u.Timeout = 60
|
||||
|
||||
updates, err := bot.GetUpdatesChan(u)
|
||||
|
||||
for update := range updates {
|
||||
if update.InlineQuery == nil { // if no inline query, ignore it
|
||||
continue
|
||||
}
|
||||
|
||||
article := tgbotapi.NewInlineQueryResultArticleHTML(update.InlineQuery.ID, "Echo", update.InlineQuery.Query)
|
||||
article.Description = update.InlineQuery.Query
|
||||
|
||||
inlineConf := tgbotapi.InlineConfig{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue