Clean up some formatting.
parent
7f37376fd0
commit
13f31854a2
68
bot_test.go
68
bot_test.go
|
@ -516,71 +516,3 @@ func ExampleAnswerInlineQuery() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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{
|
|
||||||
InlineQueryID: update.InlineQuery.ID,
|
|
||||||
IsPersonal: true,
|
|
||||||
CacheTime: 0,
|
|
||||||
Results: []interface{}{article},
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := bot.AnswerInlineQuery(inlineConf); err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -335,7 +335,7 @@ func NewInlineQueryResultArticleMarkdown(id, title, messageText string) InlineQu
|
||||||
ID: id,
|
ID: id,
|
||||||
Title: title,
|
Title: title,
|
||||||
InputMessageContent: InputTextMessageContent{
|
InputMessageContent: InputTextMessageContent{
|
||||||
Text: messageText,
|
Text: messageText,
|
||||||
ParseMode: "Markdown",
|
ParseMode: "Markdown",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -348,7 +348,7 @@ func NewInlineQueryResultArticleHTML(id, title, messageText string) InlineQueryR
|
||||||
ID: id,
|
ID: id,
|
||||||
Title: title,
|
Title: title,
|
||||||
InputMessageContent: InputTextMessageContent{
|
InputMessageContent: InputTextMessageContent{
|
||||||
Text: messageText,
|
Text: messageText,
|
||||||
ParseMode: "HTML",
|
ParseMode: "HTML",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue