Skip to content

Latest commit

 

History

History
54 lines (32 loc) · 2.06 KB

inline.md

File metadata and controls

54 lines (32 loc) · 2.06 KB

Inline Mode

inline mode bot API inline queries example

Telegram bots can be queried directly in the chat or via inline queries.

To use inline queries in your bot, you need to set up inline mode by command:

/setinline command in BotFather

Import Telegram.Bot.Types.InlineQueryResults namespace for inline query types.

There are two types that allow you to work with inline queries - InlineQuery and ChosenInlineResult:

{{#include ../../Examples/3/Inline.cs:switch-statement}}

InlineQuery

inline query result bot API

Suppose we have two arrays:

{{#include ../../Examples/3/Inline.cs:arrays}}

So we can handle inline queries this way:

{{#include ../../Examples/3/Inline.cs:on-inline-query-received}}

InlineQueryResult is an abstract type used to create a response for inline queries. You can use these result types for inline queries: InlineQueryResultArticle for articles, InlineQueryResultPhoto for photos, etc.

ChosenInlineResult

chosen inline result bot API

This type helps to handle chosen inline result. For example, you may want to know which result users chose:

{{#include ../../Examples/3/Inline.cs:on-chosen-inline-result-received}}

To use the feature you need to enable "inline feedback" in BotFather by /setinlinefeedback command:

set inline feedback command

Final result:

result