telegram-bot-api-nodejs 1.0.78 → 1.2.1

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 +9 -1
  2. package/index.js +30 -26
  3. package/package.json +7 -5
package/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export interface SendBasicOptions {
15
15
  chat_id: number | string;
16
16
  business_connection_id?: string;
17
17
  message_thread_id?: number;
18
+ direct_messages_topic_id?: number;
18
19
  disable_notification?: boolean;
19
20
  reply_to_message_id?: number | string;
20
21
  reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply;
@@ -198,7 +199,6 @@ export interface Chat {
198
199
  username?: string;
199
200
  first_name?: string;
200
201
  last_name?: string;
201
- is_forum?: boolean;
202
202
  photo?: ChatPhoto;
203
203
  bio?: string;
204
204
  description?: string;
@@ -207,6 +207,8 @@ export interface Chat {
207
207
  permissions?: ChatPermissions;
208
208
  can_set_sticker_set?: boolean;
209
209
  sticker_set_name?: string;
210
+ is_forum?: string;
211
+ is_direct_messages?: boolean;
210
212
  }
211
213
  export interface WriteAccessAllowed {
212
214
  from_request?: boolean;
@@ -284,6 +286,7 @@ export interface VideoChatParticipantsInvited {
284
286
  export interface Message {
285
287
  message_id: number;
286
288
  message_thread_id?: number;
289
+ direct_messages_topic?: DirectMessagesTopic;
287
290
  from?: User;
288
291
  sender_business_bot?: User;
289
292
  date: number;
@@ -587,6 +590,10 @@ export interface Poll {
587
590
  options: PollOption[];
588
591
  is_closed: boolean;
589
592
  }
593
+ export interface DirectMessagesTopic {
594
+ topic_id: string;
595
+ user?: User;
596
+ }
590
597
  export interface UserProfilePhotos {
591
598
  total_count: number;
592
599
  photos: PhotoSize[][];
@@ -1170,6 +1177,7 @@ export declare function isWebpageCurlFailedError(err: unknown): boolean;
1170
1177
  export declare function isWrongFileUrlError(err: unknown): boolean;
1171
1178
  export declare function isBadGatewayError(err: unknown): boolean;
1172
1179
  export declare function isMessageToEditNotFoundError(err: unknown): boolean;
1180
+ export declare function isMessageToDeleteNotFoundError(err: unknown): boolean;
1173
1181
  export declare function isMessageNotModifiedError(err: unknown): boolean;
1174
1182
  export declare function isWrongTypeOfTheWebPageContentError(err: unknown): boolean;
1175
1183
  export declare function isFailToGetHTTPURLContentError(err: unknown): boolean;
package/index.js CHANGED
@@ -12,7 +12,7 @@ export function setWebhook(token, body, signal) {
12
12
  body: JSON.stringify(body),
13
13
  headers,
14
14
  signal
15
- }).then((parseResponse));
15
+ }).then(parseResponse);
16
16
  }
17
17
  export function deleteWebhook(token, params, signal) {
18
18
  return fetch(`https://api.telegram.org/bot${token}/deleteWebhook`, {
@@ -20,7 +20,7 @@ export function deleteWebhook(token, params, signal) {
20
20
  body: JSON.stringify(params),
21
21
  headers,
22
22
  signal
23
- }).then((parseResponse));
23
+ }).then(parseResponse);
24
24
  }
25
25
  /** @todo cehck if response is the same as in typings */
26
26
  export function getWebhookInfo(token, signal) {
@@ -29,7 +29,7 @@ export function getWebhookInfo(token, signal) {
29
29
  body: JSON.stringify({}),
30
30
  headers,
31
31
  signal
32
- }).then((parseResponse));
32
+ }).then(parseResponse);
33
33
  }
34
34
  export function getMe(token, signal) {
35
35
  return fetch(`https://api.telegram.org/bot${token}/getMe`, {
@@ -37,7 +37,7 @@ export function getMe(token, signal) {
37
37
  body: JSON.stringify({}),
38
38
  headers,
39
39
  signal
40
- }).then((parseResponse));
40
+ }).then(parseResponse);
41
41
  }
42
42
  export function sendMessage(token, payload, signal) {
43
43
  return fetch(`https://api.telegram.org/bot${token}/sendMessage`, {
@@ -45,7 +45,7 @@ export function sendMessage(token, payload, signal) {
45
45
  body: JSON.stringify(payload),
46
46
  headers,
47
47
  signal
48
- }).then((parseResponse));
48
+ }).then(parseResponse);
49
49
  }
50
50
  export function editMessageText(token, payload, signal) {
51
51
  return fetch(`https://api.telegram.org/bot${token}/editMessageText`, {
@@ -53,7 +53,7 @@ export function editMessageText(token, payload, signal) {
53
53
  body: JSON.stringify(payload),
54
54
  headers,
55
55
  signal
56
- }).then((parseResponse));
56
+ }).then(parseResponse);
57
57
  }
