Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions locales/ar.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ setting-send-as-file = أرسل كملف
setting-send-as-file-0 = معطل
setting-send-as-file-1 = مفعل

setting-allow-text-links = التنزيل من الروابط التشعبية
setting-allow-text-links-0 = الروابط المباشرة فقط
setting-allow-text-links-1 = مفعل

setting-lang = اللغة
setting-lang-unset = مطابق لتيليجرام

Expand Down
4 changes: 4 additions & 0 deletions locales/en.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ setting-send-as-file = send as file
setting-send-as-file-0 = nah
setting-send-as-file-1 = sure

setting-allow-text-links = download from hyperlinks
setting-allow-text-links-0 = direct links only
setting-allow-text-links-1 = sure

setting-lang = language
setting-lang-ar = العربية
setting-lang-en = english
Expand Down
4 changes: 4 additions & 0 deletions locales/pt-BR.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ setting-send-as-file = enviar como arquivo.
setting-send-as-file-0 = não
setting-send-as-file-1 = claro

setting-allow-text-links = baixar de hyperlinks
setting-allow-text-links-0 = apenas links diretos
setting-allow-text-links-1 = claro

setting-lang = idioma
setting-lang-unset = mesmo que o telegram.

Expand Down
4 changes: 4 additions & 0 deletions locales/ru.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ setting-send-as-file = отправить как файл
setting-send-as-file-0 = не
setting-send-as-file-1 = давай

setting-allow-text-links = скачивать из гиперссылок
setting-allow-text-links-0 = только прямые ссылки
setting-allow-text-links-1 = давай

setting-lang = язык
setting-lang-unset = как в тг

Expand Down
4 changes: 4 additions & 0 deletions locales/uk-UA.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ setting-send-as-file = надіслати як файл
setting-send-as-file-0 = ні
setting-send-as-file-1 = давай

setting-allow-text-links = завантажувати з гіперпосилань
setting-allow-text-links-0 = тільки прямі посилання
setting-allow-text-links-1 = давай

setting-lang = мова
setting-lang-unset = як в тг

Expand Down
1 change: 1 addition & 0 deletions migrations/0004_misty_richard_fisk.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `settings` ADD `allow_text_links` integer DEFAULT 1 NOT NULL;
184 changes: 184 additions & 0 deletions migrations/meta/0004_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
{
"version": "6",
"dialect": "sqlite",
"id": "47100255-a2f3-4470-9e73-c0f25338f78a",
"prevId": "6446fee0-a4a1-4933-8178-b141867fcbdb",
"tables": {
"requests": {
"name": "requests",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"author_id": {
"name": "author_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"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
},
"instance": {
"name": "instance",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"video_format": {
"name": "video_format",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'h264'"
},
"video_quality": {
"name": "video_quality",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'1080'"
},
"audio_format": {
"name": "audio_format",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'mp3'"
},
"audio_quality": {
"name": "audio_quality",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'128'"
},
"send_as_file": {
"name": "send_as_file",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": 0
},
"allow_text_links": {
"name": "allow_text_links",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": 1
}
},
"indexes": {
"settings_id_unique": {
"name": "settings_id_unique",
"columns": [
"id"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"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": {},
"checkConstraints": {}
}
},
"views": {},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}
7 changes: 7 additions & 0 deletions migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
"when": 1761939615000,
"tag": "0003_send_as_file",
"breakpoints": true
},
{
"idx": 4,
"version": "6",
"when": 1777209210516,
"tag": "0004_misty_richard_fisk",
"breakpoints": true
}
]
}
1 change: 1 addition & 0 deletions src/core/data/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export const settings = sqliteTable("settings", {
audioFormat: text("audio_format").notNull().default("mp3"),
audioQuality: text("audio_quality").notNull().default("128"),
sendAsFile: int("send_as_file").notNull().default(0),
allowTextLinks: int("allow_text_links").notNull().default(1),
})
3 changes: 3 additions & 0 deletions src/core/data/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const defaultSettings: Settings = {
audioFormat: "mp3",
audioQuality: "128",
sendAsFile: 0,
allowTextLinks: 1,
}

export const settingOptions: {
Expand All @@ -33,6 +34,7 @@ export const settingOptions: {
audioFormat: ["best", "mp3", "ogg", "wav", "opus"],
audioQuality: ["8", "64", "96", "128", "256", "320"],
sendAsFile: [0, 1],
allowTextLinks: [0, 1],
}

export const settingI18n: {
Expand All @@ -47,6 +49,7 @@ export const settingI18n: {
audioFormat: { key: "audio-format", mode: "translatable" },
audioQuality: { key: "audio-quality", mode: "literal" },
sendAsFile: { key: "send-as-file", mode: "translatable" },
allowTextLinks: { key: "allow-text-links", mode: "translatable" },
}

export async function getSettings(id: number): Promise<Settings> {
Expand Down
4 changes: 2 additions & 2 deletions src/telegram/bot/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ downloadDp.onNewMessage(filters.chat("user"), async (msg) => {
return
}

const urlEntity = msg.entities.find(e => e.is("text_link") || e.is("url"))
const settings = await getPeerSettings(msg.sender)
const urlEntity = msg.entities.find(e => e.is("url") || (settings.allowTextLinks === 1 && e.is("text_link")))
const extractedUrl = urlEntity && (urlEntity.is("text_link") ? urlEntity.params.url : urlEntity.text)
const req = await createRequest(extractedUrl || msg.text, msg.sender.id)

Expand All @@ -45,7 +46,6 @@ downloadDp.onNewMessage(filters.chat("user"), async (msg) => {
]),
})

const settings = await getPeerSettings(msg.sender)
if (settings.preferredOutput) {
await onOutputSelected(
settings.preferredOutput,
Expand Down