Skip to content

Commit

Permalink
feat!: Rewrite everything with mtcute (#3)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
otomir23 committed Jul 7, 2024
1 parent 5f7834b commit dba076e
Show file tree
Hide file tree
Showing 39 changed files with 2,358 additions and 1,956 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ build
.git
.idea
.vscode
sqlite.db
data
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Required variables
API_ID=
API_HASH=
BOT_TOKEN=
INLINE_FIX_CHAT_ID=

# Optional variables, defaults shown
API_BASE_URL=https://co.wuk.sh/api
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ yarn-error.log*
.fleet
.vscode

# SQLite DB
sqlite.db
# Runtime Persistence
/data
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ powered by [cobalt](https://github.com/imputnet/cobalt).
pnpm start
```

> note: if you're using docker, don't forget to mount sqlite.db database file!
> note: if you're using docker, don't forget to create a volume for /app/data!

## license

Expand Down
2 changes: 1 addition & 1 deletion drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig } from "drizzle-kit"

export default defineConfig({
out: "./migrations",
schema: "./src/db/schema.ts",
schema: "./src/core/data/db/schema.ts",
driver: "better-sqlite",
dbCredentials: {
url: "./sqlite.db",
Expand Down
5 changes: 0 additions & 5 deletions migrations/0000_slim_maestro.sql

This file was deleted.

20 changes: 20 additions & 0 deletions migrations/0000_supreme_ben_urich.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CREATE TABLE `requests` (
`id` text PRIMARY KEY NOT NULL,
`author_id` integer NOT NULL,
`url` text NOT NULL
);
--> statement-breakpoint
CREATE TABLE `settings` (
`id` integer PRIMARY KEY NOT NULL,
`output` text,
`attribution` integer DEFAULT 0 NOT NULL,
`language` text
);
--> statement-breakpoint
CREATE TABLE `users` (
`id` integer PRIMARY KEY NOT NULL,
`downloads` integer DEFAULT 0
);
--> statement-breakpoint
CREATE UNIQUE INDEX `settings_id_unique` ON `settings` (`id`);--> statement-breakpoint
CREATE UNIQUE INDEX `users_id_unique` ON `users` (`id`);
8 changes: 0 additions & 8 deletions migrations/0001_giant_vin_gonzales.sql

This file was deleted.

1 change: 0 additions & 1 deletion migrations/0002_dry_screwball.sql

This file was deleted.

80 changes: 79 additions & 1 deletion migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "5",
"dialect": "sqlite",
"id": "b3eb1cd5-4852-47c0-9dce-5cb78200f5c8",
"id": "a3959bd4-7853-4642-b401-7ed157ba3283",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"requests": {
Expand Down Expand Up @@ -33,6 +33,84 @@
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"settings": {
"name": "settings",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"output": {
"name": "output",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"attribution": {
"name": "attribution",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": 0
},
"language": {
"name": "language",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
"settings_id_unique": {
"name": "settings_id_unique",
"columns": [
"id"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"users": {
"name": "users",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"downloads": {
"name": "downloads",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": 0
}
},
"indexes": {
"users_id_unique": {
"name": "users_id_unique",
"columns": [
"id"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
Expand Down
90 changes: 0 additions & 90 deletions migrations/meta/0001_snapshot.json

This file was deleted.

97 changes: 0 additions & 97 deletions migrations/meta/0002_snapshot.json

This file was deleted.

18 changes: 2 additions & 16 deletions migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,8 @@
{
"idx": 0,
"version": "5",
"when": 1706452128457,
"tag": "0000_slim_maestro",
"breakpoints": true
},
{
"idx": 1,
"version": "5",
"when": 1708695593228,
"tag": "0001_giant_vin_gonzales",
"breakpoints": true
},
{
"idx": 2,
"version": "5",
"when": 1718465870677,
"tag": "0002_dry_screwball",
"when": 1720203773408,
"tag": "0000_supreme_ben_urich",
"breakpoints": true
}
]
Expand Down
Loading

0 comments on commit dba076e

Please sign in to comment.