58
58
  export function deleteMessage(token, payload, signal) {
59
59
  return fetch(`https://api.telegram.org/bot${token}/deleteMessage`, {
@@ -61,7 +61,7 @@ export function deleteMessage(token, payload, signal) {
61
61
  body: JSON.stringify(payload),
62
62
  headers,
63
63
  signal
64
- }).then((parseResponse));
64
+ }).then(parseResponse);
65
65
  }
66
66
  export function sendPhoto(token, payload, signal) {
67
67
  return fetch(`https://api.telegram.org/bot${token}/sendPhoto`, {
@@ -69,7 +69,7 @@ export function sendPhoto(token, payload, signal) {
69
69
  body: JSON.stringify(payload),
70
70
  headers,
71
71
  signal
72
- }).then((parseResponse));
72
+ }).then(parseResponse);
73
73
  }
74
74
  export function sendAudio(token, payload, signal) {
75
75
  return fetch(`https://api.telegram.org/bot${token}/sendAudio`, {
@@ -77,7 +77,7 @@ export function sendAudio(token, payload, signal) {
77
77
  body: JSON.stringify(payload),
78
78
  headers,
79
79
  signal
80
- }).then((parseResponse));
80
+ }).then(parseResponse);
81
81
  }
82
82
  export function sendAnimation(token, payload, signal) {
83
83
  return fetch(`https://api.telegram.org/bot${token}/sendAnimation`, {
@@ -85,7 +85,7 @@ export function sendAnimation(token, payload, signal) {
85
85
  body: JSON.stringify(payload),
86
86
  headers,
87
87
  signal
88
- }).then((parseResponse));
88
+ }).then(parseResponse);
89
89
  }
