Skip to content

Commit e98297f

Browse files
author
Stanislav Parshin
committed
Update README.md
1 parent 9f6da20 commit e98297f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,34 @@ To get downloading link as `https://api.telegram.org/file/bot<token>/<file_path>
139139
```java
140140
String fullPath = bot.getFullFilePath("fileId");
141141
String fullPath = bot.getFullFilePath(file); // com.pengrad.telegrambot.model.File
142+
```
143+
#### Inline mode
144+
Getting updates
145+
```java
146+
GetUpdatesResponse updatesResponse = bot.getUpdates(offset, limit, timeout);
147+
List<Update> updates = updatesResponse.updates();
148+
...
149+
InlineQuery inlineQuery = update.inlineQuery();
150+
```
151+
If using webhook, you can parse request to InlineQuery
152+
```java
153+
Update update = BotUtils.parseUpdate(stringRequest); // from String
154+
Update update = BotUtils.parseUpdate(reader); // from java.io.Reader
155+
InlineQuery inlineQuery = update.inlineQuery();
156+
```
157+
Build InlineQueryResult
158+
```java
159+
InlineQueryResult r1 = new InlineQueryResultPhoto("id", "photoUrl", "thumbUrl");
160+
InlineQueryResult r2 = new InlineQueryResultArticle("id", "title", "message text").thumbUrl("url");
161+
InlineQueryResult r3 = new InlineQueryResultGif("id", "gifUrl", "thumbUrl");
162+
InlineQueryResult r4 = new InlineQueryResultMpeg4Gif("id", "mpeg4Url", "thumbUrl");
163+
InlineQueryResult r5 = new InlineQueryResultVideo("id", "videoUrl", InlineQueryResultVideo.MIME_VIDEO_MP4, "message text", "thumbUrl", "video title");
164+
```
165+
Send query
166+
```java
167+
bot.answerInlineQuery(inlineQuery.id(), r1, r2, r3, r4, r5);
168+
// or full
169+
bot.answerInlineQuery(inlineQuery.id(), new InlineQueryResult[]{r1, r2, r3, r4, r5}, cacheTime, isPersonal, nextOffset);
142170
```
143171

144172

0 commit comments

Comments
 (0)