grammy 1.3.4 → 1.4.2
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 +28 -11
- package/out/bot.js +29 -3
- package/out/composer.d.ts +1 -1
- package/out/composer.js +4 -2
- package/out/context.d.ts +44 -24
- package/out/context.js +50 -24
- package/out/convenience/webhook.js +8 -2
- package/out/core/api.d.ts +40 -20
- package/out/core/api.js +44 -20
- package/out/core/client.js +44 -20
- package/out/core/payload.d.ts +1 -1
- package/out/core/payload.js +13 -2
- package/out/filter.d.ts +25 -0
- package/out/filter.js +4 -0
- package/out/platform.node.d.ts +13 -2
- package/out/platform.node.js +35 -4
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# <h1 align="center"> [](https://grammy.dev)</h1>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**<h1 align="right">The Telegram Bot Framework.</h1>**
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
_<
|
|
7
|
+
_<h2 align="center"> [:mag: Documentation](https://grammy.dev) | [:page_with_curl: API Reference](https://doc.deno.land/https/deno.land/x/grammy/mod.ts) | [:busts_in_silhouette: Group Chat](https://telegram.me/grammyjs) | [:new: News](https://telegram.me/grammyjs_news)</h2>_
|
|
8
8
|
|
|
9
9
|
<div align="center">
|
|
10
10
|
|
|
11
11
|
<!-- deno-fmt-ignore-start -->
|
|
12
12
|
|
|
13
|
-
[](https://core.telegram.org/bots/api)
|
|
14
14
|
[](https://www.npmjs.org/package/grammy) <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
15
|
-
[](#contributors-)
|
|
16
16
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
17
17
|
|
|
18
18
|
<!-- deno-fmt-ignore-end -->
|
|
@@ -100,9 +100,11 @@ Here are some more resources to support you:
|
|
|
100
100
|
|
|
101
101
|
## Deno Support
|
|
102
102
|
|
|
103
|
-
All grammY packages published by [@grammyjs](https://github.com/grammyjs) run natively in Deno. We
|
|
103
|
+
All grammY packages published by [@grammyjs](https://github.com/grammyjs) run natively in Deno. We are compiling every codebase to still run on Node.
|
|
104
104
|
|
|
105
|
-
However, given that most bot developers are still using Node, all documentation is written Node-first. We may migrate it if Deno overtakes Node. If you are already on Deno today, we expect you to know what you're doing. You mainly have to adjust the imports to URL imports, and
|
|
105
|
+
However, given that most bot developers are still using Node, all documentation is written Node-first. We may migrate it if Deno overtakes Node. If you are already on Deno today, we expect you to know what you're doing. You mainly have to adjust the imports to URL imports, and import from [`https://deno.land/x/grammy/mod.ts`](https://deno.land/x/grammy).
|
|
106
|
+
|
|
107
|
+
## [Contribution Guide »](./CONTRIBUTING.md)
|
|
106
108
|
|
|
107
109
|
## Contributors ✨
|
|
108
110
|
|
|
@@ -122,7 +124,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
122
124
|
<td align="center"><a href="https://mkr.pw"><img src="https://avatars.githubusercontent.com/u/19621208?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Muthu Kumar</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AMKRhere" title="Reviewed Pull Requests">👀</a></td>
|
|
123
125
|
</tr>
|
|
124
126
|
<tr>
|
|
125
|
-
<td align="center"><a href="https://edjopato.de/"><img src="https://avatars.githubusercontent.com/u/7953011?v=4?s=100" width="100px;" alt=""/><br /><sub><b>EdJoPaTo</b></sub></a><br /><a href="#plugin-EdJoPaTo" title="Plugin/utility libraries">🔌</a> <a href="https://github.com/grammyjs/grammY/commits?author=EdJoPaTo" title="Documentation">📖</a> <a href="#ideas-EdJoPaTo" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AEdJoPaTo" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3AEdJoPaTo" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=EdJoPaTo" title="Code">💻</a></td>
|
|
127
|
+
<td align="center"><a href="https://edjopato.de/"><img src="https://avatars.githubusercontent.com/u/7953011?v=4?s=100" width="100px;" alt=""/><br /><sub><b>EdJoPaTo</b></sub></a><br /><a href="#plugin-EdJoPaTo" title="Plugin/utility libraries">🔌</a> <a href="https://github.com/grammyjs/grammY/commits?author=EdJoPaTo" title="Documentation">📖</a> <a href="#ideas-EdJoPaTo" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AEdJoPaTo" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3AEdJoPaTo" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=EdJoPaTo" title="Code">💻</a> <a href="#question-EdJoPaTo" title="Answering Questions">💬</a></td>
|
|
126
128
|
<td align="center"><a href="https://github.com/Amir-Zouerami"><img src="https://avatars.githubusercontent.com/u/53701884?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Amir Zouerami</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Amir-Zouerami" title="Documentation">📖</a> <a href="#plugin-Amir-Zouerami" title="Plugin/utility libraries">🔌</a></td>
|
|
127
129
|
<td align="center"><a href="https://github.com/rojserbest"><img src="https://avatars.githubusercontent.com/u/49933115?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Roj</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=rojserbest" title="Documentation">📖</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Arojserbest" title="Reviewed Pull Requests">👀</a> <a href="#infra-rojserbest" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
|
128
130
|
<td align="center"><a href="https://github.com/jokasimr"><img src="https://avatars.githubusercontent.com/u/20954731?v=4?s=100" width="100px;" alt=""/><br /><sub><b>jokasimr</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Ajokasimr" title="Bug reports">🐛</a></td>
|
|
@@ -137,15 +139,32 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
137
139
|
<td align="center"><a href="https://github.com/Asaku01"><img src="https://avatars.githubusercontent.com/u/29716396?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Asaku01</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Asaku01" title="Documentation">📖</a></td>
|
|
138
140
|
<td align="center"><a href="https://github.com/ppsimn"><img src="https://avatars.githubusercontent.com/u/88509883?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ppsimn</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Appsimn" title="Bug reports">🐛</a></td>
|
|
139
141
|
<td align="center"><a href="https://satont.js.org/"><img src="https://avatars.githubusercontent.com/u/42675886?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Satont</b></sub></a><br /><a href="#plugin-Satont" title="Plugin/utility libraries">🔌</a></td>
|
|
140
|
-
<td align="center"><a href="https://github.com/deptyped"><img src="https://avatars.githubusercontent.com/u/26162440?v=4?s=100" width="100px;" alt=""/><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></td>
|
|
142
|
+
<td align="center"><a href="https://github.com/deptyped"><img src="https://avatars.githubusercontent.com/u/26162440?v=4?s=100" width="100px;" alt=""/><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="#question-deptyped" title="Answering Questions">💬</a></td>
|
|
141
143
|
</tr>
|
|
142
144
|
<tr>
|
|
143
|
-
<td align="center"><a href="https://github.com/dzek69"><img src="https://avatars.githubusercontent.com/u/4936805?v=4?s=100" width="100px;" alt=""/><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></td>
|
|
145
|
+
<td align="center"><a href="https://github.com/dzek69"><img src="https://avatars.githubusercontent.com/u/4936805?v=4?s=100" width="100px;" alt=""/><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></td>
|
|
144
146
|
<td align="center"><a href="https://blog.outv.im"><img src="https://avatars.githubusercontent.com/u/19144373?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Outvi V</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=outloudvi" title="Code">💻</a></td>
|
|
145
147
|
<td align="center"><a href="https://bandism.net/"><img src="https://avatars.githubusercontent.com/u/22633385?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ikko Ashimine</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=eltociear" title="Documentation">📖</a></td>
|
|
146
148
|
<td align="center"><a href="https://github.com/amberlionk"><img src="https://avatars.githubusercontent.com/u/29119723?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yevhen Denesiuk</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Aamberlionk" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3Aamberlionk" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=amberlionk" title="Code">💻</a></td>
|
|
147
149
|
<td align="center"><a href="https://github.com/prazedotid"><img src="https://avatars.githubusercontent.com/u/19567624?v=4?s=100" width="100px;" alt=""/><br /><sub><b>prastian</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aprazedotid" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=prazedotid" title="Code">💻</a></td>
|
|
148
150
|
<td align="center"><a href="https://sayem.eu.org/"><img src="https://avatars.githubusercontent.com/u/14138401?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sayem Chowdhury</b></sub></a><br /><a href="#ideas-sayem314" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
151
|
+
<td align="center"><a href="https://github.com/kospra"><img src="https://avatars.githubusercontent.com/u/42740406?v=4?s=100" width="100px;" alt=""/><br /><sub><b>kospra</b></sub></a><br /><a href="#ideas-kospra" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=kospra" title="Code">💻</a></td>
|
|
152
|
+
</tr>
|
|
153
|
+
<tr>
|
|
154
|
+
<td align="center"><a href="https://github.com/chimit"><img src="https://avatars.githubusercontent.com/u/839349?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chimit</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=chimit" title="Documentation">📖</a></td>
|
|
155
|
+
<td align="center"><a href="https://github.com/CalsiBotDev"><img src="https://avatars.githubusercontent.com/u/55633371?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Calsi</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=CalsiBotDev" title="Documentation">📖</a></td>
|
|
156
|
+
<td align="center"><a href="https://zohren.xyz"><img src="https://avatars.githubusercontent.com/u/15788906?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jonas Zohren</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Ajfowl" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=jfowl" title="Code">💻</a></td>
|
|
157
|
+
<td align="center"><a href="https://zhemu.buzz/"><img src="https://avatars.githubusercontent.com/u/56839018?v=4?s=100" width="100px;" alt=""/><br /><sub><b>linbuxiao</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=linbuxiao" title="Documentation">📖</a></td>
|
|
158
|
+
<td align="center"><a href="https://github.com/JiquanWang99"><img src="https://avatars.githubusercontent.com/u/63894579?v=4?s=100" width="100px;" alt=""/><br /><sub><b>JiquanWang99</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=JiquanWang99" title="Documentation">📖</a></td>
|
|
159
|
+
<td align="center"><a href="http://bor691.ir/"><img src="https://avatars.githubusercontent.com/u/4184939?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Borhan Hafez</b></sub></a><br /><a href="#plugin-zumoshi" title="Plugin/utility libraries">🔌</a></td>
|
|
160
|
+
<td align="center"><a href="https://blog.limx.dev/"><img src="https://avatars.githubusercontent.com/u/6434137?v=4?s=100" width="100px;" alt=""/><br /><sub><b>WingLim</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=WingLim" title="Documentation">📖</a></td>
|
|
161
|
+
</tr>
|
|
162
|
+
<tr>
|
|
163
|
+
<td align="center"><a href="https://github.com/taotie111"><img src="https://avatars.githubusercontent.com/u/44166322?v=4?s=100" width="100px;" alt=""/><br /><sub><b>taotie111</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=taotie111" title="Documentation">📖</a></td>
|
|
164
|
+
<td align="center"><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=""/><br /><sub><b>Merlin</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=FatalMerlin" title="Documentation">📖</a></td>
|
|
165
|
+
<td align="center"><a href="https://darve.sh"><img src="https://avatars.githubusercontent.com/u/22394081?v=4?s=100" width="100px;" alt=""/><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></td>
|
|
166
|
+
<td align="center"><a href="http://telegram.me/dcdunkan"><img src="https://avatars.githubusercontent.com/u/70066170?v=4?s=100" width="100px;" alt=""/><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></td>
|
|
167
|
+
<td align="center"><a href="https://xuann.wang/"><img src="https://avatars.githubusercontent.com/u/44045911?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kid</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=kidonng" title="Documentation">📖</a></td>
|
|
149
168
|
</tr>
|
|
150
169
|
</table>
|
|
151
170
|
|
|
@@ -155,5 +174,3 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
155
174
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
156
175
|
|
|
157
176
|
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
158
|
-
|
|
159
|
-
## [Contribution Guide »](./CONTRIBUTING.md)
|
package/out/bot.js
CHANGED
|
@@ -248,14 +248,14 @@ a known bot info object.");
|
|
|
248
248
|
async start(options) {
|
|
249
249
|
var _a, _b;
|
|
250
250
|
// Perform setup
|
|
251
|
-
await this.init();
|
|
251
|
+
await withRetries(() => this.init());
|
|
252
252
|
if (this.pollingRunning) {
|
|
253
253
|
debug("Simple long polling already running!");
|
|
254
254
|
return;
|
|
255
255
|
}
|
|
256
|
-
await this.api.deleteWebhook({
|
|
256
|
+
await withRetries(() => this.api.deleteWebhook({
|
|
257
257
|
drop_pending_updates: options === null || options === void 0 ? void 0 : options.drop_pending_updates,
|
|
258
|
-
});
|
|
258
|
+
}));
|
|
259
259
|
// Prevent common misuse that causes memory leak
|
|
260
260
|
this.use = () => {
|
|
261
261
|
throw new Error(`It looks like you are registering more listeners \
|
|
@@ -390,4 +390,30 @@ you can circumvent this protection against memory leaks.`);
|
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
392
|
exports.Bot = Bot;
|
|
393
|
+
async function withRetries(task) {
|
|
394
|
+
let success = false;
|
|
395
|
+
while (!success) {
|
|
396
|
+
try {
|
|
397
|
+
await task();
|
|
398
|
+
success = true;
|
|
399
|
+
}
|
|
400
|
+
catch (error) {
|
|
401
|
+
debugErr(error);
|
|
402
|
+
if (error instanceof error_js_1.HttpError)
|
|
403
|
+
continue;
|
|
404
|
+
if (error instanceof error_js_1.GrammyError) {
|
|
405
|
+
if (error.error_code >= 500)
|
|
406
|
+
continue;
|
|
407
|
+
if (error.error_code === 429) {
|
|
408
|
+
const retryAfter = error.parameters.retry_after;
|
|
409
|
+
if (retryAfter !== undefined) {
|
|
410
|
+
await new Promise((resolve) => setTimeout(resolve, 1000 * retryAfter));
|
|
411
|
+
}
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
throw error;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
393
419
|
const shim_node_js_1 = require("./shim.node.js");
|
package/out/composer.d.ts
CHANGED
|
@@ -268,7 +268,7 @@ export declare class Composer<C extends Context> implements MiddlewareObj<C> {
|
|
|
268
268
|
* @param command The command to look for
|
|
269
269
|
* @param middleware The middleware to register
|
|
270
270
|
*/
|
|
271
|
-
command(command: MaybeArray<StringWithSuggestions<"start" | "help" | "settings">>, ...middleware: Array<Middleware<CommandContext<C>>>): Composer<CommandContext<C>>;
|
|
271
|
+
command<S extends string>(command: MaybeArray<StringWithSuggestions<S | "start" | "help" | "settings">>, ...middleware: Array<Middleware<CommandContext<C>>>): Composer<CommandContext<C>>;
|
|
272
272
|
/**
|
|
273
273
|
* Registers some middleware for callback queries, i.e. the updates that
|
|
274
274
|
* Telegram delivers to your bot when a user clicks an inline button (that
|
package/out/composer.js
CHANGED
|
@@ -554,7 +554,9 @@ class Composer {
|
|
|
554
554
|
return this.lazy(async (ctx) => {
|
|
555
555
|
var _a;
|
|
556
556
|
const route = await router(ctx);
|
|
557
|
-
return route === undefined
|
|
557
|
+
return (_a = (route === undefined || !routeHandlers[route]
|
|
558
|
+
? fallback
|
|
559
|
+
: routeHandlers[route])) !== null && _a !== void 0 ? _a : [];
|
|
558
560
|
});
|
|
559
561
|
}
|
|
560
562
|
/**
|
|
@@ -637,7 +639,7 @@ exports.Composer = Composer;
|
|
|
637
639
|
function triggerFn(trigger) {
|
|
638
640
|
return toArray(trigger).map((t) => typeof t === "string"
|
|
639
641
|
? (txt) => (txt === t ? t : null)
|
|
640
|
-
: (txt) =>
|
|
642
|
+
: (txt) => txt.match(t));
|
|
641
643
|
}
|
|
642
644
|
function match(ctx, content, triggers) {
|
|
643
645
|
for (const t of triggers) {
|
package/out/context.d.ts
CHANGED
|
@@ -103,6 +103,8 @@ export declare class Context implements RenamedUpdate {
|
|
|
103
103
|
get myChatMember(): import("@grammyjs/types/manage").ChatMemberUpdated | undefined;
|
|
104
104
|
/** Alias for `ctx.update.chat_member` */
|
|
105
105
|
get chatMember(): import("@grammyjs/types/manage").ChatMemberUpdated | undefined;
|
|
106
|
+
/** Alias for `ctx.update.chat_join_request` */
|
|
107
|
+
get chatJoinRequest(): import("@grammyjs/types/manage").ChatJoinRequest | undefined;
|
|
106
108
|
/**
|
|
107
109
|
* Get message object from whereever possible. Alias for `ctx.message ??
|
|
108
110
|
* ctx.editedMessage ?? ctx.callbackQuery?.message ?? ctx.channelPost ??
|
|
@@ -327,7 +329,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
327
329
|
*
|
|
328
330
|
* We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
|
|
329
331
|
*
|
|
330
|
-
* @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, find_location for location data, record_video_note or upload_video_note for video notes.
|
|
332
|
+
* @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.
|
|
331
333
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
332
334
|
*
|
|
333
335
|
* **Official reference:** https://core.telegram.org/bots/api#sendchataction
|
|
@@ -356,7 +358,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
356
358
|
/** @deprecated Use `banAuthor` instead. */
|
|
357
359
|
kickAuthor(...args: Parameters<Context["banAuthor"]>): Promise<true>;
|
|
358
360
|
/**
|
|
359
|
-
* Context-aware alias for `api.banChatMember`. Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate
|
|
361
|
+
* Context-aware alias for `api.banChatMember`. Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
360
362
|
*
|
|
361
363
|
* @param other Optional remaining parameters, confer the official reference below
|
|
362
364
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -367,7 +369,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
367
369
|
/** @deprecated Use `banChatMember` instead. */
|
|
368
370
|
kickChatMember(...args: Parameters<Context["banChatMember"]>): Promise<true>;
|
|
369
371
|
/**
|
|
370
|
-
* Context-aware alias for `api.banChatMember`. Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate
|
|
372
|
+
* Context-aware alias for `api.banChatMember`. Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
371
373
|
*
|
|
372
374
|
* @param user_id Unique identifier of the target user
|
|
373
375
|
* @param other Optional remaining parameters, confer the official reference below
|
|
@@ -387,7 +389,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
387
389
|
*/
|
|
388
390
|
unbanChatMember(user_id: number, other?: Other<"unbanChatMember", "user_id">, signal?: AbortSignal): Promise<true>;
|
|
389
391
|
/**
|
|
390
|
-
* Context-aware alias for `api.restrictChatMember`. Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate
|
|
392
|
+
* Context-aware alias for `api.restrictChatMember`. Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success.
|
|
391
393
|
*
|
|
392
394
|
* @param permissions An object for new user permissions
|
|
393
395
|
* @param other Optional remaining parameters, confer the official reference below
|
|
@@ -397,7 +399,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
397
399
|
*/
|
|
398
400
|
restrictAuthor(permissions: ChatPermissions, other?: Other<"restrictChatMember", "user_id" | "permissions">, signal?: AbortSignal): Promise<true>;
|
|
399
401
|
/**
|
|
400
|
-
* Context-aware alias for `api.restrictChatMember`. Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate
|
|
402
|
+
* Context-aware alias for `api.restrictChatMember`. Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success.
|
|
401
403
|
*
|
|
402
404
|
* @param user_id Unique identifier of the target user
|
|
403
405
|
* @param permissions An object for new user permissions
|
|
@@ -408,7 +410,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
408
410
|
*/
|
|
409
411
|
restrictChatMember(user_id: number, permissions: ChatPermissions, other?: Other<"restrictChatMember", "user_id" | "permissions">, signal?: AbortSignal): Promise<true>;
|
|
410
412
|
/**
|
|
411
|
-
* Context-aware alias for `api.promoteChatMember`. Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate
|
|
413
|
+
* Context-aware alias for `api.promoteChatMember`. Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success.
|
|
412
414
|
*
|
|
413
415
|
* @param other Optional remaining parameters, confer the official reference below
|
|
414
416
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -417,7 +419,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
417
419
|
*/
|
|
418
420
|
promoteAuthor(other?: Other<"promoteChatMember", "user_id">, signal?: AbortSignal): Promise<true>;
|
|
419
421
|
/**
|
|
420
|
-
* Context-aware alias for `api.promoteChatMember`. Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate
|
|
422
|
+
* Context-aware alias for `api.promoteChatMember`. Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success.
|
|
421
423
|
*
|
|
422
424
|
* @param user_id Unique identifier of the target user
|
|
423
425
|
* @param other Optional remaining parameters, confer the official reference below
|
|
@@ -446,7 +448,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
446
448
|
*/
|
|
447
449
|
setChatAdministratorCustomTitle(user_id: number, custom_title: string, signal?: AbortSignal): Promise<true>;
|
|
448
450
|
/**
|
|
449
|
-
* Context-aware alias for `api.setChatPermissions`. Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members
|
|
451
|
+
* Context-aware alias for `api.setChatPermissions`. Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success.
|
|
450
452
|
*
|
|
451
453
|
* @param permissions New default chat permissions
|
|
452
454
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -455,7 +457,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
455
457
|
*/
|
|
456
458
|
setChatPermissions(permissions: ChatPermissions, signal?: AbortSignal): Promise<true>;
|
|
457
459
|
/**
|
|
458
|
-
* Context-aware alias for `api.exportChatInviteLink`. Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate
|
|
460
|
+
* Context-aware alias for `api.exportChatInviteLink`. Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success.
|
|
459
461
|
*
|
|
460
462
|
* Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using exportChatInviteLink or by calling the getChat method. If your bot needs to generate a new primary invite link replacing its previous one, use exportChatInviteLink again.
|
|
461
463
|
*
|
|
@@ -465,7 +467,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
465
467
|
*/
|
|
466
468
|
exportChatInviteLink(signal?: AbortSignal): Promise<string>;
|
|
467
469
|
/**
|
|
468
|
-
* Context-aware alias for `api.createChatInviteLink`. Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate
|
|
470
|
+
* Context-aware alias for `api.createChatInviteLink`. Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object.
|
|
469
471
|
*
|
|
470
472
|
* @param other Optional remaining parameters, confer the official reference below
|
|
471
473
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -474,7 +476,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
474
476
|
*/
|
|
475
477
|
createChatInviteLink(other?: Other<"createChatInviteLink">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage").ChatInviteLink>;
|
|
476
478
|
/**
|
|
477
|
-
* Context-aware alias for `api.editChatInviteLink`. Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate
|
|
479
|
+
* Context-aware alias for `api.editChatInviteLink`. Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.
|
|
478
480
|
*
|
|
479
481
|
* @param invite_link The invite link to edit
|
|
480
482
|
* @param other Optional remaining parameters, confer the official reference below
|
|
@@ -484,7 +486,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
484
486
|
*/
|
|
485
487
|
editChatInviteLink(invite_link: string, other?: Other<"editChatInviteLink", "invite_link">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage").ChatInviteLink>;
|
|
486
488
|
/**
|
|
487
|
-
* Context-aware alias for `api.revokeChatInviteLink`. Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate
|
|
489
|
+
* Context-aware alias for `api.revokeChatInviteLink`. Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.
|
|
488
490
|
*
|
|
489
491
|
* @param invite_link The invite link to revoke
|
|
490
492
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -493,7 +495,25 @@ export declare class Context implements RenamedUpdate {
|
|
|
493
495
|
*/
|
|
494
496
|
revokeChatInviteLink(invite_link: string, signal?: AbortSignal): Promise<import("@grammyjs/types/manage").ChatInviteLink>;
|
|
495
497
|
/**
|
|
496
|
-
* Context-aware alias for `api.
|
|
498
|
+
* Context-aware alias for `api.approveChatJoinRequest`. Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.
|
|
499
|
+
*
|
|
500
|
+
* @param user_id Unique identifier of the target user
|
|
501
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
502
|
+
*
|
|
503
|
+
* **Official reference:** https://core.telegram.org/bots/api#approvechatjoinrequest
|
|
504
|
+
*/
|
|
505
|
+
approveChatJoinRequest(user_id: number, signal?: AbortSignal): Promise<true>;
|
|
506
|
+
/**
|
|
507
|
+
* Context-aware alias for `api.declineChatJoinRequest`. Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.
|
|
508
|
+
*
|
|
509
|
+
* @param user_id Unique identifier of the target user
|
|
510
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
511
|
+
*
|
|
512
|
+
* **Official reference:** https://core.telegram.org/bots/api#declinechatjoinrequest
|
|
513
|
+
*/
|
|
514
|
+
declineChatJoinRequest(user_id: number, signal?: AbortSignal): Promise<true>;
|
|
515
|
+
/**
|
|
516
|
+
* Context-aware alias for `api.setChatPhoto`. Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
497
517
|
*
|
|
498
518
|
* @param photo New chat photo, uploaded using multipart/form-data
|
|
499
519
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -502,7 +522,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
502
522
|
*/
|
|
503
523
|
setChatPhoto(photo: InputFile, signal?: AbortSignal): Promise<true>;
|
|
504
524
|
/**
|
|
505
|
-
* Context-aware alias for `api.deleteChatPhoto`. Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate
|
|
525
|
+
* Context-aware alias for `api.deleteChatPhoto`. Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
506
526
|
*
|
|
507
527
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
508
528
|
*
|
|
@@ -510,7 +530,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
510
530
|
*/
|
|
511
531
|
deleteChatPhoto(signal?: AbortSignal): Promise<true>;
|
|
512
532
|
/**
|
|
513
|
-
* Context-aware alias for `api.setChatTitle`. Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate
|
|
533
|
+
* Context-aware alias for `api.setChatTitle`. Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
514
534
|
*
|
|
515
535
|
* @param title New chat title, 1-255 characters
|
|
516
536
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -519,7 +539,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
519
539
|
*/
|
|
520
540
|
setChatTitle(title: string, signal?: AbortSignal): Promise<true>;
|
|
521
541
|
/**
|
|
522
|
-
* Context-aware alias for `api.setChatDescription`. Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate
|
|
542
|
+
* Context-aware alias for `api.setChatDescription`. Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
|
|
523
543
|
*
|
|
524
544
|
* @param description New chat description, 0-255 characters
|
|
525
545
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -528,7 +548,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
528
548
|
*/
|
|
529
549
|
setChatDescription(description: string | undefined, signal?: AbortSignal): Promise<true>;
|
|
530
550
|
/**
|
|
531
|
-
* Context-aware alias for `api.pinChatMessage`. Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages'
|
|
551
|
+
* Context-aware alias for `api.pinChatMessage`. Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.
|
|
532
552
|
*
|
|
533
553
|
* @param message_id Identifier of a message to pin
|
|
534
554
|
* @param other Optional remaining parameters, confer the official reference below
|
|
@@ -538,7 +558,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
538
558
|
*/
|
|
539
559
|
pinChatMessage(message_id: number, other?: Other<"pinChatMessage", "message_id">, signal?: AbortSignal): Promise<true>;
|
|
540
560
|
/**
|
|
541
|
-
* Context-aware alias for `api.unpinChatMessage`. Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages'
|
|
561
|
+
* Context-aware alias for `api.unpinChatMessage`. Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.
|
|
542
562
|
*
|
|
543
563
|
* @param message_id Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned.
|
|
544
564
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -547,7 +567,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
547
567
|
*/
|
|
548
568
|
unpinChatMessage(message_id?: number, signal?: AbortSignal): Promise<true>;
|
|
549
569
|
/**
|
|
550
|
-
* Context-aware alias for `api.unpinAllChatMessages`. Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages'
|
|
570
|
+
* Context-aware alias for `api.unpinAllChatMessages`. Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.
|
|
551
571
|
*
|
|
552
572
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
553
573
|
*
|
|
@@ -606,7 +626,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
606
626
|
*/
|
|
607
627
|
getChatMember(user_id: number, signal?: AbortSignal): Promise<import("@grammyjs/types/manage").ChatMember>;
|
|
608
628
|
/**
|
|
609
|
-
* Context-aware alias for `api.setChatStickerSet`. Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate
|
|
629
|
+
* Context-aware alias for `api.setChatStickerSet`. Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success.
|
|
610
630
|
*
|
|
611
631
|
* @param sticker_set_name Name of the sticker set to be set as the group sticker set
|
|
612
632
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -615,7 +635,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
615
635
|
*/
|
|
616
636
|
setChatStickerSet(sticker_set_name: string, signal?: AbortSignal): Promise<true>;
|
|
617
637
|
/**
|
|
618
|
-
* Context-aware alias for `api.deleteChatStickerSet`. Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate
|
|
638
|
+
* Context-aware alias for `api.deleteChatStickerSet`. Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success.
|
|
619
639
|
*
|
|
620
640
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
621
641
|
*
|
|
@@ -632,7 +652,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
632
652
|
*
|
|
633
653
|
* **Official reference:** https://core.telegram.org/bots/api#answercallbackquery
|
|
634
654
|
*/
|
|
635
|
-
answerCallbackQuery(other?: Other<"answerCallbackQuery", "callback_query_id">, signal?: AbortSignal): Promise<true>;
|
|
655
|
+
answerCallbackQuery(other?: string | Other<"answerCallbackQuery", "callback_query_id">, signal?: AbortSignal): Promise<true>;
|
|
636
656
|
/**
|
|
637
657
|
* Context-aware alias for `api.editMessageText`. Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
|
|
638
658
|
*
|
|
@@ -710,7 +730,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
710
730
|
* Context-aware alias for `api.answerInlineQuery`. Use this method to send answers to an inline query. On success, True is returned.
|
|
711
731
|
* No more than 50 results per query are allowed.
|
|
712
732
|
*
|
|
713
|
-
* Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an
|
|
733
|
+
* Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.
|
|
714
734
|
*
|
|
715
735
|
* @param results An array of results for the inline query
|
|
716
736
|
* @param other Optional remaining parameters, confer the official reference below
|
|
@@ -754,7 +774,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
754
774
|
*
|
|
755
775
|
* **Official reference:** https://core.telegram.org/bots/api#answerprecheckoutquery
|
|
756
776
|
*/
|
|
757
|
-
answerPreCheckoutQuery(ok: boolean, other?: Other<"answerPreCheckoutQuery", "pre_checkout_query_id" | "ok">, signal?: AbortSignal): Promise<true>;
|
|
777
|
+
answerPreCheckoutQuery(ok: boolean, other?: string | Other<"answerPreCheckoutQuery", "pre_checkout_query_id" | "ok">, signal?: AbortSignal): Promise<true>;
|
|
758
778
|
/**
|
|
759
779
|
* Context-aware alias for `api.setPassportDataErrors`. Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success.
|
|
760
780
|
*
|