90
90
  /**
91
91
  * @example
@@ -117,7 +117,7 @@ export function sendDocument(token, payload, signal) {
117
117
  body: b,
118
118
  headers: h,
119
119
  signal
120
- }).then((parseResponse));
120
+ }).then(parseResponse);
121
121
  }
122
122
  export function sendVideo(token, payload, signal) {
123
123
  return fetch(`https://api.telegram.org/bot${token}/sendVideo`, {
@@ -125,7 +125,7 @@ export function sendVideo(token, payload, signal) {
125
125
  body: JSON.stringify(payload),
126
126
  headers,
127
127
  signal
128
- }).then((parseResponse));
128
+ }).then(parseResponse);
129
129
  }
130
130
  export function sendVoice(token, payload, signal) {
131
131
  return fetch(`https://api.telegram.org/bot${token}/sendVoice`, {
@@ -133,7 +133,7 @@ export function sendVoice(token, payload, signal) {
133
133
  body: JSON.stringify(payload),
134
134
  headers,
135
135
  signal
136
- }).then((parseResponse));
136
+ }).then(parseResponse);
137
137
  }
138
138
  export function sendMediaGroup(token, payload, signal) {
139
139
  return fetch(`https://api.telegram.org/bot${token}/sendMediaGroup`, {
@@ -141,7 +141,7 @@ export function sendMediaGroup(token, payload, signal) {
141
141
  body: JSON.stringify(payload),
142
142
  headers,
143
143
  signal
144
- }).then((parseResponse));
144
+ }).then(parseResponse);
145
145
  }
146
146
  export function setMessageReaction(token, payload, signal) {
147
147
  return fetch(`https://api.telegram.org/bot${token}/setMessageReaction`, {
@@ -149,7 +149,7 @@ export function setMessageReaction(token, payload, signal) {
149
149
  body: JSON.stringify(payload),
150
150
  headers,
151
151
  signal
152
- }).then((parseResponse));
152
+ }).then(parseResponse);
153
153
  }
154
154
  export function getUserProfilePhotos(token, payload, signal) {
155
155
  return fetch(`https://api.telegram.org/bot${token}/getUserProfilePhotos`, {
@@ -157,7 +157,7 @@ export function getUserProfilePhotos(token, payload, signal) {
157
157
  body: JSON.stringify(payload),
158
158
  headers,
159
159
  signal
160
- }).then((parseResponse));
160
+ }).then(parseResponse);
161
161
  }
162
162
  export function getFile(token, payload, signal) {
163
163
  return fetch(`https://api.telegram.org/bot${token}/getFile`, {
@@ -165,7 +165,7 @@ export function getFile(token, payload, signal) {
165
165
  body: JSON.stringify(payload),
166
166
  headers,
167
167
  signal
168
- }).then((parseResponse));
168
+ }).then(parseResponse);
169
169
  }
170
170
  export function answerCallbackQuery(token, payload, signal) {
171
171
  return fetch(`https://api.telegram.org/bot${token}/answerCallbackQuery`, {
@@ -173,7 +173,7 @@ export function answerCallbackQuery(token, payload, signal) {
173
173
  body: JSON.stringify(payload),
174
174
  headers,
175
175
  signal
176
- }).then((parseResponse));
176
+ }).then(parseResponse);
177
177
  }
178
178
  export function leaveChat(token, payload, signal) {
179
179
  return fetch(`https://api.telegram.org/bot${token}/leaveChat`, {
@@ -181,7 +181,7 @@ export function leaveChat(token, payload, signal) {
181
181
  body: JSON.stringify(payload),
182
182
  headers,
183
183
  signal
184
- }).then((parseResponse));
184
+ }).then(parseResponse);
185
185
  }
186
186
  export function getChat(token, payload, signal) {
187
187
  return fetch(`https://api.telegram.org/bot${token}/getChat`, {
@@ -189,7 +189,7 @@ export function getChat(token, payload, signal) {
189
189
  body: JSON.stringify(payload),
190
190
  headers,
191
191
  signal
192
- }).then((parseResponse));
192
+ }).then(parseResponse);
193
193
  }
194
194
  export function getChatMember(token, payload, signal) {
195
195
  return fetch(`https://api.telegram.org/bot${token}/getChatMember`, {
@@ -197,7 +197,7 @@ export function getChatMember(token, payload, signal) {
197
197
  body: JSON.stringify(payload),
198
198
  headers,
199
199
  signal: signal
200
- }).then((parseResponse));
200
+ }).then(parseResponse);
201
201
  }
202
202
  export function setMyCommands(token, payload, signal) {
203
203
  return fetch(`https://api.telegram.org/bot${token}/setMyCommands`, {
@@ -205,7 +205,7 @@ export function setMyCommands(token, payload, signal) {
205
205
  body: JSON.stringify(payload),
206
206
  headers,
207
207
  signal
208
- }).then((parseResponse));
208
+ }).then(parseResponse);
209
209
  }
210
210
  export function getMyCommands(token, payload, signal) {
211
211
  return fetch(`https://api.telegram.org/bot${token}/getMyCommands`, {
@@ -213,7 +213,7 @@ export function getMyCommands(token, payload, signal) {
213
213
  body: JSON.stringify(payload),
214
214
  headers,
215
215
  signal
216
- }).then((parseResponse));
216
+ }).then(parseResponse);
217
217
  }
218
218
  export function deleteMyCommands(token, payload, signal) {
219
219
  return fetch(`https://api.telegram.org/bot${token}/deleteMyCommands`, {
@@ -221,7 +221,7 @@ export function deleteMyCommands(token, payload, signal) {
221
221
  body: JSON.stringify(payload),
222
222
  headers,
223
223
  signal
224
- }).then((parseResponse));
224
+ }).then(parseResponse);
225
225
  }
226
226
  export function getBusinessConnection(token, payload, signal) {
227
227
  return fetch(`https://api.telegram.org/bot${token}/getBusinessConnection`, {
@@ -229,7 +229,7 @@ export function getBusinessConnection(token, payload, signal) {
229
229
  body: JSON.stringify(payload),
230
230
  headers,
231
231
  signal
232
- }).then((parseResponse));
232
+ }).then(parseResponse);
233
233
  }
234
234
  /**
235
235
  * Parsers
@@ -608,6 +608,9 @@ export function isBadGatewayError(err) {
608
608
  export function isMessageToEditNotFoundError(err) {
609
609
  return err instanceof Error && err.message === "Bad Request: message to edit not found";
610
610
  }
611
+ export function isMessageToDeleteNotFoundError(err) {
612
+ return err instanceof Error && err.message === "Bad Request: message to delete not found";
613
+ }
611
614
  // Bad Request: message is not modified: specified new message content and reply markup are exactly the same as a specified new message content and reply markup are exactly the same as a current content and reply markup of the message
612
615
  // Bad Request: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message
613
616
  export function isMessageNotModifiedError(err) {
@@ -685,7 +688,8 @@ export function removeTokenFromUrl(url) {
685
688
  return `bot${botId}:${"*".repeat(token.length)}`;
686
689
  });
687
690
  }
688
- export var currencies;
691
+ export { currencies };
692
+ var currencies;
689
693
  (function (currencies_1) {
690
694
  const __dirname = import.meta.dirname;
691
695
  let currencies = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telegram-bot-api-nodejs",
3
- "version": "1.0.78",
3
+ "version": "1.2.1",
4
4
  "description": "Telegram Bot API client for nodejs",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -16,8 +16,8 @@
16
16
  ],
17
17
  "scripts": {
18
18
  "prepublishOnly": "npm run build && npm run test && npm run spec",
19
- "build": "tsc",
20
- "watch": "tsc --watch",
19
+ "build": "tsgo",
20
+ "watch": "tsgo --watch",
21
21
  "test": "node --test",
22
22
  "spec": "node --test spec.js",
23
23
  "sync": "wget -O currencies.json https://core.telegram.org/bots/payments/currencies.json"
@@ -25,7 +25,9 @@
25
25
  "author": "",
26
26
  "license": "ISC",
27
27
  "devDependencies": {
28
- "@types/node": "^22.15.17",
29
- "typescript": "^5.8.3"
28
+ "@types/node": "^22.15.17"
29
+ },
30
+ "dependencies": {
31
+ "@typescript/native-preview": "^7.0.0-dev.20251013.1"
30
32
  }
31
33
  }