Skip to content

Commit dba076e

Browse files
authored
feat!: Rewrite everything with mtcute (#3)
- reimplements bot logic using `mtcute` instead of `grammy` :3 - reimplements i18n using raw `@fluent/bundle` instead of `@grammy/i18n` - updates project structure, separates data and telegram logic - adds support for files up to 2GB instead of 50MB (as a side effect of not using bot api), fixes #2 - adds support for parallel downloads (as a side effect of using mtcute) - removes weird & ugly inline upload fix (as a side effect of not using bot api) - improves error handling
1 parent 5f7834b commit dba076e

39 files changed

+2358
-1956
lines changed

.dockerignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ build
88
.git
99
.idea
1010
.vscode
11-
sqlite.db
11+
data

.env.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Required variables
2+
API_ID=
3+
API_HASH=
24
BOT_TOKEN=
3-
INLINE_FIX_CHAT_ID=
45

56
# Optional variables, defaults shown
67
API_BASE_URL=https://co.wuk.sh/api

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ yarn-error.log*
3232
.fleet
3333
.vscode
3434

35-
# SQLite DB
36-
sqlite.db
35+
# Runtime Persistence
36+
/data

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ powered by [cobalt](https://github.com/imputnet/cobalt).
2020
pnpm start
2121
```
2222

23-
> note: if you're using docker, don't forget to mount sqlite.db database file!
23+
> note: if you're using docker, don't forget to create a volume for /app/data!
2424
2525
## license
2626

drizzle.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineConfig } from "drizzle-kit"
22

33
export default defineConfig({
44
out: "./migrations",
5-
schema: "./src/db/schema.ts",
5+
schema: "./src/core/data/db/schema.ts",
66
driver: "better-sqlite",
77
dbCredentials: {
88
url: "./sqlite.db",

migrations/0000_slim_maestro.sql

-5
This file was deleted.

migrations/0000_supreme_ben_urich.sql

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CREATE TABLE `requests` (
2+
`id` text PRIMARY KEY NOT NULL,
3+
`author_id` integer NOT NULL,
4+
`url` text NOT NULL
5+
);
6+
--> statement-breakpoint
7+
CREATE TABLE `settings` (
8+
`id` integer PRIMARY KEY NOT NULL,
9+
`output` text,
10+
`attribution` integer DEFAULT 0 NOT NULL,
11+
`language` text
12+
);
13+
--> statement-breakpoint
14+
CREATE TABLE `users` (
15+
`id` integer PRIMARY KEY NOT NULL,
16+
`downloads` integer DEFAULT 0
17+
);
18+
--> statement-breakpoint
19+
CREATE UNIQUE INDEX `settings_id_unique` ON `settings` (`id`);--> statement-breakpoint
20+
CREATE UNIQUE INDEX `users_id_unique` ON `users` (`id`);

migrations/0001_giant_vin_gonzales.sql

-8
This file was deleted.

migrations/0002_dry_screwball.sql

-1
This file was deleted.

migrations/meta/0000_snapshot.json

+79-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"version": "5",
33
"dialect": "sqlite",
4-
"id": "b3eb1cd5-4852-47c0-9dce-5cb78200f5c8",
4+
"id": "a3959bd4-7853-4642-b401-7ed157ba3283",
55
"prevId": "00000000-0000-0000-0000-000000000000",
66
"tables": {
77
"requests": {
@@ -33,6 +33,84 @@
3333
"foreignKeys": {},
3434
"compositePrimaryKeys": {},
3535
"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+
},
70+
"indexes": {
71+
"settings_id_unique": {
72+
"name": "settings_id_unique",
73+
"columns": [
74+
"id"
75+
],
76+
"isUnique": true
77+
}
78+
},
79+
"foreignKeys": {},
80+
"compositePrimaryKeys": {},
81+
"uniqueConstraints": {}
82+
},
83+
"users": {
84+
"name": "users",
85+
"columns": {
86+
"id": {
87+
"name": "id",
88+
"type": "integer",
89+
"primaryKey": true,
90+
"notNull": true,
91+
"autoincrement": false
92+
},
93+
"downloads": {
94+
"name": "downloads",
95+
"type": "integer",
96+
"primaryKey": false,
97+
"notNull": false,
98+
"autoincrement": false,
99+
"default": 0
100+
}
101+
},
102+
"indexes": {
103+
"users_id_unique": {
104+
"name": "users_id_unique",
105+
"columns": [
106+
"id"
107+
],
108+
"isUnique": true
109+
}
110+
},
111+
"foreignKeys": {},
112+
"compositePrimaryKeys": {},
113+
"uniqueConstraints": {}
36114
}
37115
},
38116
"enums": {},

migrations/meta/0001_snapshot.json

-90
This file was deleted.

migrations/meta/0002_snapshot.json

-97
This file was deleted.

migrations/meta/_journal.json

+2-16
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,8 @@
55
{
66
"idx": 0,
77
"version": "5",
8-
"when": 1706452128457,
9-
"tag": "0000_slim_maestro",
10-
"breakpoints": true
11-
},
12-
{
13-
"idx": 1,
14-
"version": "5",
15-
"when": 1708695593228,
16-
"tag": "0001_giant_vin_gonzales",
17-
"breakpoints": true
18-
},
19-
{
20-
"idx": 2,
21-
"version": "5",
22-
"when": 1718465870677,
23-
"tag": "0002_dry_screwball",
8+
"when": 1720203773408,
9+
"tag": "0000_supreme_ben_urich",
2410
"breakpoints": true
2511
}
2612
]

0 commit comments

Comments
 (0)