grammy 1.22.4 → 1.23.1

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 CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  <!-- deno-fmt-ignore-start -->
12
12
 
13
- [![Bot API](https://img.shields.io/badge/Bot%20API-7.2-blue?logo=telegram&style=flat&labelColor=000&color=3b82f6)](https://core.telegram.org/bots/api)
13
+ [![Bot API](https://img.shields.io/badge/Bot%20API-7.3-blue?logo=telegram&style=flat&labelColor=000&color=3b82f6)](https://core.telegram.org/bots/api)
14
14
  [![Deno](https://shield.deno.dev/x/grammy)](https://deno.land/x/grammy)
15
15
  [![npm](https://img.shields.io/npm/v/grammy?logo=npm&style=flat&labelColor=000&color=3b82f6)](https://www.npmjs.org/package/grammy)
16
16
  [![All Contributors](https://img.shields.io/github/all-contributors/grammyjs/grammy?style=flat&labelColor=000&color=3b82f6)](#contributors-)
@@ -288,6 +288,12 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
288
288
  <td align="center" valign="top" width="11.11%"><a href="https://linktr.ee/joshgillies"><img src="https://avatars.githubusercontent.com/u/319694?v=4?s=100" width="100px;" alt="Josh Gillies"/><br /><sub><b>Josh Gillies</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=joshgillies" title="Code">💻</a></td>
289
289
  <td align="center" valign="top" width="11.11%"><a href="https://secondthunder.github.io"><img src="https://avatars.githubusercontent.com/u/36604233?v=4?s=100" width="100px;" alt="Uladzislau Hramyka"/><br /><sub><b>Uladzislau Hramyka</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3ASecondThundeR" title="Bug reports">🐛</a></td>
290
290
  <td align="center" valign="top" width="11.11%"><a href="http://gabelluardo.github.io"><img src="https://avatars.githubusercontent.com/u/42920247?v=4?s=100" width="100px;" alt="Gabriele Belluardo"/><br /><sub><b>Gabriele Belluardo</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Agabelluardo" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=gabelluardo" title="Code">💻</a></td>
291
+ <td align="center" valign="top" width="11.11%"><a href="https://github.com/dimpurr"><img src="https://avatars.githubusercontent.com/u/5173244?v=4?s=100" width="100px;" alt="Dim Chen"/><br /><sub><b>Dim Chen</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Adimpurr" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=dimpurr" title="Code">💻</a></td>
292
+ <td align="center" valign="top" width="11.11%"><a href="http://www.fwqaq.us"><img src="https://avatars.githubusercontent.com/u/82551626?v=4?s=100" width="100px;" alt="fwqaaq"/><br /><sub><b>fwqaaq</b></sub></a><br /><a href="#ideas-fwqaaq" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=fwqaaq" title="Code">💻</a></td>
293
+ <td align="center" valign="top" width="11.11%"><a href="https://github.com/janek"><img src="https://avatars.githubusercontent.com/u/2146927?v=4?s=100" width="100px;" alt="Janek Szynal"/><br /><sub><b>Janek Szynal</b></sub></a><br /><a href="#ideas-janek" title="Ideas, Planning, & Feedback">🤔</a></td>
294
+ <td align="center" valign="top" width="11.11%"><a href="https://github.com/mordv"><img src="https://avatars.githubusercontent.com/u/32086218?v=4?s=100" width="100px;" alt="Alexander Mordvinov"/><br /><sub><b>Alexander Mordvinov</b></sub></a><br /><a href="#ideas-mordv" title="Ideas, Planning, & Feedback">🤔</a></td>
295
+ <td align="center" valign="top" width="11.11%"><a href="http://zi.vc/"><img src="https://avatars.githubusercontent.com/u/4239224?v=4?s=100" width="100px;" alt="Ash"/><br /><sub><b>Ash</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Azivc" title="Reviewed Pull Requests">👀</a></td>
296
+ <td align="center" valign="top" width="11.11%"><a href="https://github.com/winstxnhdw"><img src="https://avatars.githubusercontent.com/u/56998716?v=4?s=100" width="100px;" alt="Winston H."/><br /><sub><b>Winston H.</b></sub></a><br /><a href="#ideas-winstxnhdw" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=winstxnhdw" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Awinstxnhdw" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/commits?author=winstxnhdw" title="Tests">⚠️</a></td>
291
297
  </tr>
292
298
  </tbody>
293
299
  </table>
package/out/bot.js CHANGED
@@ -284,19 +284,24 @@ a known bot info object.");
284
284
  debug("Simple long polling already running!");
285
285
  return;
286
286
  }
287
- else {
288
- this.pollingRunning = true;
289
- this.pollingAbortController = new shim_node_js_1.AbortController();
287
+ this.pollingRunning = true;
288
+ this.pollingAbortController = new shim_node_js_1.AbortController();
289
+ try {
290
+ setup.push(withRetries(async () => {
291
+ var _a;
292
+ await this.api.deleteWebhook({
293
+ drop_pending_updates: options === null || options === void 0 ? void 0 : options.drop_pending_updates,
294
+ }, (_a = this.pollingAbortController) === null || _a === void 0 ? void 0 : _a.signal);
295
+ }, (_b = this.pollingAbortController) === null || _b === void 0 ? void 0 : _b.signal));
296
+ await Promise.all(setup);
297
+ // All async ops of setup complete, run callback
298
+ await ((_c = options === null || options === void 0 ? void 0 : options.onStart) === null || _c === void 0 ? void 0 : _c.call(options, this.botInfo));
299
+ }
300
+ catch (err) {
301
+ this.pollingRunning = false;
302
+ this.pollingAbortController = undefined;
303
+ throw err;
290
304
  }
291
- setup.push(withRetries(async () => {
292
- var _a;
293
- await this.api.deleteWebhook({
294
- drop_pending_updates: options === null || options === void 0 ? void 0 : options.drop_pending_updates,
295
- }, (_a = this.pollingAbortController) === null || _a === void 0 ? void 0 : _a.signal);
296
- }, (_b = this.pollingAbortController) === null || _b === void 0 ? void 0 : _b.signal));
297
- await Promise.all(setup);
298
- // All async ops of setup complete, run callback
299
- await ((_c = options === null || options === void 0 ? void 0 : options.onStart) === null || _c === void 0 ? void 0 : _c.call(options, this.botInfo));
300
305
  // Bot was stopped during `onStart`
301
306
  if (!this.pollingRunning)
302
307
  return;
@@ -413,12 +418,8 @@ a known bot info object.");
413
418
  let sleepSeconds = 3;
414
419
  if (error instanceof error_js_1.GrammyError) {
415
420
  debugErr(error.message);
416
- if (error.error_code === 401) {
417
- debugErr("Make sure you are using the bot token you obtained from @BotFather (https://t.me/BotFather).");
418
- throw error;
419
- }
420
- else if (error.error_code === 409) {
421
- debugErr("Consider revoking the bot token if you believe that no other instance is running.");
421
+ // rethrow upon unauthorized or conflict
422
+ if (error.error_code === 401 || error.error_code === 409) {
422
423
  throw error;
423
424
  }
424
425
  else if (error.error_code === 429) {
package/out/context.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type Api, type Other as OtherApi } from "./core/api.js";
2
2
  import { type Methods, type RawApi } from "./core/client.js";
3
3
  import { type Filter, type FilterCore, type FilterQuery } from "./filter.js";
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 ReactionType, type ReactionTypeEmoji, type Update, type User, type UserFromGetMe } from "./types.js";
4
+ import { type Chat, type ChatPermissions, type InlineQueryResult, type InputFile, type InputMedia, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo, type InputPollOption, type LabeledPrice, type Message, type MessageEntity, type PassportElementError, type ReactionType, type ReactionTypeEmoji, type Update, type User, type UserFromGetMe } from "./types.js";
5
5
  export type MaybeArray<T> = T | T[];
6
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>;
@@ -231,6 +231,11 @@ export declare class Context implements RenamedUpdate {
231
231
  * this.messageReactionCount?.message_id`.
232
232
  */
233
233
  get msgId(): number | undefined;
234
+ /**
235
+ * Gets the chat identifier from wherever possible. Alias for `this.chat?.id
236
+ * ?? this.businessConnection?.user_chat_id`.
237
+ */
238
+ get chatId(): number | undefined;
234
239
  /**
235
240
  * Get the inline message identifier from wherever possible. Alias for
236
241
  * `(ctx.callbackQuery ?? ctx.chosenInlineResult)?.inline_message_id`.
@@ -606,7 +611,7 @@ export declare class Context implements RenamedUpdate {
606
611
  *
607
612
  * **Official reference:** https://core.telegram.org/bots/api#sendpoll
608
613
  */
609
- replyWithPoll(question: string, options: readonly string[], other?: Other<"sendPoll", "chat_id" | "question" | "options">, signal?: AbortSignal): Promise<Message.PollMessage>;
614
+ replyWithPoll(question: string, options: InputPollOption[], other?: Other<"sendPoll", "chat_id" | "question" | "options">, signal?: AbortSignal): Promise<Message.PollMessage>;
610
615
  /**
611
616
  * Context-aware alias for `api.sendDice`. Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
612
617
  *
@@ -929,7 +934,7 @@ export declare class Context implements RenamedUpdate {
929
934
  *
930
935
  * **Official reference:** https://core.telegram.org/bots/api#getchat
931
936
  */
932
- getChat(signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ChatFromGetChat>;
937
+ getChat(signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ChatFullInfo>;
933
938
  /**
934
939
  * Context-aware alias for `api.getChatAdministrators`. Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of ChatMember objects.
935
940
  *