telegram-bot-api-nodejs 1.2.0 → 1.2.2
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 +2 -0
- package/index.js +34 -26
- package/package.json +7 -5
package/index.d.ts
CHANGED
|
@@ -1177,11 +1177,13 @@ export declare function isWebpageCurlFailedError(err: unknown): boolean;
|
|
|
1177
1177
|
export declare function isWrongFileUrlError(err: unknown): boolean;
|
|
1178
1178
|
export declare function isBadGatewayError(err: unknown): boolean;
|
|
1179
1179
|
export declare function isMessageToEditNotFoundError(err: unknown): boolean;
|
|
1180
|
+
export declare function isMessageToDeleteNotFoundError(err: unknown): boolean;
|
|
1180
1181
|
export declare function isMessageNotModifiedError(err: unknown): boolean;
|
|
1181
1182
|
export declare function isWrongTypeOfTheWebPageContentError(err: unknown): boolean;
|
|
1182
1183
|
export declare function isFailToGetHTTPURLContentError(err: unknown): boolean;
|
|
1183
1184
|
export declare function isWrongFileIdentifierError(err: unknown): boolean;
|
|
1184
1185
|
export declare function isInvalidFileUrlSpecifiedError(err: unknown): boolean;
|
|
1186
|
+
export declare function isMessageDeleteError(err: unknown): boolean;
|
|
1185
1187
|
export declare function parseRetryAfterTime(err: unknown): number;
|
|
1186
1188
|
export declare function resolveNameFromMessageOrigin(messageOrigin: MessageOrigin): string;
|
|
1187
1189
|
export declare function resolveChatName(chat: any): string;
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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) {
|
|
@@ -629,6 +632,10 @@ export function isWrongFileIdentifierError(err) {
|
|
|
629
632
|
export function isInvalidFileUrlSpecifiedError(err) {
|
|
630
633
|
return err instanceof Error && err.message.includes("invalid file HTTP URL specified: Unsupported URL protocol");
|
|
631
634
|
}
|
|
635
|
+
// Bad Request: message can't be deleted
|
|
636
|
+
export function isMessageDeleteError(err) {
|
|
637
|
+
return err instanceof Error && err.message.includes("message can't be deleted");
|
|
638
|
+
}
|
|
632
639
|
export function parseRetryAfterTime(err) {
|
|
633
640
|
if (!(err instanceof Error)) {
|
|
634
641
|
throw new RangeError("`err` needs to be an Error");
|
|
@@ -685,7 +692,8 @@ export function removeTokenFromUrl(url) {
|
|
|
685
692
|
return `bot${botId}:${"*".repeat(token.length)}`;
|
|
686
693
|
});
|
|
687
694
|
}
|
|
688
|
-
export
|
|
695
|
+
export { currencies };
|
|
696
|
+
var currencies;
|
|
689
697
|
(function (currencies_1) {
|
|
690
698
|
const __dirname = import.meta.dirname;
|
|
691
699
|
let currencies = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "telegram-bot-api-nodejs",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
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": "
|
|
20
|
-
"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": "^
|
|
29
|
-
|
|
28
|
+
"@types/node": "^24.10.0"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@typescript/native-preview": "^7.0.0-dev.20251104.1"
|
|
30
32
|
}
|
|
31
33
|
}
|