telegram-bot-api-nodejs 1.0.15 → 1.0.17
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 +49 -76
- package/index.js +27 -23
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface SetWebHookOptions {
|
|
|
13
13
|
}
|
|
14
14
|
interface SendBasicOptions {
|
|
15
15
|
chat_id: number | string;
|
|
16
|
+
message_thread_id?: number;
|
|
16
17
|
disable_notification?: boolean;
|
|
17
18
|
reply_to_message_id?: number | string;
|
|
18
19
|
reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply;
|
|
@@ -100,6 +101,7 @@ export interface Update {
|
|
|
100
101
|
callback_query?: CallbackQuery;
|
|
101
102
|
shipping_query?: ShippingQuery;
|
|
102
103
|
pre_checkout_query?: PreCheckoutQuery;
|
|
104
|
+
my_chat_member?: ChatMemberUpdated;
|
|
103
105
|
}
|
|
104
106
|
export interface WebhookInfo {
|
|
105
107
|
url: string;
|
|
@@ -129,6 +131,7 @@ export interface Chat {
|
|
|
129
131
|
username?: string;
|
|
130
132
|
first_name?: string;
|
|
131
133
|
last_name?: string;
|
|
134
|
+
is_forum?: boolean;
|
|
132
135
|
photo?: ChatPhoto;
|
|
133
136
|
bio?: string;
|
|
134
137
|
description?: string;
|
|
@@ -138,11 +141,29 @@ export interface Chat {
|
|
|
138
141
|
can_set_sticker_set?: boolean;
|
|
139
142
|
sticker_set_name?: string;
|
|
140
143
|
}
|
|
144
|
+
interface ForumTopicCreated {
|
|
145
|
+
name: string;
|
|
146
|
+
icon_color: number;
|
|
147
|
+
icon_custom_emoji_id?: string;
|
|
148
|
+
}
|
|
149
|
+
interface ForumTopicEdited {
|
|
150
|
+
name?: string;
|
|
151
|
+
icon_custom_emoji_id?: string;
|
|
152
|
+
}
|
|
153
|
+
interface ForumTopicClosed {
|
|
154
|
+
}
|
|
155
|
+
interface ForumTopicReopened {
|
|
156
|
+
}
|
|
157
|
+
interface GeneralForumTopicHidden {
|
|
158
|
+
}
|
|
159
|
+
interface GeneralForumTopicUnhidden {
|
|
160
|
+
}
|
|
141
161
|
/**
|
|
142
162
|
* @docs https://core.telegram.org/bots/api#message
|
|
143
163
|
*/
|
|
144
164
|
export interface Message {
|
|
145
165
|
message_id: number;
|
|
166
|
+
message_thread_id?: number;
|
|
146
167
|
from?: User;
|
|
147
168
|
date: number;
|
|
148
169
|
chat: Chat;
|
|
@@ -152,6 +173,8 @@ export interface Message {
|
|
|
152
173
|
forward_signature?: string;
|
|
153
174
|
forward_sender_name?: string;
|
|
154
175
|
forward_date?: number;
|
|
176
|
+
is_topic_message?: boolean;
|
|
177
|
+
is_automatic_forward?: boolean;
|
|
155
178
|
reply_to_message?: Message;
|
|
156
179
|
edit_date?: number;
|
|
157
180
|
media_group_id?: string;
|
|
@@ -190,6 +213,12 @@ export interface Message {
|
|
|
190
213
|
passport_data?: PassportData;
|
|
191
214
|
reply_markup?: InlineKeyboardMarkup;
|
|
192
215
|
sender_chat?: Chat;
|
|
216
|
+
forum_topic_created?: ForumTopicCreated;
|
|
217
|
+
forum_topic_edited?: ForumTopicEdited;
|
|
218
|
+
forum_topic_closed?: ForumTopicClosed;
|
|
219
|
+
forum_topic_reopened?: ForumTopicReopened;
|
|
220
|
+
general_forum_topic_hidden?: GeneralForumTopicHidden;
|
|
221
|
+
general_forum_topic_unhidden?: GeneralForumTopicUnhidden;
|
|
193
222
|
}
|
|
194
223
|
export interface MessageReactionUpdated {
|
|
195
224
|
chat: Chat;
|
|
@@ -514,6 +543,26 @@ interface PreCheckoutQuery {
|
|
|
514
543
|
shipping_option_id?: string;
|
|
515
544
|
order_info?: OrderInfo;
|
|
516
545
|
}
|
|
546
|
+
interface ChatMemberUpdated {
|
|
547
|
+
chat: Chat;
|
|
548
|
+
from: User;
|
|
549
|
+
date: number;
|
|
550
|
+
old_chat_member: ChatMember;
|
|
551
|
+
new_chat_member: ChatMember;
|
|
552
|
+
invite_link: ChatInviteLink;
|
|
553
|
+
via_chat_folder_invite_link: boolean;
|
|
554
|
+
}
|
|
555
|
+
interface ChatInviteLink {
|
|
556
|
+
invite_link: string;
|
|
557
|
+
creator: User;
|
|
558
|
+
creates_join_request: boolean;
|
|
559
|
+
is_primary: boolean;
|
|
560
|
+
is_revoked: boolean;
|
|
561
|
+
name?: string;
|
|
562
|
+
expire_date?: number;
|
|
563
|
+
member_limit?: number;
|
|
564
|
+
pending_join_request_count?: number;
|
|
565
|
+
}
|
|
517
566
|
interface Game {
|
|
518
567
|
title: string;
|
|
519
568
|
description: string;
|
|
@@ -597,82 +646,6 @@ export declare function deleteMyCommands(token: string, payload: DeleteMyCommand
|
|
|
597
646
|
* Parsers
|
|
598
647
|
*/
|
|
599
648
|
export declare function parseUpdate(update: any): Update;
|
|
600
|
-
export declare function parseMessage(m: any): Message;
|
|
601
|
-
export declare function parseUser(u: User): User;
|
|
602
|
-
export declare function parseChat(c: Chat): {
|
|
603
|
-
id: number;
|
|
604
|
-
type: ChatType;
|
|
605
|
-
title: string;
|
|
606
|
-
username: string;
|
|
607
|
-
first_name: string;
|
|
608
|
-
last_name: string;
|
|
609
|
-
};
|
|
610
|
-
export declare function parsePhotoSizes(p: PhotoSize[]): {
|
|
611
|
-
file_id: string;
|
|
612
|
-
file_unique_id: string;
|
|
613
|
-
file_size: number;
|
|
614
|
-
width: number;
|
|
615
|
-
height: number;
|
|
616
|
-
}[] | undefined;
|
|
617
|
-
export declare function parsePhotoSize(p: PhotoSize): {
|
|
618
|
-
file_id: string;
|
|
619
|
-
file_unique_id: string;
|
|
620
|
-
file_size: number;
|
|
621
|
-
width: number;
|
|
622
|
-
height: number;
|
|
623
|
-
};
|
|
624
|
-
export declare function parseSticker(v: Sticker): Sticker;
|
|
625
|
-
export declare function parseVideo(v: Video): Video;
|
|
626
|
-
export declare function parseVoice(v: Voice): Voice;
|
|
627
|
-
export declare function parseVideoNote(v: VideoNote): VideoNote;
|
|
628
|
-
export declare function parseEntities(v: MessageEntity[]): MessageEntity[];
|
|
629
|
-
export declare function parseAudio(v: Audio): Audio;
|
|
630
|
-
export declare function parseDocument(v: Document): Document;
|
|
631
|
-
export declare function parseAnimation(v: Animation): Animation;
|
|
632
|
-
export declare function parseContact(v: Contact): {
|
|
633
|
-
phone_number: string;
|
|
634
|
-
first_name: string;
|
|
635
|
-
last_name: string;
|
|
636
|
-
user_id: number;
|
|
637
|
-
vcard: string;
|
|
638
|
-
};
|
|
639
|
-
export declare function parseLocation(v: Location): {
|
|
640
|
-
longitude: number;
|
|
641
|
-
latitude: number;
|
|
642
|
-
};
|
|
643
|
-
export declare function parseVenue(v: Venue): {
|
|
644
|
-
location: {
|
|
645
|
-
longitude: number;
|
|
646
|
-
latitude: number;
|
|
647
|
-
};
|
|
648
|
-
title: string;
|
|
649
|
-
address: string;
|
|
650
|
-
foursquare_id: string;
|
|
651
|
-
foursquare_type: string;
|
|
652
|
-
google_place_id: string;
|
|
653
|
-
google_place_type: string;
|
|
654
|
-
};
|
|
655
|
-
export declare function parsePoll(v: Poll): {
|
|
656
|
-
id: string;
|
|
657
|
-
question: string;
|
|
658
|
-
options: {
|
|
659
|
-
text: string;
|
|
660
|
-
voter_count: number;
|
|
661
|
-
}[];
|
|
662
|
-
is_closed: boolean;
|
|
663
|
-
};
|
|
664
|
-
export declare function parsePollOptions(v: PollOption[]): {
|
|
665
|
-
text: string;
|
|
666
|
-
voter_count: number;
|
|
667
|
-
}[];
|
|
668
|
-
export declare function parsePollOption(v: PollOption): {
|
|
669
|
-
text: string;
|
|
670
|
-
voter_count: number;
|
|
671
|
-
};
|
|
672
|
-
/**
|
|
673
|
-
* @see https://core.telegram.org/bots/api#callbackquery
|
|
674
|
-
*/
|
|
675
|
-
export declare function parseCallbackQuery(v?: CallbackQuery): CallbackQuery | undefined;
|
|
676
649
|
export declare function parseResponse<T>(response: Response): Promise<T>;
|
|
677
650
|
export declare class TelegramError extends Error {
|
|
678
651
|
status: number;
|
package/index.js
CHANGED
|
@@ -196,10 +196,14 @@ export function parseUpdate(update) {
|
|
|
196
196
|
if (update.message_reaction_count) {
|
|
197
197
|
u.message_reaction_count = parseMessageReactionCount(update.message_reaction_count);
|
|
198
198
|
}
|
|
199
|
-
return
|
|
199
|
+
return {
|
|
200
|
+
...update,
|
|
201
|
+
u
|
|
202
|
+
};
|
|
200
203
|
}
|
|
201
|
-
|
|
204
|
+
function parseMessage(m) {
|
|
202
205
|
return {
|
|
206
|
+
...m,
|
|
203
207
|
message_id: Number(m.message_id),
|
|
204
208
|
from: m.from ? parseUser(m.from) : void 0,
|
|
205
209
|
date: Number(m.date),
|
|
@@ -211,7 +215,8 @@ export function parseMessage(m) {
|
|
|
211
215
|
forward_signature: m.forward_signature ? String(m.forward_signature) : void 0, // string;
|
|
212
216
|
forward_sender_name: m.forward_sender_name ? String(m.forward_sender_name) : void 0, // string;
|
|
213
217
|
forward_date: m.forward_date ? Number(m.forward_date) : void 0, // number;
|
|
214
|
-
|
|
218
|
+
reply_to_message: m.reply_to_message ? parseMessage(m.reply_to_message) : void 0,
|
|
219
|
+
is_automatic_forward: m.is_automatic_forward != null ? Boolean(m.is_automatic_forward) : void 0,
|
|
215
220
|
edit_date: m.edit_date ? Number(m.edit_date) : void 0, // number;
|
|
216
221
|
media_group_id: m.media_group_id ? String(m.media_group_id) : void 0, // string;
|
|
217
222
|
author_signature: m.author_signature ? String(m.author_signature) : void 0, // string;
|
|
@@ -232,7 +237,6 @@ export function parseMessage(m) {
|
|
|
232
237
|
venue: m.venue ? parseVenue(m.venue) : void 0,
|
|
233
238
|
poll: m.poll ? parsePoll(m.poll) : void 0,
|
|
234
239
|
// new_chat_members?: User[];
|
|
235
|
-
// left_chat_member?: User;
|
|
236
240
|
// new_chat_title?: string;
|
|
237
241
|
// new_chat_photo?: PhotoSize[];
|
|
238
242
|
// delete_chat_photo?: boolean;
|
|
@@ -250,7 +254,7 @@ export function parseMessage(m) {
|
|
|
250
254
|
sender_chat: m.sender_chat ? parseChat(m.sender_chat) : void 0,
|
|
251
255
|
};
|
|
252
256
|
}
|
|
253
|
-
|
|
257
|
+
function parseUser(u) {
|
|
254
258
|
return {
|
|
255
259
|
id: String(u.id),
|
|
256
260
|
is_bot: Boolean(u.is_bot),
|
|
@@ -261,7 +265,7 @@ export function parseUser(u) {
|
|
|
261
265
|
is_premium: Boolean(u.is_premium ?? ""),
|
|
262
266
|
};
|
|
263
267
|
}
|
|
264
|
-
|
|
268
|
+
function parseChat(c) {
|
|
265
269
|
return {
|
|
266
270
|
id: Number(c.id),
|
|
267
271
|
type: c.type,
|
|
@@ -271,13 +275,13 @@ export function parseChat(c) {
|
|
|
271
275
|
last_name: String(c.last_name ?? ""),
|
|
272
276
|
};
|
|
273
277
|
}
|
|
274
|
-
|
|
278
|
+
function parsePhotoSizes(p) {
|
|
275
279
|
if (!Array.isArray(p)) {
|
|
276
280
|
return void 0;
|
|
277
281
|
}
|
|
278
282
|
return p.map(parsePhotoSize);
|
|
279
283
|
}
|
|
280
|
-
|
|
284
|
+
function parsePhotoSize(p) {
|
|
281
285
|
return {
|
|
282
286
|
file_id: String(p.file_id),
|
|
283
287
|
file_unique_id: String(p.file_unique_id),
|
|
@@ -286,7 +290,7 @@ export function parsePhotoSize(p) {
|
|
|
286
290
|
height: Number(p.height),
|
|
287
291
|
};
|
|
288
292
|
}
|
|
289
|
-
|
|
293
|
+
function parseSticker(v) {
|
|
290
294
|
return {
|
|
291
295
|
file_id: String(v.file_id),
|
|
292
296
|
width: Number(v.width),
|
|
@@ -296,7 +300,7 @@ export function parseSticker(v) {
|
|
|
296
300
|
emoji: String(v.emoji),
|
|
297
301
|
};
|
|
298
302
|
}
|
|
299
|
-
|
|
303
|
+
function parseVideo(v) {
|
|
300
304
|
return {
|
|
301
305
|
file_id: String(v.file_id),
|
|
302
306
|
width: Number(v.width),
|
|
@@ -308,7 +312,7 @@ export function parseVideo(v) {
|
|
|
308
312
|
file_size: Number(v.file_size ?? ""),
|
|
309
313
|
};
|
|
310
314
|
}
|
|
311
|
-
|
|
315
|
+
function parseVoice(v) {
|
|
312
316
|
return {
|
|
313
317
|
file_id: String(v.file_id),
|
|
314
318
|
file_size: Number(v.file_size),
|
|
@@ -316,7 +320,7 @@ export function parseVoice(v) {
|
|
|
316
320
|
mime_type: String(v.mime_type)
|
|
317
321
|
};
|
|
318
322
|
}
|
|
319
|
-
|
|
323
|
+
function parseVideoNote(v) {
|
|
320
324
|
return {
|
|
321
325
|
file_id: String(v.file_id),
|
|
322
326
|
length: Number(v.length),
|
|
@@ -324,7 +328,7 @@ export function parseVideoNote(v) {
|
|
|
324
328
|
thumb: v.thumb ? parsePhotoSize(v.thumb) : void 0,
|
|
325
329
|
};
|
|
326
330
|
}
|
|
327
|
-
|
|
331
|
+
function parseEntities(v) {
|
|
328
332
|
if (!Array.isArray(v)) {
|
|
329
333
|
return [];
|
|
330
334
|
}
|
|
@@ -338,7 +342,7 @@ export function parseEntities(v) {
|
|
|
338
342
|
};
|
|
339
343
|
});
|
|
340
344
|
}
|
|
341
|
-
|
|
345
|
+
function parseAudio(v) {
|
|
342
346
|
return {
|
|
343
347
|
file_id: String(v.file_id),
|
|
344
348
|
duration: Number(v.duration),
|
|
@@ -348,7 +352,7 @@ export function parseAudio(v) {
|
|
|
348
352
|
mime_type: String(v.mime_type ?? ""),
|
|
349
353
|
};
|
|
350
354
|
}
|
|
351
|
-
|
|
355
|
+
function parseDocument(v) {
|
|
352
356
|
return {
|
|
353
357
|
file_id: String(v.file_id),
|
|
354
358
|
file_name: String(v.file_name || ""),
|
|
@@ -356,7 +360,7 @@ export function parseDocument(v) {
|
|
|
356
360
|
file_size: Number(v.file_size || 0),
|
|
357
361
|
};
|
|
358
362
|
}
|
|
359
|
-
|
|
363
|
+
function parseAnimation(v) {
|
|
360
364
|
return {
|
|
361
365
|
file_id: String(v.file_id),
|
|
362
366
|
width: Number(v.width),
|
|
@@ -368,7 +372,7 @@ export function parseAnimation(v) {
|
|
|
368
372
|
thumbnail: v.thumbnail ? parsePhotoSize(v.thumbnail) : void 0,
|
|
369
373
|
};
|
|
370
374
|
}
|
|
371
|
-
|
|
375
|
+
function parseContact(v) {
|
|
372
376
|
return {
|
|
373
377
|
phone_number: String(v.phone_number),
|
|
374
378
|
first_name: String(v.first_name),
|
|
@@ -377,13 +381,13 @@ export function parseContact(v) {
|
|
|
377
381
|
vcard: String(v.vcard ?? ""),
|
|
378
382
|
};
|
|
379
383
|
}
|
|
380
|
-
|
|
384
|
+
function parseLocation(v) {
|
|
381
385
|
return {
|
|
382
386
|
longitude: Number(v.longitude),
|
|
383
387
|
latitude: Number(v.latitude),
|
|
384
388
|
};
|
|
385
389
|
}
|
|
386
|
-
|
|
390
|
+
function parseVenue(v) {
|
|
387
391
|
return {
|
|
388
392
|
location: parseLocation(v.location),
|
|
389
393
|
title: String(v.title),
|
|
@@ -394,7 +398,7 @@ export function parseVenue(v) {
|
|
|
394
398
|
google_place_type: String(v.google_place_type ?? ""),
|
|
395
399
|
};
|
|
396
400
|
}
|
|
397
|
-
|
|
401
|
+
function parsePoll(v) {
|
|
398
402
|
return {
|
|
399
403
|
id: String(v.id),
|
|
400
404
|
question: String(v.question),
|
|
@@ -402,10 +406,10 @@ export function parsePoll(v) {
|
|
|
402
406
|
is_closed: Boolean(v.is_closed),
|
|
403
407
|
};
|
|
404
408
|
}
|
|
405
|
-
|
|
409
|
+
function parsePollOptions(v) {
|
|
406
410
|
return Array.isArray(v) ? v.map(parsePollOption) : [];
|
|
407
411
|
}
|
|
408
|
-
|
|
412
|
+
function parsePollOption(v) {
|
|
409
413
|
return {
|
|
410
414
|
text: String(v.text),
|
|
411
415
|
voter_count: Number(v.voter_count),
|
|
@@ -414,7 +418,7 @@ export function parsePollOption(v) {
|
|
|
414
418
|
/**
|
|
415
419
|
* @see https://core.telegram.org/bots/api#callbackquery
|
|
416
420
|
*/
|
|
417
|
-
|
|
421
|
+
function parseCallbackQuery(v) {
|
|
418
422
|
if (!v) {
|
|
419
423
|
return;
|
|
420
424
|
}
|