Inline Queries

Inline queries are used to search for content in your bot. When a user types a query in the chat, the bot receives an inline query. You can handle these queries using the AddInlineHandler method.

package main
 
import (
    "github.com/amarnathcjd/gogram/telegram"
)
 
func main() {
    client, _ := telegram.NewClient(telegram.ClientConfig{ // Create a new client
        AppID:   6,
        AppHash: "app_hash",
    })
 
    client.AddInlineHandler(telegram.OnInlineQuery, DemoInlineResult)
 
    client.Start()
}
 
func DemoInlineResult(i *telegram.InlineQuery) error {
	builder := i.Builder()
	button := telegram.Button{}
 
	builder.Article("Austin & Ally",
		"ImDB 6.0",
		"2011 TV Series",
		&telegram.ArticleOptions{
			ReplyMarkup: button.Keyboard(
				button.Row(
					button.URL("Open Website", "https://www.imdb.com/title/tt1835842/"),
				),
			),
		})
        
	builder.Article("Wizards of Waverly Place",
		"ImDB 6.7",
		"2007 TV Series",
		&telegram.ArticleOptions{
			ReplyMarkup: button.Keyboard(
				button.Row(
					button.URL("Open Website", "https://www.imdb.com/title/tt0799922/"),
				),
			),
		})
	_, err := i.Answer(builder.Results())
	return err
}