telegram-bot-api-nodejs 1.0.47 → 1.0.49
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 +4 -0
- package/index.js +14 -1
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -1073,6 +1073,9 @@ export declare function getFile(token: string, payload: {
|
|
|
1073
1073
|
file_id: string;
|
|
1074
1074
|
}, signal: AbortSignal): Promise<File>;
|
|
1075
1075
|
export declare function answerCallbackQuery(token: string, payload: AnswerCallbackQueryOptions, signal: AbortSignal): Promise<File>;
|
|
1076
|
+
export declare function leaveChat(token: string, payload: {
|
|
1077
|
+
chat_id: string;
|
|
1078
|
+
}, signal: AbortSignal): Promise<true>;
|
|
1076
1079
|
export declare function getChat(token: string, payload: {
|
|
1077
1080
|
chat_id: string;
|
|
1078
1081
|
}, signal: AbortSignal): Promise<Chat>;
|
|
@@ -1116,6 +1119,7 @@ export declare function isWrongFileUrlError(err: unknown): boolean;
|
|
|
1116
1119
|
export declare function parseRetryAfterTime(err: unknown): number;
|
|
1117
1120
|
export declare function resolveNameFromMessageOrigin(messageOrigin: MessageOrigin): string;
|
|
1118
1121
|
export declare function resolveChatName(chat: any): string;
|
|
1122
|
+
export declare function removeTokenFromUrl(url: string): string;
|
|
1119
1123
|
export declare namespace currencies {
|
|
1120
1124
|
interface Currency {
|
|
1121
1125
|
code: string;
|
package/index.js
CHANGED
|
@@ -151,6 +151,14 @@ export function answerCallbackQuery(token, payload, signal) {
|
|
|
151
151
|
signal
|
|
152
152
|
}).then((parseResponse));
|
|
153
153
|
}
|
|
154
|
+
export function leaveChat(token, payload, signal) {
|
|
155
|
+
return fetch(`https://api.telegram.org/bot${token}/leaveChat`, {
|
|
156
|
+
method: "POST",
|
|
157
|
+
body: JSON.stringify(payload),
|
|
158
|
+
headers,
|
|
159
|
+
signal
|
|
160
|
+
}).then((parseResponse));
|
|
161
|
+
}
|
|
154
162
|
export function getChat(token, payload, signal) {
|
|
155
163
|
return fetch(`https://api.telegram.org/bot${token}/getChat`, {
|
|
156
164
|
method: "POST",
|
|
@@ -527,7 +535,7 @@ export function parseResponse(response) {
|
|
|
527
535
|
const description = String(data.description ?? "");
|
|
528
536
|
const parameters = Object.assign(data.parameters || {}, {
|
|
529
537
|
text,
|
|
530
|
-
url: response.url
|
|
538
|
+
url: removeTokenFromUrl(response.url)
|
|
531
539
|
});
|
|
532
540
|
throw new TelegramError(description, error_code, parameters);
|
|
533
541
|
});
|
|
@@ -629,6 +637,11 @@ export function resolveChatName(chat) {
|
|
|
629
637
|
`${chat.title}`.trim() ||
|
|
630
638
|
`@${chat.username || ""}`.trim();
|
|
631
639
|
}
|
|
640
|
+
export function removeTokenFromUrl(url) {
|
|
641
|
+
return String(url).replace(/bot([\d]+)\:([^\/]+)/ig, function (match, botId, token) {
|
|
642
|
+
return `bot${botId}:${"*".repeat(token.length)}`;
|
|
643
|
+
});
|
|
644
|
+
}
|
|
632
645
|
export var currencies;
|
|
633
646
|
(function (currencies_1) {
|
|
634
647
|
const __dirname = import.meta.dirname;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "telegram-bot-api-nodejs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.49",
|
|
4
4
|
"description": "Telegram Bot API client for nodejs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"README.md"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"prepublishOnly": "npm run build",
|
|
18
|
+
"prepublishOnly": "npm run build && node --test",
|
|
19
19
|
"build": "tsc",
|
|
20
20
|
"watch": "tsc --watch",
|
|
21
21
|
"pretest": "npm run build",
|