telegram-bot-api-nodejs 1.0.12 → 1.0.14
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 +27 -15
- package/index.js +29 -2
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -441,6 +441,8 @@ export interface Sticker {
|
|
|
441
441
|
file_id: string;
|
|
442
442
|
width: number;
|
|
443
443
|
height: number;
|
|
444
|
+
thumbnail?: PhotoSize;
|
|
445
|
+
/** @deprecated */
|
|
444
446
|
thumb?: PhotoSize;
|
|
445
447
|
emoji?: string;
|
|
446
448
|
set_name?: string;
|
|
@@ -524,7 +526,9 @@ export interface Animation extends FileBase {
|
|
|
524
526
|
width: number;
|
|
525
527
|
height: number;
|
|
526
528
|
duration: number;
|
|
529
|
+
/** @deprecated */
|
|
527
530
|
thumb?: PhotoSize;
|
|
531
|
+
thumbnail?: PhotoSize;
|
|
528
532
|
file_name?: string;
|
|
529
533
|
mime_type?: string;
|
|
530
534
|
}
|
|
@@ -548,7 +552,22 @@ export declare function sendPhoto(token: string, payload: SendBasicOptions & {
|
|
|
548
552
|
parse_mode?: ParseMode;
|
|
549
553
|
}, signal: AbortSignal): Promise<Message>;
|
|
550
554
|
export declare function sendAnimation(token: string, payload: SendAnimationOptions, signal: AbortSignal): Promise<Message>;
|
|
551
|
-
|
|
555
|
+
/**
|
|
556
|
+
* @example
|
|
557
|
+
*
|
|
558
|
+
* const body = new FormData()
|
|
559
|
+
*
|
|
560
|
+
* body.append("chat_id", payload.chat_id)
|
|
561
|
+
* body.append("caption", payload.caption)
|
|
562
|
+
* body.append("document", payload.document, payload.documentName)
|
|
563
|
+
*
|
|
564
|
+
* if (payload.parse_mode) {
|
|
565
|
+
* body.append("parse_mode", payload.parse_mode)
|
|
566
|
+
* }
|
|
567
|
+
*
|
|
568
|
+
* sendDocument("token", payload)
|
|
569
|
+
*/
|
|
570
|
+
export declare function sendDocument(token: string, payload: SendDocumentOptions | FormData, signal: AbortSignal): Promise<Message>;
|
|
552
571
|
export declare function sendMediaGroup(token: string, payload: SendMediaGroupOptions, signal: AbortSignal): Promise<Message[]>;
|
|
553
572
|
export declare function setMessageReaction(token: string, payload: {
|
|
554
573
|
chat_id: string | number;
|
|
@@ -609,14 +628,7 @@ export declare function parseVideoNote(v: VideoNote): VideoNote;
|
|
|
609
628
|
export declare function parseEntities(v: MessageEntity[]): MessageEntity[];
|
|
610
629
|
export declare function parseAudio(v: Audio): Audio;
|
|
611
630
|
export declare function parseDocument(v: Document): Document;
|
|
612
|
-
export declare function parseAnimation(v: Animation):
|
|
613
|
-
file_id: string;
|
|
614
|
-
width: number;
|
|
615
|
-
height: number;
|
|
616
|
-
duration: number;
|
|
617
|
-
file_name: string;
|
|
618
|
-
mime_type: string;
|
|
619
|
-
};
|
|
631
|
+
export declare function parseAnimation(v: Animation): Animation;
|
|
620
632
|
export declare function parseContact(v: Contact): {
|
|
621
633
|
phone_number: string;
|
|
622
634
|
first_name: string;
|
|
@@ -671,10 +683,10 @@ export declare class TelegramError extends Error {
|
|
|
671
683
|
* Helpers
|
|
672
684
|
*/
|
|
673
685
|
export declare const SUPPORTED_REACTION_EMOJI: string[];
|
|
674
|
-
export declare function isUnauthorizedError(err: unknown):
|
|
675
|
-
export declare function isBotBlockedByUserError(err: unknown):
|
|
676
|
-
export declare function isChatNotFoundError(err: unknown):
|
|
677
|
-
export declare function isUserDeactivatedError(err: unknown):
|
|
678
|
-
export declare function isBotKickedFromSupergroupError(err: unknown):
|
|
679
|
-
export declare function isNotEnoughRightsError(err: unknown):
|
|
686
|
+
export declare function isUnauthorizedError(err: unknown): boolean;
|
|
687
|
+
export declare function isBotBlockedByUserError(err: unknown): boolean;
|
|
688
|
+
export declare function isChatNotFoundError(err: unknown): boolean;
|
|
689
|
+
export declare function isUserDeactivatedError(err: unknown): boolean;
|
|
690
|
+
export declare function isBotKickedFromSupergroupError(err: unknown): boolean;
|
|
691
|
+
export declare function isNotEnoughRightsError(err: unknown): boolean;
|
|
680
692
|
export {};
|
package/index.js
CHANGED
|
@@ -70,11 +70,35 @@ export function sendAnimation(token, payload, signal) {
|
|
|
70
70
|
signal
|
|
71
71
|
}).then((parseResponse));
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* @example
|
|
75
|
+
*
|
|
76
|
+
* const body = new FormData()
|
|
77
|
+
*
|
|
78
|
+
* body.append("chat_id", payload.chat_id)
|
|
79
|
+
* body.append("caption", payload.caption)
|
|
80
|
+
* body.append("document", payload.document, payload.documentName)
|
|
81
|
+
*
|
|
82
|
+
* if (payload.parse_mode) {
|
|
83
|
+
* body.append("parse_mode", payload.parse_mode)
|
|
84
|
+
* }
|
|
85
|
+
*
|
|
86
|
+
* sendDocument("token", payload)
|
|
87
|
+
*/
|
|
73
88
|
export function sendDocument(token, payload, signal) {
|
|
89
|
+
let h = headers;
|
|
90
|
+
let b = undefined;
|
|
91
|
+
if (payload instanceof FormData) {
|
|
92
|
+
h = undefined;
|
|
93
|
+
b = payload;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
b = JSON.stringify(payload);
|
|
97
|
+
}
|
|
74
98
|
return fetch(`https://api.telegram.org/bot${token}/sendDocument`, {
|
|
75
99
|
method: "POST",
|
|
76
|
-
body:
|
|
77
|
-
headers,
|
|
100
|
+
body: b,
|
|
101
|
+
headers: h,
|
|
78
102
|
signal
|
|
79
103
|
}).then((parseResponse));
|
|
80
104
|
}
|
|
@@ -268,6 +292,7 @@ export function parseSticker(v) {
|
|
|
268
292
|
width: Number(v.width),
|
|
269
293
|
height: Number(v.height),
|
|
270
294
|
thumb: v.thumb ? parsePhotoSize(v.thumb) : void 0,
|
|
295
|
+
thumbnail: v.thumbnail ? parsePhotoSize(v.thumbnail) : void 0,
|
|
271
296
|
emoji: String(v.emoji),
|
|
272
297
|
};
|
|
273
298
|
}
|
|
@@ -339,6 +364,8 @@ export function parseAnimation(v) {
|
|
|
339
364
|
duration: Number(v.duration),
|
|
340
365
|
file_name: String(v.file_name),
|
|
341
366
|
mime_type: String(v.mime_type || ""),
|
|
367
|
+
thumb: v.thumb ? parsePhotoSize(v.thumb) : void 0,
|
|
368
|
+
thumbnail: v.thumbnail ? parsePhotoSize(v.thumbnail) : void 0,
|
|
342
369
|
};
|
|
343
370
|
}
|
|
344
371
|
export function parseContact(v) {
|