Skip to content

Commit f0335a1

Browse files
committed
Add more Walkthrough sections
1 parent 06456dc commit f0335a1

2 files changed

Lines changed: 111 additions & 0 deletions

File tree

src/editing-inline-messages.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: Editing Inline Messages
3+
parent: /#walkthrough
4+
walkthrough:
5+
track: bot
6+
order: 18
7+
---
8+
9+
Bots can edit inline messages after a user selects an inline query result or interacts with an inline keyboard.
10+
11+
## Editing the Text
12+
13+
In a `chosenInlineResult` or `callbackQuery` handler, use the context shortcut for {{ "editInlineMessageText" |> m }}.
14+
15+
```ts
16+
client.on("chosenInlineResult", async (ctx) => {
17+
await ctx.editInlineMessageText("Updated content.");
18+
});
19+
```
20+
21+
## Editing the Caption
22+
23+
Use the context shortcut for {{ "editInlineMessageCaption" |> m }} to update the caption.
24+
25+
```ts
26+
client.on("chosenInlineResult", async (ctx) => {
27+
await ctx.editInlineMessageCaption({ caption: "New caption." });
28+
});
29+
```
30+
31+
## Editing the Reply Markup
32+
33+
Use the context shortcut for {{ "editInlineMessageReplyMarkup" |> m }} to change the inline keyboard.
34+
35+
```ts
36+
client.callbackQuery("refresh", async (ctx) => {
37+
await ctx.editInlineMessageReplyMarkup({
38+
replyMarkup: [[{ text: "Refreshed", callbackData: "done" }]],
39+
});
40+
await ctx.answerCallbackQuery();
41+
});
42+
```

src/gifts.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: Gifts
3+
parent: /#walkthrough
4+
walkthrough:
5+
track: main
6+
order: 22
7+
---
8+
9+
Clients can browse, send, sell, and transfer Telegram Star gifts.
10+
11+
## Getting Available Gifts
12+
13+
Use {{ "getGifts" |> m }} to list the gifts available for purchase.
14+
15+
```ts
16+
const gifts = await client.getGifts();
17+
18+
for (const gift of gifts) {
19+
console.log(gift.id, gift.price);
20+
}
21+
```
22+
23+
`id` is the identifier used when sending a gift.
24+
25+
## Getting a Gift
26+
27+
Use {{ "getGift" |> m }} with a gift slug to fetch its details.
28+
29+
```ts
30+
const gift = await client.getGift("delicious-bento");
31+
```
32+
33+
## Sending a Gift
34+
35+
Use {{ "sendGift" |> m }} with the recipient and the gift identifier to purchase and send a gift.
36+
37+
```ts
38+
await client.sendGift(userId, giftId);
39+
```
40+
41+
Optionally, pass a `message` to attach text to the gift.
42+
43+
```ts
44+
await client.sendGift(userId, giftId, {
45+
message: "Enjoy!",
46+
});
47+
```
48+
49+
## Selling a Gift
50+
51+
Use {{ "sellGift" |> m }} to convert a saved gift to Telegram Stars. Reference the gift by its chat and identifier.
52+
53+
```ts
54+
await client.sellGift({ type: "chat", chatId, id });
55+
```
56+
57+
For a gift in a private chat, use `type: "user"` with the `messageId`.
58+
59+
```ts
60+
await client.sellGift({ type: "user", messageId });
61+
```
62+
63+
## Transferring a Gift
64+
65+
Use {{ "transferGift" |> m }} to give a saved gift to another user.
66+
67+
```ts
68+
await client.transferGift(userId, { type: "chat", chatId, id });
69+
```

0 commit comments

Comments
 (0)