telegram-bot-api-nodejs 1.0.3 â 1.0.5
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/index.d.ts +8 -2
- package/index.js +21 -3
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -617,12 +617,18 @@ export declare function parsePollOption(v: PollOption): {
|
|
|
617
617
|
export declare function parseCallbackQuery(v?: CallbackQuery): CallbackQuery | undefined;
|
|
618
618
|
export declare function parseResponse<T>(response: Response): Promise<T>;
|
|
619
619
|
export declare class TelegramError extends Error {
|
|
620
|
-
|
|
620
|
+
status: number;
|
|
621
621
|
parameters: Record<string, any>;
|
|
622
|
-
constructor(message: string,
|
|
622
|
+
constructor(message: string, status: number, parameters?: Record<string, any>);
|
|
623
623
|
}
|
|
624
624
|
/**
|
|
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
|
@@ -467,11 +467,11 @@ export function parseResponse(response) {
|
|
|
467
467
|
});
|
|
468
468
|
}
|
|
469
469
|
export class TelegramError extends Error {
|
|
470
|
-
|
|
470
|
+
status;
|
|
471
471
|
parameters;
|
|
472
|
-
constructor(message,
|
|
472
|
+
constructor(message, status, parameters = {}) {
|
|
473
473
|
super(message);
|
|
474
|
-
this.
|
|
474
|
+
this.status = status;
|
|
475
475
|
this.parameters = parameters;
|
|
476
476
|
}
|
|
477
477
|
}
|
|
@@ -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
|
+
}
|