File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -436,3 +436,37 @@ func ExampleNewWebhook() {
436436 log .Printf ("%+v\n " , update )
437437 }
438438}
439+
440+ func ExampleAnswerInlineQuery () {
441+ bot , err := tgbotapi .NewBotAPI ("MyAwesomeBotToken" ) // create new bot
442+ if err != nil {
443+ log .Panic (err )
444+ }
445+
446+ log .Printf ("Authorized on account %s" , bot .Self .UserName )
447+
448+ u := tgbotapi .NewUpdate (0 )
449+ u .Timeout = 60
450+
451+ updates , err := bot .GetUpdatesChan (u )
452+
453+ for update := range updates {
454+ if update .InlineQuery .Query == "" { // if no inline query, ignore it
455+ continue
456+ }
457+
458+ article := tgbotapi .NewInlineQueryResultArticle (update .InlineQuery .ID , "Echo" , update .InlineQuery .Query )
459+ article .Description = update .InlineQuery .Query
460+
461+ inlineConf := tgbotapi.InlineConfig {
462+ InlineQueryID : update .InlineQuery .ID ,
463+ IsPersonal : true ,
464+ CacheTime : 0 ,
465+ Results : []interface {}{article },
466+ }
467+
468+ if _ , err := bot .AnswerInlineQuery (inlineConf ); err != nil {
469+ log .Println (err )
470+ }
471+ }
472+ }
You can’t perform that action at this time.
0 commit comments