telegram-bot-api-nodejs 1.0.16 → 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.
Files changed (3) hide show
  1. package/index.d.ts +21 -76
  2. package/index.js +24 -22
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -101,6 +101,7 @@ export interface Update {
101
101
  callback_query?: CallbackQuery;
102
102
  shipping_query?: ShippingQuery;
103
103
  pre_checkout_query?: PreCheckoutQuery;
104
+ my_chat_member?: ChatMemberUpdated;
104
105
  }
105
106
  export interface WebhookInfo {
106
107
  url: string;
@@ -542,6 +543,26 @@ interface PreCheckoutQuery {
542
543
  shipping_option_id?: string;
543
544
  order_info?: OrderInfo;
544
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
+ }
545
566
  interface Game {
546
567
  title: string;
547
568
  description: string;
@@ -625,82 +646,6 @@ export declare function deleteMyCommands(token: string, payload: DeleteMyCommand
625
646
  * Parsers
626
647
  */
627
648
  export declare function parseUpdate(update: any): Update;
628
- export declare function parseMessage(m: any): Message;
629
- export declare function parseUser(u: User): User;
630
- export declare function parseChat(c: Chat): {
631
- id: number;
632
- type: ChatType;
633
- title: string;
634
- username: string;
635
- first_name: string;
636
- last_name: string;
637
- };
638
- export declare function parsePhotoSizes(p: PhotoSize[]): {
639
- file_id: string;
640
- file_unique_id: string;
641
- file_size: number;
642
- width: number;
643
- height: number;
644
- }[] | undefined;
645
- export declare function parsePhotoSize(p: PhotoSize): {
646
- file_id: string;
647
- file_unique_id: string;
648
- file_size: number;
649
- width: number;
650
- height: number;
651
- };
652
- export declare function parseSticker(v: Sticker): Sticker;
653
- export declare function parseVideo(v: Video): Video;
654
- export declare function parseVoice(v: Voice): Voice;
655
- export declare function parseVideoNote(v: VideoNote): VideoNote;
656
- export declare function parseEntities(v: MessageEntity[]): MessageEntity[];
657
- export declare function parseAudio(v: Audio): Audio;
658
- export declare function parseDocument(v: Document): Document;
659
- export declare function parseAnimation(v: Animation): Animation;
660
- export declare function parseContact(v: Contact): {
661
- phone_number: string;
662
- first_name: string;
663
- last_name: string;
664
- user_id: number;
665
- vcard: string;
666
- };
667
- export declare function parseLocation(v: Location): {
668
- longitude: number;
669
- latitude: number;
670
- };
671
- export declare function parseVenue(v: Venue): {
672
- location: {
673
- longitude: number;
674
- latitude: number;
675
- };
676
- title: string;
677
- address: string;
678
- foursquare_id: string;
679
- foursquare_type: string;
680
- google_place_id: string;
681
- google_place_type: string;
682
- };
683
- export declare function parsePoll(v: Poll): {
684
- id: string;
685
- question: string;
686
- options: {
687
- text: string;
688
- voter_count: number;
689
- }[];
690
- is_closed: boolean;
691
- };
692
- export declare function parsePollOptions(v: PollOption[]): {
693
- text: string;
694
- voter_count: number;
695
- }[];
696
- export declare function parsePollOption(v: PollOption): {
697
- text: string;
698
- voter_count: number;
699
- };
700
- /**
701
- * @see https://core.telegram.org/bots/api#callbackquery
702
- */
703
- export declare function parseCallbackQuery(v?: CallbackQuery): CallbackQuery | undefined;
704
649
  export declare function parseResponse<T>(response: Response): Promise<T>;
705
650
  export declare class TelegramError extends Error {
706
651
  status: number;
package/index.js CHANGED
@@ -196,9 +196,12 @@ 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 u;
199
+ return {
200
+ ...update,
201
+ u
202
+ };
200
203
  }
201
- export function parseMessage(m) {
204
+ function parseMessage(m) {
202
205
  return {
203
206
  ...m,
204
207
  message_id: Number(m.message_id),
@@ -234,7 +237,6 @@ export function parseMessage(m) {
234
237
  venue: m.venue ? parseVenue(m.venue) : void 0,
235
238
  poll: m.poll ? parsePoll(m.poll) : void 0,
236
239
  // new_chat_members?: User[];
237
- // left_chat_member?: User;
238
240
  // new_chat_title?: string;
239
241
  // new_chat_photo?: PhotoSize[];
240
242
  // delete_chat_photo?: boolean;
@@ -252,7 +254,7 @@ export function parseMessage(m) {
252
254
  sender_chat: m.sender_chat ? parseChat(m.sender_chat) : void 0,
253
255
  };
254
256
  }
255
- export function parseUser(u) {
257
+ function parseUser(u) {
256
258
  return {
257
259
  id: String(u.id),
258
260
  is_bot: Boolean(u.is_bot),
@@ -263,7 +265,7 @@ export function parseUser(u) {
263
265
  is_premium: Boolean(u.is_premium ?? ""),
264
266
  };
265
267
  }
266
- export function parseChat(c) {
268
+ function parseChat(c) {
267
269
  return {
268
270
  id: Number(c.id),
269
271
  type: c.type,
@@ -273,13 +275,13 @@ export function parseChat(c) {
273
275
  last_name: String(c.last_name ?? ""),
274
276
  };
275
277
  }
276
- export function parsePhotoSizes(p) {
278
+ function parsePhotoSizes(p) {
277
279
  if (!Array.isArray(p)) {
278
280
  return void 0;
279
281
  }
280
282
  return p.map(parsePhotoSize);
281
283
  }
282
- export function parsePhotoSize(p) {
284
+ function parsePhotoSize(p) {
283
285
  return {
284
286
  file_id: String(p.file_id),
285
287
  file_unique_id: String(p.file_unique_id),
@@ -288,7 +290,7 @@ export function parsePhotoSize(p) {
288
290
  height: Number(p.height),
289
291
  };
290
292
  }
291
- export function parseSticker(v) {
293
+ function parseSticker(v) {
292
294
  return {
293
295
  file_id: String(v.file_id),
294
296
  width: Number(v.width),
@@ -298,7 +300,7 @@ export function parseSticker(v) {
298
300
  emoji: String(v.emoji),
299
301
  };
300
302
  }
301
- export function parseVideo(v) {
303
+ function parseVideo(v) {
302
304
  return {
303
305
  file_id: String(v.file_id),
304
306
  width: Number(v.width),
@@ -310,7 +312,7 @@ export function parseVideo(v) {
310
312
  file_size: Number(v.file_size ?? ""),
311
313
  };
312
314
  }
313
- export function parseVoice(v) {
315
+ function parseVoice(v) {
314
316
  return {
315
317
  file_id: String(v.file_id),
316
318
  file_size: Number(v.file_size),
@@ -318,7 +320,7 @@ export function parseVoice(v) {
318
320
  mime_type: String(v.mime_type)
319
321
  };
320
322
  }
321
- export function parseVideoNote(v) {
323
+ function parseVideoNote(v) {
322
324
  return {
323
325
  file_id: String(v.file_id),
324
326
  length: Number(v.length),
@@ -326,7 +328,7 @@ export function parseVideoNote(v) {
326
328
  thumb: v.thumb ? parsePhotoSize(v.thumb) : void 0,
327
329
  };
328
330
  }
329
- export function parseEntities(v) {
331
+ function parseEntities(v) {
330
332
  if (!Array.isArray(v)) {
331
333
  return [];
332
334
  }
@@ -340,7 +342,7 @@ export function parseEntities(v) {
340
342
  };
341
343
  });
342
344
  }
343
- export function parseAudio(v) {
345
+ function parseAudio(v) {
344
346
  return {
345
347
  file_id: String(v.file_id),
346
348
  duration: Number(v.duration),
@@ -350,7 +352,7 @@ export function parseAudio(v) {
350
352
  mime_type: String(v.mime_type ?? ""),
351
353
  };
352
354
  }
353
- export function parseDocument(v) {
355
+ function parseDocument(v) {
354
356
  return {
355
357
  file_id: String(v.file_id),
356
358
  file_name: String(v.file_name || ""),
@@ -358,7 +360,7 @@ export function parseDocument(v) {
358
360
  file_size: Number(v.file_size || 0),
359
361
  };
360
362
  }
361
- export function parseAnimation(v) {
363
+ function parseAnimation(v) {
362
364
  return {
363
365
  file_id: String(v.file_id),
364
366
  width: Number(v.width),
@@ -370,7 +372,7 @@ export function parseAnimation(v) {
370
372
  thumbnail: v.thumbnail ? parsePhotoSize(v.thumbnail) : void 0,
371
373
  };
372
374
  }
373
- export function parseContact(v) {
375
+ function parseContact(v) {
374
376
  return {
375
377
  phone_number: String(v.phone_number),
376
378
  first_name: String(v.first_name),
@@ -379,13 +381,13 @@ export function parseContact(v) {
379
381
  vcard: String(v.vcard ?? ""),
380
382
  };
381
383
  }
382
- export function parseLocation(v) {
384
+ function parseLocation(v) {
383
385
  return {
384
386
  longitude: Number(v.longitude),
385
387
  latitude: Number(v.latitude),
386
388
  };
387
389
  }
388
- export function parseVenue(v) {
390
+ function parseVenue(v) {
389
391
  return {
390
392
  location: parseLocation(v.location),
391
393
  title: String(v.title),
@@ -396,7 +398,7 @@ export function parseVenue(v) {
396
398
  google_place_type: String(v.google_place_type ?? ""),
397
399
  };
398
400
  }
399
- export function parsePoll(v) {
401
+ function parsePoll(v) {
400
402
  return {
401
403
  id: String(v.id),
402
404
  question: String(v.question),
@@ -404,10 +406,10 @@ export function parsePoll(v) {
404
406
  is_closed: Boolean(v.is_closed),
405
407
  };
406
408
  }
407
- export function parsePollOptions(v) {
409
+ function parsePollOptions(v) {
408
410
  return Array.isArray(v) ? v.map(parsePollOption) : [];
409
411
  }
410
- export function parsePollOption(v) {
412
+ function parsePollOption(v) {
411
413
  return {
412
414
  text: String(v.text),
413
415
  voter_count: Number(v.voter_count),
@@ -416,7 +418,7 @@ export function parsePollOption(v) {
416
418
  /**
417
419
  * @see https://core.telegram.org/bots/api#callbackquery
418
420
  */
419
- export function parseCallbackQuery(v) {
421
+ function parseCallbackQuery(v) {
420
422
  if (!v) {
421
423
  return;
422
424
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telegram-bot-api-nodejs",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "Telegram Bot API client for nodejs",
5
5
  "type": "module",
6
6
  "main": "index.js",