grammy 1.16.2 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -3
- package/out/bot.d.ts +9 -1
- package/out/bot.js +60 -16
- package/out/composer.d.ts +37 -10
- package/out/composer.js +27 -7
- package/out/context.d.ts +29 -1
- package/out/context.js +16 -0
- package/out/convenience/constants.d.ts +54 -0
- package/out/convenience/constants.js +60 -0
- package/out/convenience/inline_query.d.ts +401 -0
- package/out/convenience/inline_query.js +461 -0
- package/out/convenience/input_media.d.ts +72 -0
- package/out/convenience/input_media.js +82 -0
- package/out/convenience/keyboard.d.ts +392 -13
- package/out/convenience/keyboard.js +518 -34
- package/out/core/api.d.ts +1 -1
- package/out/core/api.js +1 -1
- package/out/filter.d.ts +2 -0
- package/out/filter.js +3 -1
- package/out/mod.d.ts +3 -0
- package/out/mod.js +3 -0
- package/out/types.node.d.ts +4 -2
- package/out/types.node.js +11 -5
- package/out/web.mjs +568 -47
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -166,7 +166,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
166
166
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Asaku01"><img src="https://avatars.githubusercontent.com/u/29716396?v=4?s=100" width="100px;" alt="Asaku01"/><br /><sub><b>Asaku01</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Asaku01" title="Documentation">📖</a></td>
|
|
167
167
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ppsimn"><img src="https://avatars.githubusercontent.com/u/88509883?v=4?s=100" width="100px;" alt="ppsimn"/><br /><sub><b>ppsimn</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Appsimn" title="Bug reports">🐛</a></td>
|
|
168
168
|
<td align="center" valign="top" width="14.28%"><a href="https://satont.js.org/"><img src="https://avatars.githubusercontent.com/u/42675886?v=4?s=100" width="100px;" alt="Satont"/><br /><sub><b>Satont</b></sub></a><br /><a href="#plugin-Satont" title="Plugin/utility libraries">🔌</a> <a href="https://github.com/grammyjs/grammY/commits?author=Satont" title="Documentation">📖</a></td>
|
|
169
|
-
<td align="center" valign="top" width="14.28%"><a href="https://github.com/deptyped"><img src="https://avatars.githubusercontent.com/u/26162440?v=4?s=100" width="100px;" alt="deptyped"/><br /><sub><b>deptyped</b></sub></a><br /><a href="#example-deptyped" title="Examples">💡</a> <a href="https://github.com/grammyjs/grammY/commits?author=deptyped" title="Documentation">📖</a> <a href="#tutorial-deptyped" title="Tutorials">✅</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3Adeptyped" title="Bug reports">🐛</a></td>
|
|
169
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/deptyped"><img src="https://avatars.githubusercontent.com/u/26162440?v=4?s=100" width="100px;" alt="deptyped"/><br /><sub><b>deptyped</b></sub></a><br /><a href="#example-deptyped" title="Examples">💡</a> <a href="https://github.com/grammyjs/grammY/commits?author=deptyped" title="Documentation">📖</a> <a href="#tutorial-deptyped" title="Tutorials">✅</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3Adeptyped" title="Bug reports">🐛</a> <a href="#translation-deptyped" title="Translation">🌍</a></td>
|
|
170
170
|
</tr>
|
|
171
171
|
<tr>
|
|
172
172
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/dzek69"><img src="https://avatars.githubusercontent.com/u/4936805?v=4?s=100" width="100px;" alt="Jacek Nowacki"/><br /><sub><b>Jacek Nowacki</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=dzek69" title="Documentation">📖</a> <a href="https://github.com/grammyjs/grammY/commits?author=dzek69" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3Adzek69" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Adzek69" title="Reviewed Pull Requests">👀</a> <a href="#ideas-dzek69" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
@@ -190,7 +190,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
190
190
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/taotie111"><img src="https://avatars.githubusercontent.com/u/44166322?v=4?s=100" width="100px;" alt="taotie111"/><br /><sub><b>taotie111</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=taotie111" title="Documentation">📖</a> <a href="#translation-taotie111" title="Translation">🌍</a></td>
|
|
191
191
|
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/merlin-brandes-42328717a/"><img src="https://avatars.githubusercontent.com/u/14237330?v=4?s=100" width="100px;" alt="Merlin"/><br /><sub><b>Merlin</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=FatalMerlin" title="Documentation">📖</a></td>
|
|
192
192
|
<td align="center" valign="top" width="14.28%"><a href="https://darve.sh"><img src="https://avatars.githubusercontent.com/u/22394081?v=4?s=100" width="100px;" alt="Darvesh"/><br /><sub><b>Darvesh</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Adarvesh" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=darvesh" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Adarvesh" title="Reviewed Pull Requests">👀</a></td>
|
|
193
|
-
<td align="center" valign="top" width="14.28%"><a href="http://telegram.me/dcdunkan"><img src="https://avatars.githubusercontent.com/u/70066170?v=4?s=100" width="100px;" alt="dcdunkan"/><br /><sub><b>dcdunkan</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Adcdunkan" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=dcdunkan" title="Code">💻</a> <a href="#plugin-dcdunkan" title="Plugin/utility libraries">🔌</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Adcdunkan" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/commits?author=dcdunkan" title="Documentation">📖</a> <a href="#ideas-dcdunkan" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-dcdunkan" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#tool-dcdunkan" title="Tools">🔧</a></td>
|
|
193
|
+
<td align="center" valign="top" width="14.28%"><a href="http://telegram.me/dcdunkan"><img src="https://avatars.githubusercontent.com/u/70066170?v=4?s=100" width="100px;" alt="dcdunkan"/><br /><sub><b>dcdunkan</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Adcdunkan" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=dcdunkan" title="Code">💻</a> <a href="#plugin-dcdunkan" title="Plugin/utility libraries">🔌</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Adcdunkan" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/commits?author=dcdunkan" title="Documentation">📖</a> <a href="#ideas-dcdunkan" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-dcdunkan" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#tool-dcdunkan" title="Tools">🔧</a> <a href="#mentoring-dcdunkan" title="Mentoring">🧑🏫</a> <a href="#maintenance-dcdunkan" title="Maintenance">🚧</a></td>
|
|
194
194
|
<td align="center" valign="top" width="14.28%"><a href="https://xuann.wang/"><img src="https://avatars.githubusercontent.com/u/44045911?v=4?s=100" width="100px;" alt="Kid"/><br /><sub><b>Kid</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=kidonng" title="Documentation">📖</a> <a href="#translation-kidonng" title="Translation">🌍</a></td>
|
|
195
195
|
<td align="center" valign="top" width="14.28%"><a href="http://slava.fomin.io/"><img src="https://avatars.githubusercontent.com/u/1702725?v=4?s=100" width="100px;" alt="Slava Fomin II"/><br /><sub><b>Slava Fomin II</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aslavafomin" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=slavafomin" title="Documentation">📖</a></td>
|
|
196
196
|
<td align="center" valign="top" width="14.28%"><a href="https://kikobeats.com/"><img src="https://avatars.githubusercontent.com/u/2096101?v=4?s=100" width="100px;" alt="Kiko Beats"/><br /><sub><b>Kiko Beats</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Kikobeats" title="Documentation">📖</a></td>
|
|
@@ -265,7 +265,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
265
265
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/amanape"><img src="https://avatars.githubusercontent.com/u/83104063?v=4?s=100" width="100px;" alt="Stephan Psaras"/><br /><sub><b>Stephan Psaras</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aamanape" title="Bug reports">🐛</a></td>
|
|
266
266
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/shevernitskiy"><img src="https://avatars.githubusercontent.com/u/28886342?v=4?s=100" width="100px;" alt="shevernitskiy"/><br /><sub><b>shevernitskiy</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Ashevernitskiy" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Ashevernitskiy" title="Reviewed Pull Requests">👀</a></td>
|
|
267
267
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mrmaster009"><img src="https://avatars.githubusercontent.com/u/81420490?v=4?s=100" width="100px;" alt="mrmaster009"/><br /><sub><b>mrmaster009</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=mrmaster009" title="Documentation">📖</a></td>
|
|
268
|
-
<td align="center" valign="top" width="14.28%"><a href="https://lwjerri.dev/"><img src="https://avatars.githubusercontent.com/u/50290430?v=4?s=100" width="100px;" alt="Andrey Zontov"/><br /><sub><b>Andrey Zontov</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3ALWJerri" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=LWJerri" title="Code">💻</a> <a href="#question-LWJerri" title="Answering Questions">💬</a> <a href="#ideas-LWJerri" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
268
|
+
<td align="center" valign="top" width="14.28%"><a href="https://lwjerri.dev/"><img src="https://avatars.githubusercontent.com/u/50290430?v=4?s=100" width="100px;" alt="Andrey Zontov"/><br /><sub><b>Andrey Zontov</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3ALWJerri" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=LWJerri" title="Code">💻</a> <a href="#question-LWJerri" title="Answering Questions">💬</a> <a href="#ideas-LWJerri" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=LWJerri" title="Documentation">📖</a> <a href="#translation-LWJerri" title="Translation">🌍</a></td>
|
|
269
269
|
</tr>
|
|
270
270
|
<tr>
|
|
271
271
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/AbbassAlmusawi"><img src="https://avatars.githubusercontent.com/u/73327881?v=4?s=100" width="100px;" alt="Abbass Al-Musawi"/><br /><sub><b>Abbass Al-Musawi</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=AbbassAlmusawi" title="Documentation">📖</a></td>
|
|
@@ -274,6 +274,11 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
274
274
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/MatyiFKBT"><img src="https://avatars.githubusercontent.com/u/6183867?v=4?s=100" width="100px;" alt="MatyiFKBT"/><br /><sub><b>MatyiFKBT</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=MatyiFKBT" title="Documentation">📖</a></td>
|
|
275
275
|
<td align="center" valign="top" width="14.28%"><a href="https://chrisandrew.cl"><img src="https://avatars.githubusercontent.com/u/368831?v=4?s=100" width="100px;" alt="Chris Andrew C. L."/><br /><sub><b>Chris Andrew C. L.</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Achrisandrewcl" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=chrisandrewcl" title="Code">💻</a></td>
|
|
276
276
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kiyasov"><img src="https://avatars.githubusercontent.com/u/16527461?v=4?s=100" width="100px;" alt="Islam Kiiasov"/><br /><sub><b>Islam Kiiasov</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=kiyasov" title="Code">💻</a></td>
|
|
277
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ssistoza"><img src="https://avatars.githubusercontent.com/u/17445445?v=4?s=100" width="100px;" alt="Shane Avery Sistoza"/><br /><sub><b>Shane Avery Sistoza</b></sub></a><br /><a href="#ideas-ssistoza" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=ssistoza" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/commits?author=ssistoza" title="Tests">⚠️</a></td>
|
|
278
|
+
</tr>
|
|
279
|
+
<tr>
|
|
280
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/MaicolAntali"><img src="https://avatars.githubusercontent.com/u/79454487?v=4?s=100" width="100px;" alt="Maicol"/><br /><sub><b>Maicol</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=MaicolAntali" title="Code">💻</a></td>
|
|
281
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Nazar-Ant"><img src="https://avatars.githubusercontent.com/u/75927667?v=4?s=100" width="100px;" alt="Nazar Antoniuk"/><br /><sub><b>Nazar Antoniuk</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Nazar-Ant" title="Documentation">📖</a> <a href="#translation-Nazar-Ant" title="Translation">🌍</a> <a href="#maintenance-Nazar-Ant" title="Maintenance">🚧</a></td>
|
|
277
282
|
</tr>
|
|
278
283
|
</tbody>
|
|
279
284
|
</table>
|
package/out/bot.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { BotError, Composer } from "./composer.js";
|
|
1
|
+
import { BotError, Composer, type Middleware } from "./composer.js";
|
|
2
2
|
import { Context } from "./context.js";
|
|
3
3
|
import { Api } from "./core/api.js";
|
|
4
4
|
import { type ApiClientOptions, type WebhookReplyEnvelope } from "./core/client.js";
|
|
5
|
+
import { type Filter, type FilterQuery } from "./filter.js";
|
|
5
6
|
import { type Update, type UserFromGetMe } from "./types.js";
|
|
7
|
+
export declare const DEFAULT_UPDATE_TYPES: readonly ["message", "edited_message", "channel_post", "edited_channel_post", "inline_query", "chosen_inline_result", "callback_query", "shipping_query", "pre_checkout_query", "poll", "poll_answer", "my_chat_member", "chat_join_request"];
|
|
6
8
|
/**
|
|
7
9
|
* Options that can be specified when running the bot via simple long polling.
|
|
8
10
|
*/
|
|
@@ -117,6 +119,8 @@ export declare class Bot<C extends Context = Context, A extends Api = Api> exten
|
|
|
117
119
|
private mePromise;
|
|
118
120
|
private readonly clientConfig;
|
|
119
121
|
private readonly ContextConstructor;
|
|
122
|
+
/** Used to log a warning if some update types are not in allowed_updates */
|
|
123
|
+
private observedUpdateTypes;
|
|
120
124
|
/**
|
|
121
125
|
* Holds the bot's error handler that is invoked whenever middleware throws
|
|
122
126
|
* (rejects). If you set your own error handler via `bot.catch`, all that
|
|
@@ -155,6 +159,10 @@ export declare class Bot<C extends Context = Context, A extends Api = Api> exten
|
|
|
155
159
|
*/
|
|
156
160
|
set botInfo(botInfo: UserFromGetMe);
|
|
157
161
|
get botInfo(): UserFromGetMe;
|
|
162
|
+
/**
|
|
163
|
+
* @inheritdoc
|
|
164
|
+
*/
|
|
165
|
+
on<Q extends FilterQuery>(filter: Q | Q[], ...middleware: Array<Middleware<Filter<C, Q>>>): Composer<Filter<C, Q>>;
|
|
158
166
|
/**
|
|
159
167
|
* Checks if the bot has been initialized. A bot is initialized if the bot
|
|
160
168
|
* information is set. The bot information can either be set automatically
|
package/out/bot.js
CHANGED
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Bot = exports.BotError = void 0;
|
|
3
|
+
exports.Bot = exports.BotError = exports.DEFAULT_UPDATE_TYPES = void 0;
|
|
4
4
|
// deno-lint-ignore-file camelcase
|
|
5
5
|
const composer_js_1 = require("./composer.js");
|
|
6
6
|
Object.defineProperty(exports, "BotError", { enumerable: true, get: function () { return composer_js_1.BotError; } });
|
|
7
7
|
const context_js_1 = require("./context.js");
|
|
8
8
|
const api_js_1 = require("./core/api.js");
|
|
9
9
|
const error_js_1 = require("./core/error.js");
|
|
10
|
+
const filter_js_1 = require("./filter.js");
|
|
10
11
|
const platform_node_js_1 = require("./platform.node.js");
|
|
11
12
|
const debug = (0, platform_node_js_1.debug)("grammy:bot");
|
|
13
|
+
const debugWarn = (0, platform_node_js_1.debug)("grammy:warn");
|
|
12
14
|
const debugErr = (0, platform_node_js_1.debug)("grammy:error");
|
|
15
|
+
exports.DEFAULT_UPDATE_TYPES = [
|
|
16
|
+
"message",
|
|
17
|
+
"edited_message",
|
|
18
|
+
"channel_post",
|
|
19
|
+
"edited_channel_post",
|
|
20
|
+
"inline_query",
|
|
21
|
+
"chosen_inline_result",
|
|
22
|
+
"callback_query",
|
|
23
|
+
"shipping_query",
|
|
24
|
+
"pre_checkout_query",
|
|
25
|
+
"poll",
|
|
26
|
+
"poll_answer",
|
|
27
|
+
"my_chat_member",
|
|
28
|
+
"chat_join_request",
|
|
29
|
+
];
|
|
13
30
|
/**
|
|
14
31
|
* This is the single most important class of grammY. It represents your bot.
|
|
15
32
|
*
|
|
@@ -53,6 +70,8 @@ class Bot extends composer_js_1.Composer {
|
|
|
53
70
|
this.token = token;
|
|
54
71
|
this.pollingRunning = false;
|
|
55
72
|
this.lastTriedUpdateId = 0;
|
|
73
|
+
/** Used to log a warning if some update types are not in allowed_updates */
|
|
74
|
+
this.observedUpdateTypes = new Set();
|
|
56
75
|
/**
|
|
57
76
|
* Holds the bot's error handler that is invoked whenever middleware throws
|
|
58
77
|
* (rejects). If you set your own error handler via `bot.catch`, all that
|
|
@@ -97,6 +116,15 @@ class Bot extends composer_js_1.Composer {
|
|
|
97
116
|
}
|
|
98
117
|
return this.me;
|
|
99
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* @inheritdoc
|
|
121
|
+
*/
|
|
122
|
+
on(filter, ...middleware) {
|
|
123
|
+
for (const [u] of (0, filter_js_1.parse)(filter).flatMap(filter_js_1.preprocess)) {
|
|
124
|
+
this.observedUpdateTypes.add(u);
|
|
125
|
+
}
|
|
126
|
+
return super.on(filter, ...middleware);
|
|
127
|
+
}
|
|
100
128
|
/**
|
|
101
129
|
* Checks if the bot has been initialized. A bot is initialized if the bot
|
|
102
130
|
* information is set. The bot information can either be set automatically
|
|
@@ -256,20 +284,10 @@ a known bot info object.");
|
|
|
256
284
|
// Bot was stopped during `onStart`
|
|
257
285
|
if (!this.pollingRunning)
|
|
258
286
|
return;
|
|
287
|
+
// Prevent common misuse that leads to missing updates
|
|
288
|
+
validateAllowedUpdates(this.observedUpdateTypes, options === null || options === void 0 ? void 0 : options.allowed_updates);
|
|
259
289
|
// Prevent common misuse that causes memory leak
|
|
260
|
-
this.use =
|
|
261
|
-
throw new Error(`It looks like you are registering more listeners \
|
|
262
|
-
on your bot from within other listeners! This means that every time your bot \
|
|
263
|
-
handles a message like this one, new listeners will be added. This list grows until \
|
|
264
|
-
your machine crashes, so grammY throws this error to tell you that you should \
|
|
265
|
-
probably do things a bit differently. If you're unsure how to resolve this problem, \
|
|
266
|
-
you can ask in the group chat: https://telegram.me/grammyjs
|
|
267
|
-
|
|
268
|
-
On the other hand, if you actually know what you're doing and you do need to install \
|
|
269
|
-
further middleware while your bot is running, consider installing a composer \
|
|
270
|
-
instance on your bot, and in turn augment the composer after the fact. This way, \
|
|
271
|
-
you can circumvent this protection against memory leaks.`);
|
|
272
|
-
};
|
|
290
|
+
this.use = noUseFunction;
|
|
273
291
|
// Start polling
|
|
274
292
|
debug("Starting simple long polling");
|
|
275
293
|
await this.loop(options);
|
|
@@ -327,10 +345,10 @@ you can circumvent this protection against memory leaks.`);
|
|
|
327
345
|
* the bot is stopped.
|
|
328
346
|
*/
|
|
329
347
|
async loop(options) {
|
|
330
|
-
var _a;
|
|
348
|
+
var _a, _b;
|
|
331
349
|
const limit = options === null || options === void 0 ? void 0 : options.limit;
|
|
332
350
|
const timeout = (_a = options === null || options === void 0 ? void 0 : options.timeout) !== null && _a !== void 0 ? _a : 30; // seconds
|
|
333
|
-
let allowed_updates = options === null || options === void 0 ? void 0 : options.allowed_updates;
|
|
351
|
+
let allowed_updates = (_b = options === null || options === void 0 ? void 0 : options.allowed_updates) !== null && _b !== void 0 ? _b : []; // reset to default if unspecified
|
|
334
352
|
while (this.pollingRunning) {
|
|
335
353
|
// fetch updates
|
|
336
354
|
const updates = await this.fetchUpdates({ limit, timeout, allowed_updates });
|
|
@@ -503,4 +521,30 @@ async function sleep(seconds, signal) {
|
|
|
503
521
|
signal === null || signal === void 0 ? void 0 : signal.removeEventListener("abort", abort);
|
|
504
522
|
}
|
|
505
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* Takes a set of observed update types and a list of allowed updates and logs a
|
|
526
|
+
* warning in debug mode if some update types were observed that have not been
|
|
527
|
+
* allowed.
|
|
528
|
+
*/
|
|
529
|
+
function validateAllowedUpdates(updates, allowed = exports.DEFAULT_UPDATE_TYPES) {
|
|
530
|
+
const impossible = Array.from(updates).filter((u) => !allowed.includes(u));
|
|
531
|
+
if (impossible.length > 0) {
|
|
532
|
+
debugWarn(`You registered listeners for the following update types, \
|
|
533
|
+
but you did not specify them in \`allowed_updates\` \
|
|
534
|
+
so they may not be received: ${impossible.map((u) => `'${u}'`).join(", ")}`);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
function noUseFunction() {
|
|
538
|
+
throw new Error(`It looks like you are registering more listeners \
|
|
539
|
+
on your bot from within other listeners! This means that every time your bot \
|
|
540
|
+
handles a message like this one, new listeners will be added. This list grows until \
|
|
541
|
+
your machine crashes, so grammY throws this error to tell you that you should \
|
|
542
|
+
probably do things a bit differently. If you're unsure how to resolve this problem, \
|
|
543
|
+
you can ask in the group chat: https://telegram.me/grammyjs
|
|
544
|
+
|
|
545
|
+
On the other hand, if you actually know what you're doing and you do need to install \
|
|
546
|
+
further middleware while your bot is running, consider installing a composer \
|
|
547
|
+
instance on your bot, and in turn augment the composer after the fact. This way, \
|
|
548
|
+
you can circumvent this protection against memory leaks.`);
|
|
549
|
+
}
|
|
506
550
|
const shim_node_js_1 = require("./shim.node.js");
|
package/out/composer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CallbackQueryContext, type ChatTypeContext, type CommandContext, Context, type GameQueryContext, type HearsContext, type InlineQueryContext, type MaybeArray, type StringWithSuggestions } from "./context.js";
|
|
1
|
+
import { type CallbackQueryContext, type ChatTypeContext, type ChosenInlineResultContext, type CommandContext, Context, type GameQueryContext, type HearsContext, type InlineQueryContext, type MaybeArray, type StringWithSuggestions } from "./context.js";
|
|
2
2
|
import { type Filter, type FilterQuery } from "./filter.js";
|
|
3
3
|
import { type Chat } from "./types.js";
|
|
4
4
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -226,11 +226,11 @@ export declare class Composer<C extends Context> implements MiddlewareObj<C> {
|
|
|
226
226
|
* via `ctx.match`.
|
|
227
227
|
*
|
|
228
228
|
* > **Did you know?** You can use deep linking
|
|
229
|
-
* > (https://core.telegram.org/bots/features#deep-linking) to let users
|
|
230
|
-
* > bot with a custom payload. As an example, send someone the
|
|
231
|
-
* > https://t.me/name-of-your-bot?start=custom-payload and register a
|
|
232
|
-
* > command handler on your bot with grammY. As soon as the user
|
|
233
|
-
* > your bot, you will receive `custom-payload` in the `ctx.match`
|
|
229
|
+
* > (https://core.telegram.org/bots/features#deep-linking) to let users
|
|
230
|
+
* > start your bot with a custom payload. As an example, send someone the
|
|
231
|
+
* > link https://t.me/name-of-your-bot?start=custom-payload and register a
|
|
232
|
+
* > start command handler on your bot with grammY. As soon as the user
|
|
233
|
+
* > starts your bot, you will receive `custom-payload` in the `ctx.match`
|
|
234
234
|
* > property!
|
|
235
235
|
* > ```ts
|
|
236
236
|
* > bot.command('start', ctx => {
|
|
@@ -261,8 +261,8 @@ export declare class Composer<C extends Context> implements MiddlewareObj<C> {
|
|
|
261
261
|
* // etc
|
|
262
262
|
* ```
|
|
263
263
|
*
|
|
264
|
-
* If you need more freedom matching your commands, check out the
|
|
265
|
-
*
|
|
264
|
+
* If you need more freedom matching your commands, check out the `commands`
|
|
265
|
+
* plugin.
|
|
266
266
|
*
|
|
267
267
|
* @param command The command to look for
|
|
268
268
|
* @param middleware The middleware to register
|
|
@@ -383,6 +383,24 @@ export declare class Composer<C extends Context> implements MiddlewareObj<C> {
|
|
|
383
383
|
* @param middleware The middleware to register
|
|
384
384
|
*/
|
|
385
385
|
inlineQuery(trigger: MaybeArray<string | RegExp>, ...middleware: Array<InlineQueryMiddleware<C>>): Composer<InlineQueryContext<C>>;
|
|
386
|
+
/**
|
|
387
|
+
* Registers middleware for the ChosenInlineResult by the given id or ids.
|
|
388
|
+
* ChosenInlineResult represents a result of an inline query that was
|
|
389
|
+
* chosen by the user and sent to their chat partner. Check out
|
|
390
|
+
* https://core.telegram.org/bots/api#choseninlineresult to read more
|
|
391
|
+
* about chosen inline results.
|
|
392
|
+
*
|
|
393
|
+
* ```ts
|
|
394
|
+
* bot.chosenInlineResult('id', async ctx => {
|
|
395
|
+
* const id = ctx.result_id;
|
|
396
|
+
* // Your code
|
|
397
|
+
* })
|
|
398
|
+
* ```
|
|
399
|
+
*
|
|
400
|
+
* @param resultId An id or array of ids
|
|
401
|
+
* @param middleware The middleware to register
|
|
402
|
+
*/
|
|
403
|
+
chosenInlineResult(resultId: MaybeArray<string | RegExp>, ...middleware: Array<ChosenInlineResultMiddleware<C>>): Composer<ChosenInlineResultContext<C>>;
|
|
386
404
|
/**
|
|
387
405
|
* > This is an advanced method of grammY.
|
|
388
406
|
*
|
|
@@ -393,8 +411,8 @@ export declare class Composer<C extends Context> implements MiddlewareObj<C> {
|
|
|
393
411
|
* skipped and the next middleware will be executed.
|
|
394
412
|
*
|
|
395
413
|
* This method has two signatures. The first one is straightforward, it is
|
|
396
|
-
* the one described above. Note that the predicate may be asynchronous,
|
|
397
|
-
* it can return a Promise of a boolean.
|
|
414
|
+
* the one described above. Note that the predicate may be asynchronous,
|
|
415
|
+
* i.e. it can return a Promise of a boolean.
|
|
398
416
|
*
|
|
399
417
|
* Alternatively, you can pass a function that has a type predicate as
|
|
400
418
|
* return type. This will allow you to narrow down the context object. The
|
|
@@ -629,6 +647,15 @@ export type GameQueryMiddleware<C extends Context> = Middleware<GameQueryContext
|
|
|
629
647
|
* modular code where handlers are defined in separate files.
|
|
630
648
|
*/
|
|
631
649
|
export type InlineQueryMiddleware<C extends Context> = Middleware<InlineQueryContext<C>>;
|
|
650
|
+
/**
|
|
651
|
+
* Type of the middleware that can be passed to `bot.chosenInlineResult`.
|
|
652
|
+
*
|
|
653
|
+
* This helper type can be used to annotate middleware functions that are
|
|
654
|
+
* defined in one place, so that they have the correct type when passed to
|
|
655
|
+
* `bot.chosenInlineResult` in a different place. For instance, this allows for more
|
|
656
|
+
* modular code where handlers are defined in separate files.
|
|
657
|
+
*/
|
|
658
|
+
export type ChosenInlineResultMiddleware<C extends Context> = Middleware<ChosenInlineResultContext<C>>;
|
|
632
659
|
/**
|
|
633
660
|
* Type of the middleware that can be passed to `bot.chatType`.
|
|
634
661
|
*
|
package/out/composer.js
CHANGED
|
@@ -231,11 +231,11 @@ class Composer {
|
|
|
231
231
|
* via `ctx.match`.
|
|
232
232
|
*
|
|
233
233
|
* > **Did you know?** You can use deep linking
|
|
234
|
-
* > (https://core.telegram.org/bots/features#deep-linking) to let users
|
|
235
|
-
* > bot with a custom payload. As an example, send someone the
|
|
236
|
-
* > https://t.me/name-of-your-bot?start=custom-payload and register a
|
|
237
|
-
* > command handler on your bot with grammY. As soon as the user
|
|
238
|
-
* > your bot, you will receive `custom-payload` in the `ctx.match`
|
|
234
|
+
* > (https://core.telegram.org/bots/features#deep-linking) to let users
|
|
235
|
+
* > start your bot with a custom payload. As an example, send someone the
|
|
236
|
+
* > link https://t.me/name-of-your-bot?start=custom-payload and register a
|
|
237
|
+
* > start command handler on your bot with grammY. As soon as the user
|
|
238
|
+
* > starts your bot, you will receive `custom-payload` in the `ctx.match`
|
|
239
239
|
* > property!
|
|
240
240
|
* > ```ts
|
|
241
241
|
* > bot.command('start', ctx => {
|
|
@@ -266,8 +266,8 @@ class Composer {
|
|
|
266
266
|
* // etc
|
|
267
267
|
* ```
|
|
268
268
|
*
|
|
269
|
-
* If you need more freedom matching your commands, check out the
|
|
270
|
-
*
|
|
269
|
+
* If you need more freedom matching your commands, check out the `commands`
|
|
270
|
+
* plugin.
|
|
271
271
|
*
|
|
272
272
|
* @param command The command to look for
|
|
273
273
|
* @param middleware The middleware to register
|
|
@@ -398,6 +398,26 @@ class Composer {
|
|
|
398
398
|
inlineQuery(trigger, ...middleware) {
|
|
399
399
|
return this.filter(context_js_1.Context.has.inlineQuery(trigger), ...middleware);
|
|
400
400
|
}
|
|
401
|
+
/**
|
|
402
|
+
* Registers middleware for the ChosenInlineResult by the given id or ids.
|
|
403
|
+
* ChosenInlineResult represents a result of an inline query that was
|
|
404
|
+
* chosen by the user and sent to their chat partner. Check out
|
|
405
|
+
* https://core.telegram.org/bots/api#choseninlineresult to read more
|
|
406
|
+
* about chosen inline results.
|
|
407
|
+
*
|
|
408
|
+
* ```ts
|
|
409
|
+
* bot.chosenInlineResult('id', async ctx => {
|
|
410
|
+
* const id = ctx.result_id;
|
|
411
|
+
* // Your code
|
|
412
|
+
* })
|
|
413
|
+
* ```
|
|
414
|
+
*
|
|
415
|
+
* @param resultId An id or array of ids
|
|
416
|
+
* @param middleware The middleware to register
|
|
417
|
+
*/
|
|
418
|
+
chosenInlineResult(resultId, ...middleware) {
|
|
419
|
+
return this.filter(context_js_1.Context.has.chosenInlineResult(resultId), ...middleware);
|
|
420
|
+
}
|
|
401
421
|
filter(predicate, ...middleware) {
|
|
402
422
|
const composer = new Composer(...middleware);
|
|
403
423
|
this.branch(predicate, composer, pass);
|
package/out/context.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type Methods, type RawApi } from "./core/client.js";
|
|
|
3
3
|
import { type Filter, type FilterCore, type FilterQuery } from "./filter.js";
|
|
4
4
|
import { type Chat, type ChatPermissions, type InlineQueryResult, type InputFile, type InputMedia, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo, type LabeledPrice, type Message, type MessageEntity, type PassportElementError, type Update, type User, type UserFromGetMe } from "./types.js";
|
|
5
5
|
export type MaybeArray<T> = T | T[];
|
|
6
|
-
export type StringWithSuggestions<S extends string> = (string &
|
|
6
|
+
export type StringWithSuggestions<S extends string> = (string & Record<never, never>) | S;
|
|
7
7
|
type Other<M extends Methods<RawApi>, X extends string = never> = OtherApi<RawApi, M, X>;
|
|
8
8
|
type SnakeToCamelCase<S extends string> = S extends `${infer L}_${infer R}` ? `${L}${Capitalize<SnakeToCamelCase<R>>}` : S;
|
|
9
9
|
export type AliasProps<U> = {
|
|
@@ -66,6 +66,14 @@ interface StaticHas {
|
|
|
66
66
|
* @param trigger The string or regex to match
|
|
67
67
|
*/
|
|
68
68
|
inlineQuery(trigger: MaybeArray<string | RegExp>): <C extends Context>(ctx: C) => ctx is InlineQueryContext<C>;
|
|
69
|
+
/**
|
|
70
|
+
* Generates a predicate function that can test context objects for
|
|
71
|
+
* containing the chosen inline result, or for the chosen inline result to
|
|
72
|
+
* match the given regular expression.
|
|
73
|
+
*
|
|
74
|
+
* @param trigger The string or regex to match
|
|
75
|
+
*/
|
|
76
|
+
chosenInlineResult(trigger: MaybeArray<string | RegExp>): <C extends Context>(ctx: C) => ctx is ChosenInlineResultContext<C>;
|
|
69
77
|
}
|
|
70
78
|
/**
|
|
71
79
|
* When your bot receives a message, Telegram sends an update object to your
|
|
@@ -292,6 +300,14 @@ export declare class Context implements RenamedUpdate {
|
|
|
292
300
|
* @param trigger The string or regex to match
|
|
293
301
|
*/
|
|
294
302
|
hasInlineQuery(trigger: MaybeArray<string | RegExp>): this is InlineQueryContextCore;
|
|
303
|
+
/**
|
|
304
|
+
* Returns `true` if this context object contains the chosen inline result, or
|
|
305
|
+
* if the contained chosen inline result matches the given regular expression. It
|
|
306
|
+
* returns `false` otherwise. This uses the same logic as `bot.chosenInlineResult`.
|
|
307
|
+
*
|
|
308
|
+
* @param trigger The string or regex to match
|
|
309
|
+
*/
|
|
310
|
+
hasChosenInlineResult(trigger: MaybeArray<string | RegExp>): this is ChosenInlineResultContextCore;
|
|
295
311
|
/**
|
|
296
312
|
* Context-aware alias for `api.sendMessage`. Use this method to send text messages. On success, the sent Message is returned.
|
|
297
313
|
*
|
|
@@ -1181,6 +1197,18 @@ type InlineQueryContextCore = FilterCore<"inline_query">;
|
|
|
1181
1197
|
* in separate files and still have the correct types.
|
|
1182
1198
|
*/
|
|
1183
1199
|
export type InlineQueryContext<C extends Context> = Filter<C, "inline_query">;
|
|
1200
|
+
type ChosenInlineResultContextCore = FilterCore<"chosen_inline_result">;
|
|
1201
|
+
/**
|
|
1202
|
+
* Type of the context object that is available inside the handlers for
|
|
1203
|
+
* `bot.chosenInlineResult`.
|
|
1204
|
+
*
|
|
1205
|
+
* This helper type can be used to narrow down context objects the same way how
|
|
1206
|
+
* annotate `bot.chosenInlineResult` does it. This allows you to context objects in
|
|
1207
|
+
* middleware that is not directly passed to `bot.chosenInlineResult`, hence not
|
|
1208
|
+
* inferring the correct type automatically. That way, handlers can be defined
|
|
1209
|
+
* in separate files and still have the correct types.
|
|
1210
|
+
*/
|
|
1211
|
+
export type ChosenInlineResultContext<C extends Context> = Filter<C, "chosen_inline_result">;
|
|
1184
1212
|
type ChatTypeContextCore<T extends Chat["type"]> = Record<"update", ChatTypeUpdate<T>> & ChatType<T> & ChatFrom<T> & ChatTypeRecord<"msg", T> & AliasProps<ChatTypeUpdate<T>>;
|
|
1185
1213
|
/**
|
|
1186
1214
|
* Type of the context object that is available inside the handlers for
|
package/out/context.js
CHANGED
|
@@ -81,6 +81,12 @@ const checker = {
|
|
|
81
81
|
const trg = triggerFn(trigger);
|
|
82
82
|
return (ctx) => hasInlineQuery(ctx) && match(ctx, ctx.inlineQuery.query, trg);
|
|
83
83
|
},
|
|
84
|
+
chosenInlineResult(trigger) {
|
|
85
|
+
const hasChosenInlineResult = checker.filterQuery("chosen_inline_result");
|
|
86
|
+
const trg = triggerFn(trigger);
|
|
87
|
+
return (ctx) => hasChosenInlineResult(ctx) &&
|
|
88
|
+
match(ctx, ctx.chosenInlineResult.result_id, trg);
|
|
89
|
+
},
|
|
84
90
|
};
|
|
85
91
|
// === Context class
|
|
86
92
|
/**
|
|
@@ -332,6 +338,16 @@ class Context {
|
|
|
332
338
|
hasInlineQuery(trigger) {
|
|
333
339
|
return Context.has.inlineQuery(trigger)(this);
|
|
334
340
|
}
|
|
341
|
+
/**
|
|
342
|
+
* Returns `true` if this context object contains the chosen inline result, or
|
|
343
|
+
* if the contained chosen inline result matches the given regular expression. It
|
|
344
|
+
* returns `false` otherwise. This uses the same logic as `bot.chosenInlineResult`.
|
|
345
|
+
*
|
|
346
|
+
* @param trigger The string or regex to match
|
|
347
|
+
*/
|
|
348
|
+
hasChosenInlineResult(trigger) {
|
|
349
|
+
return Context.has.chosenInlineResult(trigger)(this);
|
|
350
|
+
}
|
|
335
351
|
// API
|
|
336
352
|
/**
|
|
337
353
|
* Context-aware alias for `api.sendMessage`. Use this method to send text messages. On success, the sent Message is returned.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contains lists of constants which are useful when working with the Bot API.
|
|
3
|
+
*/
|
|
4
|
+
export declare const API_CONSTANTS: Readonly<{
|
|
5
|
+
/**
|
|
6
|
+
* List of all available update types. Useful if you want to receive all
|
|
7
|
+
* updates from the Bot API, rather than just those that are delivered by
|
|
8
|
+
* default.
|
|
9
|
+
*
|
|
10
|
+
* The main use case for this is when you want to receive `chat_member`
|
|
11
|
+
* updates, as they need to be enabled first. Use it like so:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* // Built-in polling:
|
|
15
|
+
* bot.start({ allowed_updates: ALL_UPDATE_TYPES });
|
|
16
|
+
* // grammY runner:
|
|
17
|
+
* run(bot, { runner: { fetch: { allowed_updates: ALL_UPDATE_TYPES } } });
|
|
18
|
+
* // Webhooks:
|
|
19
|
+
* await bot.api.setWebhook(url, { allowed_updates: ALL_UPDATE_TYPES });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
readonly ALL_UPDATE_TYPES: readonly ["message", "edited_message", "channel_post", "edited_channel_post", "inline_query", "chosen_inline_result", "callback_query", "shipping_query", "pre_checkout_query", "poll", "poll_answer", "my_chat_member", "chat_join_request", "chat_member"];
|
|
23
|
+
/**
|
|
24
|
+
* An object containing all available chat permissions. Useful if you want
|
|
25
|
+
* to lift restrictions from a user, as this action requires you to pass
|
|
26
|
+
* `true` for all permissions. Use it like so:
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* // On `Bot`:
|
|
30
|
+
* await bot.api.restrictChatMember(chat_id, user_id, ALL_CHAT_PERMISSIONS);
|
|
31
|
+
* // On `Api`:
|
|
32
|
+
* await ctx.api.restrictChatMember(chat_id, user_id, ALL_CHAT_PERMISSIONS);
|
|
33
|
+
* // On `Context`:
|
|
34
|
+
* await ctx.restrictChatMember(user_id, ALL_CHAT_PERMISSIONS);
|
|
35
|
+
* await ctx.restrictAuthor(ALL_CHAT_PERMISSIONS);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
readonly ALL_CHAT_PERMISSIONS: {
|
|
39
|
+
readonly can_send_messages: true;
|
|
40
|
+
readonly can_send_audios: true;
|
|
41
|
+
readonly can_send_documents: true;
|
|
42
|
+
readonly can_send_photos: true;
|
|
43
|
+
readonly can_send_videos: true;
|
|
44
|
+
readonly can_send_video_notes: true;
|
|
45
|
+
readonly can_send_voice_notes: true;
|
|
46
|
+
readonly can_send_polls: true;
|
|
47
|
+
readonly can_send_other_messages: true;
|
|
48
|
+
readonly can_add_web_page_previews: true;
|
|
49
|
+
readonly can_change_info: true;
|
|
50
|
+
readonly can_invite_users: true;
|
|
51
|
+
readonly can_pin_messages: true;
|
|
52
|
+
readonly can_manage_topics: true;
|
|
53
|
+
};
|
|
54
|
+
}>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.API_CONSTANTS = void 0;
|
|
4
|
+
const bot_js_1 = require("../bot.js");
|
|
5
|
+
const ALL_UPDATE_TYPES = [...bot_js_1.DEFAULT_UPDATE_TYPES, "chat_member"];
|
|
6
|
+
const ALL_CHAT_PERMISSIONS = {
|
|
7
|
+
can_send_messages: true,
|
|
8
|
+
can_send_audios: true,
|
|
9
|
+
can_send_documents: true,
|
|
10
|
+
can_send_photos: true,
|
|
11
|
+
can_send_videos: true,
|
|
12
|
+
can_send_video_notes: true,
|
|
13
|
+
can_send_voice_notes: true,
|
|
14
|
+
can_send_polls: true,
|
|
15
|
+
can_send_other_messages: true,
|
|
16
|
+
can_add_web_page_previews: true,
|
|
17
|
+
can_change_info: true,
|
|
18
|
+
can_invite_users: true,
|
|
19
|
+
can_pin_messages: true,
|
|
20
|
+
can_manage_topics: true,
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Contains lists of constants which are useful when working with the Bot API.
|
|
24
|
+
*/
|
|
25
|
+
exports.API_CONSTANTS = Object.freeze({
|
|
26
|
+
/**
|
|
27
|
+
* List of all available update types. Useful if you want to receive all
|
|
28
|
+
* updates from the Bot API, rather than just those that are delivered by
|
|
29
|
+
* default.
|
|
30
|
+
*
|
|
31
|
+
* The main use case for this is when you want to receive `chat_member`
|
|
32
|
+
* updates, as they need to be enabled first. Use it like so:
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* // Built-in polling:
|
|
36
|
+
* bot.start({ allowed_updates: ALL_UPDATE_TYPES });
|
|
37
|
+
* // grammY runner:
|
|
38
|
+
* run(bot, { runner: { fetch: { allowed_updates: ALL_UPDATE_TYPES } } });
|
|
39
|
+
* // Webhooks:
|
|
40
|
+
* await bot.api.setWebhook(url, { allowed_updates: ALL_UPDATE_TYPES });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
ALL_UPDATE_TYPES,
|
|
44
|
+
/**
|
|
45
|
+
* An object containing all available chat permissions. Useful if you want
|
|
46
|
+
* to lift restrictions from a user, as this action requires you to pass
|
|
47
|
+
* `true` for all permissions. Use it like so:
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* // On `Bot`:
|
|
51
|
+
* await bot.api.restrictChatMember(chat_id, user_id, ALL_CHAT_PERMISSIONS);
|
|
52
|
+
* // On `Api`:
|
|
53
|
+
* await ctx.api.restrictChatMember(chat_id, user_id, ALL_CHAT_PERMISSIONS);
|
|
54
|
+
* // On `Context`:
|
|
55
|
+
* await ctx.restrictChatMember(user_id, ALL_CHAT_PERMISSIONS);
|
|
56
|
+
* await ctx.restrictAuthor(ALL_CHAT_PERMISSIONS);
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
ALL_CHAT_PERMISSIONS,
|
|
60
|
+
});
|