telegram-bot-api-nodejs 1.0.3 → 1.0.4

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.
Files changed (3) hide show
  1. package/index.d.ts +6 -0
  2. package/index.js +18 -0
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -625,4 +625,10 @@ export declare class TelegramError extends Error {
625
625
  * Helpers
626
626
  */
627
627
  export declare const SUPPORTED_REACTION_EMOJI: string[];
628
+ export declare function isUnauthorizedError(err: unknown): err is Error;
629
+ export declare function isBotBlockedByUserError(err: unknown): err is Error;
630
+ export declare function isChatNotFoundError(err: unknown): err is Error;
631
+ export declare function isUserDeactivatedError(err: unknown): err is Error;
632
+ export declare function isBotKickedFromSupergroupError(err: unknown): err is Error;
633
+ export declare function isNotEnoughRightsError(err: unknown): err is Error;
628
634
  export {};
package/index.js CHANGED
@@ -487,3 +487,21 @@ export const SUPPORTED_REACTION_EMOJI = ["👍", "👎", "\u2764\ufe0f" // red h
487
487
  "✍", "ðŸĪ—", "ðŸŦĄ", "🎅", "🎄", "☃", "💅", "ðŸĪŠ", "ðŸ—ŋ", "🆒", "💘", "🙉", "ðŸĶ„",
488
488
  "😘", "💊", "🙊", "😎", "ðŸ‘ū", "ðŸĪ·â€â™‚", "ðŸĪ·", "ðŸĪ·â€â™€", "ðŸ˜Ą"
489
489
  ];
490
+ export function isUnauthorizedError(err) {
491
+ return err instanceof Error && err.message === "Unauthorized";
492
+ }
493
+ export function isBotBlockedByUserError(err) {
494
+ return err instanceof Error && err.message.includes("Forbidden: bot was blocked by the user");
495
+ }
496
+ export function isChatNotFoundError(err) {
497
+ return err instanceof Error && err.message.includes("Bad Request: chat not found");
498
+ }
499
+ export function isUserDeactivatedError(err) {
500
+ return err instanceof Error && err.message.includes("Forbidden: user is deactivated");
501
+ }
502
+ export function isBotKickedFromSupergroupError(err) {
503
+ return err instanceof Error && err.message.includes("Forbidden: bot was kicked from the supergroup chat");
504
+ }
505
+ export function isNotEnoughRightsError(err) {
506
+ return err instanceof Error && err.message.includes("Bad Request: not enough rights to send text messages to the chat");
507
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telegram-bot-api-nodejs",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Telegram Bot API client for nodejs",
5
5
  "type": "module",
6
6
  "main": "index.js",