nyx-bot-client 0.0.3 → 0.0.5
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/biome.json +1 -1
- package/bun.lock +21 -36
- package/cron/actions-server.ts +5 -7
- package/nyx-client.ts +5 -8
- package/package.json +7 -8
- package/types.d.ts +2 -2
- package/utils/actions.ts +4 -4
- package/utils/methods.ts +38 -17
- package/utils/table.ts +4 -5
package/biome.json
CHANGED
package/bun.lock
CHANGED
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
"": {
|
|
5
5
|
"name": "nyx-bot-client",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@biomejs/biome": "^2.
|
|
8
|
-
"@types/node": "^24.
|
|
9
|
-
"dotenv": "^17.2.
|
|
10
|
-
"kysely": "^0.28.
|
|
11
|
-
"mysql2": "^3.15.
|
|
12
|
-
"redis": "^5.8.2",
|
|
7
|
+
"@biomejs/biome": "^2.3.5",
|
|
8
|
+
"@types/node": "^24.10.1",
|
|
9
|
+
"dotenv": "^17.2.3",
|
|
10
|
+
"kysely": "^0.28.8",
|
|
11
|
+
"mysql2": "^3.15.3",
|
|
13
12
|
"ts-debounce": "^4.0.0",
|
|
14
|
-
"zod": "^4.1.
|
|
13
|
+
"zod": "^4.1.12",
|
|
15
14
|
},
|
|
16
15
|
"devDependencies": {
|
|
17
16
|
"@types/bun": "latest",
|
|
@@ -22,47 +21,35 @@
|
|
|
22
21
|
},
|
|
23
22
|
},
|
|
24
23
|
"packages": {
|
|
25
|
-
"@biomejs/biome": ["@biomejs/biome@2.
|
|
24
|
+
"@biomejs/biome": ["@biomejs/biome@2.3.5", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.3.5", "@biomejs/cli-darwin-x64": "2.3.5", "@biomejs/cli-linux-arm64": "2.3.5", "@biomejs/cli-linux-arm64-musl": "2.3.5", "@biomejs/cli-linux-x64": "2.3.5", "@biomejs/cli-linux-x64-musl": "2.3.5", "@biomejs/cli-win32-arm64": "2.3.5", "@biomejs/cli-win32-x64": "2.3.5" }, "bin": { "biome": "bin/biome" } }, "sha512-HvLhNlIlBIbAV77VysRIBEwp55oM/QAjQEin74QQX9Xb259/XP/D5AGGnZMOyF1el4zcvlNYYR3AyTMUV3ILhg=="],
|
|
26
25
|
|
|
27
|
-
"@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.
|
|
26
|
+
"@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.3.5", "", { "os": "darwin", "cpu": "arm64" }, "sha512-fLdTur8cJU33HxHUUsii3GLx/TR0BsfQx8FkeqIiW33cGMtUD56fAtrh+2Fx1uhiCsVZlFh6iLKUU3pniZREQw=="],
|
|
28
27
|
|
|
29
|
-
"@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.
|
|
28
|
+
"@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.3.5", "", { "os": "darwin", "cpu": "x64" }, "sha512-qpT8XDqeUlzrOW8zb4k3tjhT7rmvVRumhi2657I2aGcY4B+Ft5fNwDdZGACzn8zj7/K1fdWjgwYE3i2mSZ+vOA=="],
|
|
30
29
|
|
|
31
|
-
"@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.
|
|
30
|
+
"@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.3.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-u/pybjTBPGBHB66ku4pK1gj+Dxgx7/+Z0jAriZISPX1ocTO8aHh8x8e7Kb1rB4Ms0nA/SzjtNOVJ4exVavQBCw=="],
|
|
32
31
|
|
|
33
|
-
"@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.
|
|
32
|
+
"@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.3.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-eGUG7+hcLgGnMNl1KHVZUYxahYAhC462jF/wQolqu4qso2MSk32Q+QrpN7eN4jAHAg7FUMIo897muIhK4hXhqg=="],
|
|
34
33
|
|
|
35
|
-
"@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.
|
|
34
|
+
"@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.3.5", "", { "os": "linux", "cpu": "x64" }, "sha512-XrIVi9YAW6ye0CGQ+yax0gLfx+BFOtKaNX74n+xHWla6Cl6huUmcKNO7HPx7BiKnJUzrxXY1qYlm7xMvi08X4g=="],
|
|
36
35
|
|
|
37
|
-
"@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.
|
|
36
|
+
"@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.3.5", "", { "os": "linux", "cpu": "x64" }, "sha512-awVuycTPpVTH/+WDVnEEYSf6nbCBHf/4wB3lquwT7puhNg8R4XvonWNZzUsfHZrCkjkLhFH/vCZK5jHatD9FEg=="],
|
|
38
37
|
|
|
39
|
-
"@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.
|
|
38
|
+
"@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.3.5", "", { "os": "win32", "cpu": "arm64" }, "sha512-DlBiMlBZZ9eIq4H7RimDSGsYcOtfOIfZOaI5CqsWiSlbTfqbPVfWtCf92wNzx8GNMbu1s7/g3ZZESr6+GwM/SA=="],
|
|
40
39
|
|
|
41
|
-
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.
|
|
42
|
-
|
|
43
|
-
"@redis/bloom": ["@redis/bloom@5.8.2", "", { "peerDependencies": { "@redis/client": "^5.8.2" } }, "sha512-855DR0ChetZLarblio5eM0yLwxA9Dqq50t8StXKp5bAtLT0G+rZ+eRzzqxl37sPqQKjUudSYypz55o6nNhbz0A=="],
|
|
44
|
-
|
|
45
|
-
"@redis/client": ["@redis/client@5.8.2", "", { "dependencies": { "cluster-key-slot": "1.1.2" } }, "sha512-WtMScno3+eBpTac1Uav2zugXEoXqaU23YznwvFgkPwBQVwEHTDgOG7uEAObtZ/Nyn8SmAMbqkEubJaMOvnqdsQ=="],
|
|
46
|
-
|
|
47
|
-
"@redis/json": ["@redis/json@5.8.2", "", { "peerDependencies": { "@redis/client": "^5.8.2" } }, "sha512-uxpVfas3I0LccBX9rIfDgJ0dBrUa3+0Gc8sEwmQQH0vHi7C1Rx1Qn8Nv1QWz5bohoeIXMICFZRcyDONvum2l/w=="],
|
|
48
|
-
|
|
49
|
-
"@redis/search": ["@redis/search@5.8.2", "", { "peerDependencies": { "@redis/client": "^5.8.2" } }, "sha512-cNv7HlgayavCBXqPXgaS97DRPVWFznuzsAmmuemi2TMCx5scwLiP50TeZvUS06h/MG96YNPe6A0Zt57yayfxwA=="],
|
|
50
|
-
|
|
51
|
-
"@redis/time-series": ["@redis/time-series@5.8.2", "", { "peerDependencies": { "@redis/client": "^5.8.2" } }, "sha512-g2NlHM07fK8H4k+613NBsk3y70R2JIM2dPMSkhIjl2Z17SYvaYKdusz85d7VYOrZBWtDrHV/WD2E3vGu+zni8A=="],
|
|
40
|
+
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.3.5", "", { "os": "win32", "cpu": "x64" }, "sha512-nUmR8gb6yvrKhtRgzwo/gDimPwnO5a4sCydf8ZS2kHIJhEmSmk+STsusr1LHTuM//wXppBawvSQi2xFXJCdgKQ=="],
|
|
52
41
|
|
|
53
42
|
"@types/bun": ["@types/bun@1.2.17", "", { "dependencies": { "bun-types": "1.2.17" } }, "sha512-l/BYs/JYt+cXA/0+wUhulYJB6a6p//GTPiJ7nV+QHa8iiId4HZmnu/3J/SowP5g0rTiERY2kfGKXEK5Ehltx4Q=="],
|
|
54
43
|
|
|
55
|
-
"@types/node": ["@types/node@24.
|
|
44
|
+
"@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="],
|
|
56
45
|
|
|
57
46
|
"aws-ssl-profiles": ["aws-ssl-profiles@1.1.2", "", {}, "sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g=="],
|
|
58
47
|
|
|
59
48
|
"bun-types": ["bun-types@1.2.17", "", { "dependencies": { "@types/node": "*" } }, "sha512-ElC7ItwT3SCQwYZDYoAH+q6KT4Fxjl8DtZ6qDulUFBmXA8YB4xo+l54J9ZJN+k2pphfn9vk7kfubeSd5QfTVJQ=="],
|
|
60
49
|
|
|
61
|
-
"cluster-key-slot": ["cluster-key-slot@1.1.2", "", {}, "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA=="],
|
|
62
|
-
|
|
63
50
|
"denque": ["denque@2.1.0", "", {}, "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw=="],
|
|
64
51
|
|
|
65
|
-
"dotenv": ["dotenv@17.2.
|
|
52
|
+
"dotenv": ["dotenv@17.2.3", "", {}, "sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w=="],
|
|
66
53
|
|
|
67
54
|
"generate-function": ["generate-function@2.3.1", "", { "dependencies": { "is-property": "^1.0.2" } }, "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ=="],
|
|
68
55
|
|
|
@@ -70,7 +57,7 @@
|
|
|
70
57
|
|
|
71
58
|
"is-property": ["is-property@1.0.2", "", {}, "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g=="],
|
|
72
59
|
|
|
73
|
-
"kysely": ["kysely@0.28.
|
|
60
|
+
"kysely": ["kysely@0.28.8", "", {}, "sha512-QUOgl5ZrS9IRuhq5FvOKFSsD/3+IA6MLE81/bOOTRA/YQpKDza2sFdN5g6JCB9BOpqMJDGefLCQ9F12hRS13TA=="],
|
|
74
61
|
|
|
75
62
|
"long": ["long@5.3.2", "", {}, "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA=="],
|
|
76
63
|
|
|
@@ -78,12 +65,10 @@
|
|
|
78
65
|
|
|
79
66
|
"lru.min": ["lru.min@1.1.2", "", {}, "sha512-Nv9KddBcQSlQopmBHXSsZVY5xsdlZkdH/Iey0BlcBYggMd4two7cZnKOK9vmy3nY0O5RGH99z1PCeTpPqszUYg=="],
|
|
80
67
|
|
|
81
|
-
"mysql2": ["mysql2@3.15.
|
|
68
|
+
"mysql2": ["mysql2@3.15.3", "", { "dependencies": { "aws-ssl-profiles": "^1.1.1", "denque": "^2.1.0", "generate-function": "^2.3.1", "iconv-lite": "^0.7.0", "long": "^5.2.1", "lru.min": "^1.0.0", "named-placeholders": "^1.1.3", "seq-queue": "^0.0.5", "sqlstring": "^2.3.2" } }, "sha512-FBrGau0IXmuqg4haEZRBfHNWB5mUARw6hNwPDXXGg0XzVJ50mr/9hb267lvpVMnhZ1FON3qNd4Xfcez1rbFwSg=="],
|
|
82
69
|
|
|
83
70
|
"named-placeholders": ["named-placeholders@1.1.3", "", { "dependencies": { "lru-cache": "^7.14.1" } }, "sha512-eLoBxg6wE/rZkJPhU/xRX1WTpkFEwDJEN96oxFrTsqBdbT5ec295Q+CoHrL9IT0DipqKhmGcaZmwOt8OON5x1w=="],
|
|
84
71
|
|
|
85
|
-
"redis": ["redis@5.8.2", "", { "dependencies": { "@redis/bloom": "5.8.2", "@redis/client": "5.8.2", "@redis/json": "5.8.2", "@redis/search": "5.8.2", "@redis/time-series": "5.8.2" } }, "sha512-31vunZj07++Y1vcFGcnNWEf5jPoTkGARgfWI4+Tk55vdwHxhAvug8VEtW7Cx+/h47NuJTEg/JL77zAwC6E0OeA=="],
|
|
86
|
-
|
|
87
72
|
"safer-buffer": ["safer-buffer@2.1.2", "", {}, "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="],
|
|
88
73
|
|
|
89
74
|
"seq-queue": ["seq-queue@0.0.5", "", {}, "sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q=="],
|
|
@@ -94,9 +79,9 @@
|
|
|
94
79
|
|
|
95
80
|
"typescript": ["typescript@5.8.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ=="],
|
|
96
81
|
|
|
97
|
-
"undici-types": ["undici-types@7.
|
|
82
|
+
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
|
|
98
83
|
|
|
99
|
-
"zod": ["zod@4.1.
|
|
84
|
+
"zod": ["zod@4.1.12", "", {}, "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ=="],
|
|
100
85
|
|
|
101
86
|
"bun-types/@types/node": ["@types/node@24.0.4", "", { "dependencies": { "undici-types": "~7.8.0" } }, "sha512-ulyqAkrhnuNq9pB76DRBTkcS6YsmDALy6Ua63V8OhrOBgbcYt6IOdzpw5P1+dyRIyMerzLkeYWBeOXPpA9GMAA=="],
|
|
102
87
|
|
package/cron/actions-server.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Cron: @reboot
|
|
2
2
|
|
|
3
|
+
import { RedisClient } from "bun";
|
|
3
4
|
import dotenv from "dotenv";
|
|
4
5
|
import { Kysely, MysqlDialect } from "kysely";
|
|
5
6
|
import { createPool } from "mysql2";
|
|
6
|
-
import { createClient } from "redis";
|
|
7
7
|
import z from "zod";
|
|
8
8
|
import type { NyxAction } from "../utils/actions";
|
|
9
9
|
import * as methods from "../utils/methods";
|
|
@@ -47,12 +47,9 @@ const db = new Kysely<{
|
|
|
47
47
|
}),
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
const redis =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
port: env.BROKER_REDIS_PORT,
|
|
54
|
-
}
|
|
55
|
-
});
|
|
50
|
+
const redis = new RedisClient(
|
|
51
|
+
`redis://${env.BROKER_REDIS_HOST}:${env.BROKER_REDIS_PORT}`,
|
|
52
|
+
);
|
|
56
53
|
await redis.connect();
|
|
57
54
|
|
|
58
55
|
redis.subscribe("nyx-action", async (input) => {
|
|
@@ -87,6 +84,7 @@ setInterval(async () => {
|
|
|
87
84
|
for (const task of tasks) {
|
|
88
85
|
const params: NyxAction = JSON.parse(task.params as any);
|
|
89
86
|
|
|
87
|
+
// biome-ignore lint: performance/noDynamicNamespaceImportAccess
|
|
90
88
|
methods[params.type]({
|
|
91
89
|
bot_token: params.bot_token,
|
|
92
90
|
...params.params,
|
package/nyx-client.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RedisClient } from "bun";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import type { EventTypes } from "./@types";
|
|
4
4
|
import type {
|
|
@@ -31,15 +31,12 @@ class NyxClient {
|
|
|
31
31
|
public injections: BotInjections | undefined;
|
|
32
32
|
public benchmark: boolean | undefined;
|
|
33
33
|
|
|
34
|
-
private redis:
|
|
34
|
+
private redis: RedisClient | undefined;
|
|
35
35
|
|
|
36
36
|
public async initialize(config: NyxConfig) {
|
|
37
|
-
this.redis =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
port: config.redis?.port ?? 6379,
|
|
41
|
-
},
|
|
42
|
-
});
|
|
37
|
+
this.redis = new RedisClient(
|
|
38
|
+
`redis://${config.redis?.host ?? "127.0.0.1"}:${config.redis?.port ?? 6379}`,
|
|
39
|
+
);
|
|
43
40
|
|
|
44
41
|
this.botConfig = z
|
|
45
42
|
.object({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nyx-bot-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"module": "index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devDependencies": {
|
|
@@ -10,13 +10,12 @@
|
|
|
10
10
|
"typescript": "^5"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@biomejs/biome": "^2.
|
|
14
|
-
"@types/node": "^24.
|
|
15
|
-
"dotenv": "^17.2.
|
|
16
|
-
"kysely": "^0.28.
|
|
17
|
-
"mysql2": "^3.15.
|
|
18
|
-
"redis": "^5.8.2",
|
|
13
|
+
"@biomejs/biome": "^2.3.5",
|
|
14
|
+
"@types/node": "^24.10.1",
|
|
15
|
+
"dotenv": "^17.2.3",
|
|
16
|
+
"kysely": "^0.28.8",
|
|
17
|
+
"mysql2": "^3.15.3",
|
|
19
18
|
"ts-debounce": "^4.0.0",
|
|
20
|
-
"zod": "^4.1.
|
|
19
|
+
"zod": "^4.1.12"
|
|
21
20
|
}
|
|
22
21
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { RedisClient } from "bun";
|
|
1
2
|
import type { Kysely } from "kysely";
|
|
2
3
|
import type { Connection, Pool } from "mysql2";
|
|
3
|
-
import type { RedisClientType } from "redis";
|
|
4
4
|
import type { EventTypes } from "./@types";
|
|
5
5
|
import type { NyxResponse } from "./utils/enum";
|
|
6
6
|
|
|
@@ -29,7 +29,7 @@ export type BotInjections = () => Promise<{
|
|
|
29
29
|
|
|
30
30
|
export type Injections<T> = {
|
|
31
31
|
mysql?: Connection | Pool;
|
|
32
|
-
redis?:
|
|
32
|
+
redis?: RedisClient;
|
|
33
33
|
db?: Kysely<T>;
|
|
34
34
|
[key: string]: any;
|
|
35
35
|
};
|
package/utils/actions.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RedisClient } from "bun";
|
|
2
2
|
import type * as methods from "./methods.ts";
|
|
3
3
|
|
|
4
4
|
type MethodName = keyof typeof methods;
|
|
@@ -13,7 +13,7 @@ export type NyxAction<T extends MethodName = MethodName> = {
|
|
|
13
13
|
date: number;
|
|
14
14
|
bot_token: string;
|
|
15
15
|
bot_api_server?: string;
|
|
16
|
-
redis?:
|
|
16
|
+
redis?: RedisClient;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const actionBroker = async <T extends MethodName>(
|
|
@@ -22,9 +22,9 @@ export const actionBroker = async <T extends MethodName>(
|
|
|
22
22
|
if (action.redis) {
|
|
23
23
|
await action.redis.publish("nyx-action", JSON.stringify(action));
|
|
24
24
|
} else {
|
|
25
|
-
const redis =
|
|
25
|
+
const redis = new RedisClient();
|
|
26
26
|
await redis.connect();
|
|
27
27
|
await redis.publish("nyx-action", JSON.stringify(action));
|
|
28
|
-
|
|
28
|
+
redis.close();
|
|
29
29
|
}
|
|
30
30
|
};
|
package/utils/methods.ts
CHANGED
|
@@ -108,7 +108,8 @@ export const sendMessage = (
|
|
|
108
108
|
params.text = JSON.stringify(params.text);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
params.parse_mode
|
|
111
|
+
params.parse_mode =
|
|
112
|
+
params.parse_mode ?? (params.parse_mode === "none" ? undefined : "HTML");
|
|
112
113
|
|
|
113
114
|
return requestTelegramAPI("sendMessage", params);
|
|
114
115
|
};
|
|
@@ -205,7 +206,8 @@ export type copyMessageParams = {
|
|
|
205
206
|
export const copyMessage = (
|
|
206
207
|
params: copyMessageParams,
|
|
207
208
|
): APIResponse<MessageId> => {
|
|
208
|
-
params.parse_mode
|
|
209
|
+
params.parse_mode =
|
|
210
|
+
params.parse_mode ?? (params.parse_mode === "none" ? undefined : "HTML");
|
|
209
211
|
return requestTelegramAPI("copyMessage", params);
|
|
210
212
|
};
|
|
211
213
|
|
|
@@ -246,7 +248,8 @@ export type sendPhotoParams = {
|
|
|
246
248
|
} & methodParams;
|
|
247
249
|
|
|
248
250
|
export const sendPhoto = (params: sendPhotoParams): APIResponse<Message> => {
|
|
249
|
-
params.parse_mode
|
|
251
|
+
params.parse_mode =
|
|
252
|
+
params.parse_mode ?? (params.parse_mode === "none" ? undefined : "HTML");
|
|
250
253
|
return requestTelegramAPI("sendPhoto", params);
|
|
251
254
|
};
|
|
252
255
|
|
|
@@ -275,7 +278,8 @@ export type sendAudioParams = {
|
|
|
275
278
|
} & methodParams;
|
|
276
279
|
|
|
277
280
|
export const sendAudio = (params: sendAudioParams): APIResponse<Message> => {
|
|
278
|
-
params.parse_mode
|
|
281
|
+
params.parse_mode =
|
|
282
|
+
params.parse_mode ?? (params.parse_mode === "none" ? undefined : "HTML");
|
|
279
283
|
return requestTelegramAPI("sendAudio", params);
|
|
280
284
|
};
|
|
281
285
|
|
|
@@ -304,7 +308,8 @@ export type sendDocumentParams = {
|
|
|
304
308
|
export const sendDocument = (
|
|
305
309
|
params: sendDocumentParams,
|
|
306
310
|
): APIResponse<Message> => {
|
|
307
|
-
params.parse_mode
|
|
311
|
+
params.parse_mode =
|
|
312
|
+
params.parse_mode ?? (params.parse_mode === "none" ? undefined : "HTML");
|
|
308
313
|
return requestTelegramAPI("sendDocument", params);
|
|
309
314
|
};
|
|
310
315
|
|
|
@@ -338,7 +343,8 @@ export type sendVideoParams = {
|
|
|
338
343
|
} & methodParams;
|
|
339
344
|
|
|
340
345
|
export const sendVideo = (params: sendVideoParams): APIResponse<Message> => {
|
|
341
|
-
params.parse_mode
|
|
346
|
+
params.parse_mode =
|
|
347
|
+
params.parse_mode ?? (params.parse_mode === "none" ? undefined : "HTML");
|
|
342
348
|
return requestTelegramAPI("sendVideo", params);
|
|
343
349
|
};
|
|
344
350
|
|
|
@@ -371,7 +377,8 @@ export type sendAnimationParams = {
|
|
|
371
377
|
export const sendAnimation = (
|
|
372
378
|
params: sendAnimationParams,
|
|
373
379
|
): APIResponse<Message> => {
|
|
374
|
-
params.parse_mode
|
|
380
|
+
params.parse_mode =
|
|
381
|
+
params.parse_mode ?? (params.parse_mode === "none" ? undefined : "HTML");
|
|
375
382
|
return requestTelegramAPI("sendAnimation", params);
|
|
376
383
|
};
|
|
377
384
|
|
|
@@ -397,7 +404,8 @@ export type sendVoiceParams = {
|
|
|
397
404
|
} & methodParams;
|
|
398
405
|
|
|
399
406
|
export const sendVoice = (params: sendVoiceParams): APIResponse<Message> => {
|
|
400
|
-
params.parse_mode
|
|
407
|
+
params.parse_mode =
|
|
408
|
+
params.parse_mode ?? (params.parse_mode === "none" ? undefined : "HTML");
|
|
401
409
|
return requestTelegramAPI("sendVoice", params);
|
|
402
410
|
};
|
|
403
411
|
|
|
@@ -451,7 +459,8 @@ export type sendPaidMediaParams = {
|
|
|
451
459
|
export const sendPaidMedia = (
|
|
452
460
|
params: sendPaidMediaParams,
|
|
453
461
|
): APIResponse<Message> => {
|
|
454
|
-
params.parse_mode
|
|
462
|
+
params.parse_mode =
|
|
463
|
+
params.parse_mode ?? (params.parse_mode === "none" ? undefined : "HTML");
|
|
455
464
|
return requestTelegramAPI("sendPaidMedia", params);
|
|
456
465
|
};
|
|
457
466
|
|
|
@@ -587,8 +596,12 @@ export type sendPollParams = {
|
|
|
587
596
|
} & methodParams;
|
|
588
597
|
|
|
589
598
|
export const sendPoll = (params: sendPollParams): APIResponse<Message> => {
|
|
590
|
-
params.question_parse_mode
|
|
591
|
-
|
|
599
|
+
params.question_parse_mode =
|
|
600
|
+
params.question_parse_mode ??
|
|
601
|
+
(params.question_parse_mode === "none" ? undefined : "HTML");
|
|
602
|
+
params.explanation_parse_mode =
|
|
603
|
+
params.explanation_parse_mode ??
|
|
604
|
+
(params.explanation_parse_mode === "none" ? undefined : "HTML");
|
|
592
605
|
return requestTelegramAPI("sendPoll", params);
|
|
593
606
|
};
|
|
594
607
|
|
|
@@ -1223,7 +1236,8 @@ export type editMessageTextParams = {
|
|
|
1223
1236
|
export const editMessageText = (
|
|
1224
1237
|
params: editMessageTextParams,
|
|
1225
1238
|
): APIResponse<Message | true> => {
|
|
1226
|
-
params.parse_mode
|
|
1239
|
+
params.parse_mode =
|
|
1240
|
+
params.parse_mode ?? (params.parse_mode === "none" ? undefined : "HTML");
|
|
1227
1241
|
return requestTelegramAPI("editMessageText", params);
|
|
1228
1242
|
};
|
|
1229
1243
|
|
|
@@ -1242,7 +1256,8 @@ export type editMessageCaptionParams = {
|
|
|
1242
1256
|
export const editMessageCaption = (
|
|
1243
1257
|
params: editMessageCaptionParams,
|
|
1244
1258
|
): APIResponse<Message | true> => {
|
|
1245
|
-
params.parse_mode
|
|
1259
|
+
params.parse_mode =
|
|
1260
|
+
params.parse_mode ?? (params.parse_mode === "none" ? undefined : "HTML");
|
|
1246
1261
|
return requestTelegramAPI("editMessageCaption", params);
|
|
1247
1262
|
};
|
|
1248
1263
|
|
|
@@ -1348,7 +1363,9 @@ export type sendGiftParams = {
|
|
|
1348
1363
|
} & methodParams;
|
|
1349
1364
|
|
|
1350
1365
|
export const sendGift = (params: sendGiftParams): APIResponse => {
|
|
1351
|
-
params.text_parse_mode
|
|
1366
|
+
params.text_parse_mode =
|
|
1367
|
+
params.text_parse_mode ??
|
|
1368
|
+
(params.text_parse_mode === "none" ? undefined : "HTML");
|
|
1352
1369
|
return requestTelegramAPI("sendGift", params);
|
|
1353
1370
|
};
|
|
1354
1371
|
|
|
@@ -1364,7 +1381,9 @@ export type giftPremiumSubscriptionParams = {
|
|
|
1364
1381
|
export const giftPremiumSubscription = (
|
|
1365
1382
|
params: giftPremiumSubscriptionParams,
|
|
1366
1383
|
): APIResponse => {
|
|
1367
|
-
params.text_parse_mode
|
|
1384
|
+
params.text_parse_mode =
|
|
1385
|
+
params.text_parse_mode ??
|
|
1386
|
+
(params.text_parse_mode === "none" ? undefined : "HTML");
|
|
1368
1387
|
return requestTelegramAPI("giftPremiumSubscription", params);
|
|
1369
1388
|
};
|
|
1370
1389
|
|
|
@@ -1551,7 +1570,8 @@ export type postStoryParams = {
|
|
|
1551
1570
|
} & methodParams;
|
|
1552
1571
|
|
|
1553
1572
|
export const postStory = (params: postStoryParams): APIResponse<Story> => {
|
|
1554
|
-
params.parse_mode
|
|
1573
|
+
params.parse_mode =
|
|
1574
|
+
params.parse_mode ?? (params.parse_mode === "none" ? undefined : "HTML");
|
|
1555
1575
|
return requestTelegramAPI("postStory", params);
|
|
1556
1576
|
};
|
|
1557
1577
|
|
|
@@ -1566,7 +1586,8 @@ export type editStoryParams = {
|
|
|
1566
1586
|
} & methodParams;
|
|
1567
1587
|
|
|
1568
1588
|
export const editStory = (params: editStoryParams): APIResponse<Story> => {
|
|
1569
|
-
params.parse_mode
|
|
1589
|
+
params.parse_mode =
|
|
1590
|
+
params.parse_mode ?? (params.parse_mode === "none" ? undefined : "HTML");
|
|
1570
1591
|
return requestTelegramAPI("editStory", params);
|
|
1571
1592
|
};
|
|
1572
1593
|
|
package/utils/table.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RedisClient } from "bun";
|
|
2
2
|
import { debounce } from "ts-debounce";
|
|
3
3
|
import { createReactiveObject } from "./objects";
|
|
4
4
|
|
|
@@ -13,7 +13,7 @@ class NyxTable<T> {
|
|
|
13
13
|
private pid: string;
|
|
14
14
|
private options: NyxTableOptions<T> | undefined;
|
|
15
15
|
private schema: T;
|
|
16
|
-
private redis:
|
|
16
|
+
private redis: RedisClient;
|
|
17
17
|
private key: string;
|
|
18
18
|
private channel: string;
|
|
19
19
|
private handleUpdate: (() => void) | undefined;
|
|
@@ -23,7 +23,7 @@ class NyxTable<T> {
|
|
|
23
23
|
constructor(
|
|
24
24
|
uid: string,
|
|
25
25
|
schema: T,
|
|
26
|
-
redis:
|
|
26
|
+
redis: RedisClient,
|
|
27
27
|
options?: NyxTableOptions<T>,
|
|
28
28
|
) {
|
|
29
29
|
this.uid = uid;
|
|
@@ -58,8 +58,7 @@ class NyxTable<T> {
|
|
|
58
58
|
await this.options?.onInternalUpdate?.(this.table);
|
|
59
59
|
}, this.options?.persistenceDebounceMillis ?? 1_000);
|
|
60
60
|
|
|
61
|
-
const redisSub = this.redis.duplicate();
|
|
62
|
-
await redisSub.connect();
|
|
61
|
+
const redisSub = await this.redis.duplicate();
|
|
63
62
|
redisSub.subscribe(this.channel, async (pid) => {
|
|
64
63
|
if (pid !== this.pid) {
|
|
65
64
|
this.assignTable(JSON.parse((await this.redis.get(this.key))!));
|