@aracna/telegram-bot 1.9.8 → 1.9.10
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 +6 -6
- package/modules/api.d.ts +4 -4
- package/modules/api.js +3 -3
- package/modules/telegram.js +1 -1
- package/package.json +18 -15
- package/utils/html.utils.d.ts +1 -1
- package/utils/html.utils.js +3 -3
package/index.d.ts
CHANGED
|
@@ -5,8 +5,6 @@ import { AnswerCallbackQuery } from '@aracna/telegram-bot-types';
|
|
|
5
5
|
import { AnswerInlineQuery } from '@aracna/telegram-bot-types';
|
|
6
6
|
import { AnswerPreCheckoutQuery } from '@aracna/telegram-bot-types';
|
|
7
7
|
import { AnswerShippingQuery } from '@aracna/telegram-bot-types';
|
|
8
|
-
import { API as API_2 } from '@aracna/core';
|
|
9
|
-
import { APIConfig } from '@aracna/core';
|
|
10
8
|
import { BanChatMember } from '@aracna/telegram-bot-types';
|
|
11
9
|
import { BotCommand } from '@aracna/telegram-bot-types';
|
|
12
10
|
import { CallbackQuery as CallbackQuery_2 } from '@aracna/telegram-bot-types';
|
|
@@ -50,6 +48,8 @@ import { PollAnswer } from '@aracna/telegram-bot-types';
|
|
|
50
48
|
import { PreCheckoutQuery } from '@aracna/telegram-bot-types';
|
|
51
49
|
import { PromoteChatMember } from '@aracna/telegram-bot-types';
|
|
52
50
|
import { RequestMethod } from '@aracna/core';
|
|
51
|
+
import { RestAPI } from '@aracna/core';
|
|
52
|
+
import { RestApiConfig } from '@aracna/core';
|
|
53
53
|
import { RestrictChatMember } from '@aracna/telegram-bot-types';
|
|
54
54
|
import { SendAnimation } from '@aracna/telegram-bot-types';
|
|
55
55
|
import { SendAudio } from '@aracna/telegram-bot-types';
|
|
@@ -97,9 +97,9 @@ declare class Answer extends Child {
|
|
|
97
97
|
shippingQuery(id: string, ok: boolean, parameters?: Partial<AnswerShippingQuery>): Promise<boolean | FetchError>;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
declare class API extends
|
|
101
|
-
post<V, W, X = undefined>(path: string, body?: W, config?:
|
|
102
|
-
transformBody<V>(method: RequestMethod, path: string, body: V, config:
|
|
100
|
+
declare class API extends RestAPI {
|
|
101
|
+
post<V, W, X = undefined>(path: string, body?: W, config?: RestApiConfig<void>): Promise<V | FetchError<X>>;
|
|
102
|
+
transformBody<V>(method: RequestMethod, path: string, body: V, config: RestApiConfig<void>): Promise<FormData>;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
declare class Ban extends Child {
|
|
@@ -273,7 +273,7 @@ export declare interface HandlerOptions {
|
|
|
273
273
|
export declare class HTMLUtils {
|
|
274
274
|
static tags: string[];
|
|
275
275
|
static sanitize(text: string): string;
|
|
276
|
-
static progress(value: number,
|
|
276
|
+
static progress(value: number, min?: number, max?: number, size?: number): string;
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
export declare class InlineKeyboardUtils {
|
package/modules/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class API extends
|
|
3
|
-
post<V, W, X = undefined>(path: string, body?: W, config?:
|
|
4
|
-
transformBody<V>(method: RequestMethod, path: string, body: V, config:
|
|
1
|
+
import { FetchError, RequestMethod, RestAPI, RestApiConfig } from '@aracna/core';
|
|
2
|
+
export declare class API extends RestAPI {
|
|
3
|
+
post<V, W, X = undefined>(path: string, body?: W, config?: RestApiConfig<void>): Promise<V | FetchError<X>>;
|
|
4
|
+
transformBody<V>(method: RequestMethod, path: string, body: V, config: RestApiConfig<void>): Promise<FormData>;
|
|
5
5
|
}
|
package/modules/api.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.API = void 0;
|
|
4
4
|
const core_1 = require("@aracna/core");
|
|
5
|
-
class API extends core_1.
|
|
5
|
+
class API extends core_1.RestAPI {
|
|
6
6
|
async post(path, body, config) {
|
|
7
7
|
let response;
|
|
8
|
-
response = await this.
|
|
8
|
+
response = await this.post(path, body, config);
|
|
9
9
|
if (response instanceof Error)
|
|
10
10
|
return response;
|
|
11
11
|
return response.data.result;
|
|
@@ -14,7 +14,7 @@ class API extends core_1.API {
|
|
|
14
14
|
switch (method) {
|
|
15
15
|
case 'GET':
|
|
16
16
|
case 'POST':
|
|
17
|
-
await (0, core_1.useNodeFetch)(await (0, core_1.
|
|
17
|
+
await (0, core_1.useNodeFetch)(await (0, core_1.importNodeFetch)());
|
|
18
18
|
return (0, core_1.serializeFormData)(typeof body === 'object' ? body : {});
|
|
19
19
|
default:
|
|
20
20
|
return (0, core_1.serializeFormData)({});
|
package/modules/telegram.js
CHANGED
|
@@ -113,7 +113,7 @@ class Telegram {
|
|
|
113
113
|
let handler, potential;
|
|
114
114
|
handler = dummy_1.Dummy.handler;
|
|
115
115
|
handler.description = description;
|
|
116
|
-
handler.id = core_1.
|
|
116
|
+
handler.id = (0, core_1.generateRandomString)({ blacklist: this.handlerIDs });
|
|
117
117
|
handler.key = key;
|
|
118
118
|
handler.middleware = middleware;
|
|
119
119
|
handler.type = type;
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Dario Sechi",
|
|
3
3
|
"devDependencies": {
|
|
4
|
-
"@aracna/core": "^1.1.
|
|
5
|
-
"@aracna/telegram-bot-types": "^1.2.
|
|
6
|
-
"@microsoft/api-extractor": "^7.
|
|
7
|
-
"@
|
|
8
|
-
"@vitest/
|
|
4
|
+
"@aracna/core": "^1.1.75",
|
|
5
|
+
"@aracna/telegram-bot-types": "^1.2.9",
|
|
6
|
+
"@microsoft/api-extractor": "^7.39.0",
|
|
7
|
+
"@types/node": "^20.10.5",
|
|
8
|
+
"@vitest/coverage-v8": "^1.1.0",
|
|
9
|
+
"@vitest/ui": "^1.1.0",
|
|
9
10
|
"dotenv": "^16.3.1",
|
|
10
|
-
"fastify": "^4.
|
|
11
|
-
"typescript": "^5.
|
|
12
|
-
"vitest": "^
|
|
11
|
+
"fastify": "^4.25.1",
|
|
12
|
+
"typescript": "^5.3.3",
|
|
13
|
+
"vitest": "^1.1.0"
|
|
13
14
|
},
|
|
14
15
|
"license": "MIT",
|
|
15
16
|
"main": "index.js",
|
|
@@ -18,12 +19,14 @@
|
|
|
18
19
|
"@aracna/core": ">= 1.1.12",
|
|
19
20
|
"@aracna/telegram-bot-types": ">= 1.2.0"
|
|
20
21
|
},
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"build": "rm -rf dist && yarn tsc && yarn api-extractor run --local",
|
|
24
|
-
"tarball": "yarn version && cp LICENSE package.json README.md dist/. && cd dist && yarn pack",
|
|
25
|
-
"deploy": "yarn test && yarn build && yarn tarball && yarn publish dist/*.tgz && git push"
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"directory": "dist"
|
|
26
24
|
},
|
|
27
25
|
"types": "index.d.ts",
|
|
28
|
-
"version": "1.9.
|
|
29
|
-
|
|
26
|
+
"version": "1.9.10",
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "rm -rf dist && pnpm tsc && pnpm api-extractor run --local",
|
|
29
|
+
"prepublish": "pnpm test && pnpm build && pnpm version patch && cp LICENSE package.json README.md dist",
|
|
30
|
+
"test": "vitest run"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/utils/html.utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare class HTMLUtils {
|
|
2
2
|
static tags: string[];
|
|
3
3
|
static sanitize(text: string): string;
|
|
4
|
-
static progress(value: number,
|
|
4
|
+
static progress(value: number, min?: number, max?: number, size?: number): string;
|
|
5
5
|
}
|
package/utils/html.utils.js
CHANGED
|
@@ -10,10 +10,10 @@ class HTMLUtils {
|
|
|
10
10
|
.replace(new RegExp(`(?<!(${this.tags.join('|')}))>`, 'gm'), '>')
|
|
11
11
|
.replace(/&/gm, '&');
|
|
12
12
|
}
|
|
13
|
-
static progress(value,
|
|
13
|
+
static progress(value, min = 0, max = 100, size = 20) {
|
|
14
14
|
let percentage, steps;
|
|
15
|
-
percentage = (0, core_1.getNumberPercentage)(value,
|
|
16
|
-
steps = new Array(size).fill(0).map((v, k) => ((k *
|
|
15
|
+
percentage = (0, core_1.getNumberPercentage)(value, { min, max });
|
|
16
|
+
steps = new Array(size).fill(0).map((v, k) => ((k * max) / size < percentage ? '=' : ' '));
|
|
17
17
|
return `<code>[${steps.join('')}]</code>`;
|
|
18
18
|
}
|
|
19
19
|
}
|