Skip to content

Commit 0065c56

Browse files
authored
feat: Implement setting to use custom Cobalt API instance endpoint & rewrite data layer (#13)
1 parent 71ebd0e commit 0065c56

25 files changed

+564
-211
lines changed

.env.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ BOT_TOKEN=
55
API_ENDPOINTS='[
66
"https://api.cobalt.tools",
77
{ "url": "https://api.cobalt.tools" },
8-
{ "name": "custom name", "url": "https://api.cobalt.tools", "auth": "Api-Key 123" }
8+
{ "name": "custom name", "url": "https://api.cobalt.tools", "auth": "Api-Key 123", "proxy": "http://proxy.example.com" }
99
]'
1010

1111
# Optional variables, defaults shown
1212
SELECT_TYPE_PHOTO_URL=https://i.otomir23.me/buckets/cobold/download.png
1313
ERROR_CHAT_ID=
14+
CUSTOM_INSTANCE_PROXY_URL=

locales/en.ftl

+4
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,9 @@ setting-lang-ru = русский
4242
setting-lang-uk-UA = українська
4343
setting-lang-unset = same as telegram
4444
45+
setting-instance = custom instance
46+
setting-instance-unset = disabled
47+
setting-instance-custom = override
48+
4549
stats-personal = i helped you with downloading { $count } times! (˶ᵔ ᵕ ᵔ˶)
4650
stats-global = i helped with downloading { $count } times! (˶ᵔ ᵕ ᵔ˶)

locales/ru.ftl

+4
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,9 @@ setting-attribution-1 = давай
3737
setting-lang = язык
3838
setting-lang-unset = как в тг
3939
40+
setting-instance = кастомный инстанс
41+
setting-instance-unset = выключен
42+
setting-instance-custom = настроить
43+
4044
stats-personal = я помог тебе с загрузкой { $count } раз! (˶ᵔ ᵕ ᵔ˶)
4145
stats-global = я помог с загрузкой { $count } раз! (˶ᵔ ᵕ ᵔ˶)

migrations/0001_eminent_ultron.sql

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE settings ADD `instance` text;

migrations/meta/0001_snapshot.json

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
{
2+
"version": "5",
3+
"dialect": "sqlite",
4+
"id": "8f524a1e-29ad-4518-88f2-435c6a3114f0",
5+
"prevId": "a3959bd4-7853-4642-b401-7ed157ba3283",
6+
"tables": {
7+
"requests": {
8+
"name": "requests",
9+
"columns": {
10+
"id": {
11+
"name": "id",
12+
"type": "text",
13+
"primaryKey": true,
14+
"notNull": true,
15+
"autoincrement": false
16+
},
17+
"author_id": {
18+
"name": "author_id",
19+
"type": "integer",
20+
"primaryKey": false,
21+
"notNull": true,
22+
"autoincrement": false
23+
},
24+
"url": {
25+
"name": "url",
26+
"type": "text",
27+
"primaryKey": false,
28+
"notNull": true,
29+
"autoincrement": false
30+
}
31+
},
32+
"indexes": {},
33+
"foreignKeys": {},
34+
"compositePrimaryKeys": {},
35+
"uniqueConstraints": {}
36+
},
37+
"settings": {
38+
"name": "settings",
39+
"columns": {
40+
"id": {
41+
"name": "id",
42+
"type": "integer",
43+
"primaryKey": true,
44+
"notNull": true,
45+
"autoincrement": false
46+
},
47+
"output": {
48+
"name": "output",
49+
"type": "text",
50+
"primaryKey": false,
51+
"notNull": false,
52+
"autoincrement": false
53+
},
54+
"attribution": {
55+
"name": "attribution",
56+
"type": "integer",
57+
"primaryKey": false,
58+
"notNull": true,
59+
"autoincrement": false,
60+
"default": 0
61+
},
62+
"language": {
63+
"name": "language",
64+
"type": "text",
65+
"primaryKey": false,
66+
"notNull": false,
67+
"autoincrement": false
68+
},
69+
"instance": {
70+
"name": "instance",
71+
"type": "text",
72+
"primaryKey": false,
73+
"notNull": false,
74+
"autoincrement": false
75+
}
76+
},
77+
"indexes": {
78+
"settings_id_unique": {
79+
"name": "settings_id_unique",
80+
"columns": [
81+
"id"
82+
],
83+
"isUnique": true
84+
}
85+
},
86+
"foreignKeys": {},
87+
"compositePrimaryKeys": {},
88+
"uniqueConstraints": {}
89+
},
90+
"users": {
91+
"name": "users",
92+
"columns": {
93+
"id": {
94+
"name": "id",
95+
"type": "integer",
96+
"primaryKey": true,
97+
"notNull": true,
98+
"autoincrement": false
99+
},
100+
"downloads": {
101+
"name": "downloads",
102+
"type": "integer",
103+
"primaryKey": false,
104+
"notNull": false,
105+
"autoincrement": false,
106+
"default": 0
107+
}
108+
},
109+
"indexes": {
110+
"users_id_unique": {
111+
"name": "users_id_unique",
112+
"columns": [
113+
"id"
114+
],
115+
"isUnique": true
116+
}
117+
},
118+
"foreignKeys": {},
119+
"compositePrimaryKeys": {},
120+
"uniqueConstraints": {}
121+
}
122+
},
123+
"enums": {},
124+
"_meta": {
125+
"schemas": {},
126+
"tables": {},
127+
"columns": {}
128+
}
129+
}

migrations/meta/_journal.json

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
"when": 1720203773408,
99
"tag": "0000_supreme_ben_urich",
1010
"breakpoints": true
11+
},
12+
{
13+
"idx": 1,
14+
"version": "5",
15+
"when": 1736519894021,
16+
"tag": "0001_eminent_ultron",
17+
"breakpoints": true
1118
}
1219
]
1320
}

package.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,23 @@
3737
"dependencies": {
3838
"@fluent/bundle": "^0.18.0",
3939
"@fluent/langneg": "^0.7.0",
40+
"@fuman/fetch": "^0.0.12",
4041
"@mtcute/crypto-node": "^0.19.0",
4142
"@mtcute/dispatcher": "^0.19.1",
4243
"@mtcute/node": "^0.19.3",
4344
"@t3-oss/env-core": "^0.7.1",
4445
"better-sqlite3": "^11.5.0",
4546
"dotenv": "^16.3.1",
4647
"drizzle-orm": "^0.29.3",
48+
"ipaddr.js": "^2.2.0",
4749
"mediainfo.js": "^0.3.2",
50+
"undici": "^7.4.0",
4851
"zod": "^3.22.4"
4952
},
5053
"pnpm": {
51-
"onlyBuiltDependencies": ["better-sqlite3", "esbuild"]
54+
"onlyBuiltDependencies": [
55+
"better-sqlite3",
56+
"esbuild"
57+
]
5258
}
5359
}

0 commit comments

Comments
 (0)