Phase 1: core bot
Link in, card, download, send, in private chats and groups. - cmd/core with an embedded download worker - Telegram front end on telego v1.13.0 (Bot API 10.4): link card with thumbnail and format buttons, one live status message, /dl /audio /thumb /info /queue /cancel, group support with requester-only buttons - Database backed queue: paid and free lanes, leases with heartbeats, one automatic retry, cancel, queue position and wait estimate - yt-dlp and ffprobe behind a Runner interface with classified, redacted errors mapped to friendly messages - SQLite via modernc with goose migrations, portable schema - Local file storage behind a Storage interface - go-i18n with an English catalog, no literal text in handlers - Free tier limits enforced before queueing and again on the real file - Bot token and webhook secret are stripped from all log output - Tests: URL parsing, job lifecycle, worker, yt-dlp wrapper, and end to end flows against a fake Bot API server; opt-in test with the real yt-dlp Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
// Package locales embeds the translation catalogs into the binary.
|
||||
package locales
|
||||
|
||||
import "embed"
|
||||
|
||||
// FS holds every catalog, one TOML file per language.
|
||||
//
|
||||
//go:embed *.toml
|
||||
var FS embed.FS
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
# English catalog. This is the source language: every other catalog must
|
||||
# have exactly these keys.
|
||||
#
|
||||
# Rules for translators:
|
||||
# - Text in {{.Braces}} is a placeholder. Keep it as is.
|
||||
# - Keep the HTML tags (<b>, <i>, <code>) and the line breaks.
|
||||
# - Never use these words as a key name, go-i18n reserves them:
|
||||
# id, description, hash, leftdelim, rightdelim, zero, one, two, few, many, other
|
||||
# (they are only valid as plural forms inside a message).
|
||||
|
||||
[start]
|
||||
private = """
|
||||
<b>Hi {{.Name}}, welcome to The Noderunners Download Bot.</b>
|
||||
|
||||
Send me a link to a video or a song and I will fetch it for you.
|
||||
|
||||
/help shows what I can do."""
|
||||
group = """
|
||||
<b>The Noderunners Download Bot is here.</b>
|
||||
|
||||
Use /dl with a link, or reply /dl to a message that has a link."""
|
||||
|
||||
[help]
|
||||
text = """
|
||||
<b>How to use me</b>
|
||||
|
||||
In a private chat, just send a link. I show a card and you pick the format.
|
||||
In a group, use /dl with a link, or reply /dl to a message that has a link.
|
||||
|
||||
<b>Commands</b>
|
||||
/dl link - download a video
|
||||
/audio link - download the audio as MP3
|
||||
/thumb link - get the thumbnail
|
||||
/info link - show formats and sizes without downloading
|
||||
/queue - your running downloads
|
||||
/cancel - cancel your downloads
|
||||
|
||||
<b>Your limits</b>
|
||||
Up to {{.MaxSize}} and {{.MaxDuration}} per download."""
|
||||
|
||||
[cmd]
|
||||
unknown = "I do not know that command. Try /help."
|
||||
|
||||
# Descriptions in Telegram's command menu. Keep them short.
|
||||
[menu]
|
||||
dl = "Download a video from a link"
|
||||
audio = "Download the audio as MP3"
|
||||
thumb = "Get the thumbnail"
|
||||
info = "Show formats and sizes"
|
||||
queue = "Your downloads in progress"
|
||||
cancel = "Cancel your downloads"
|
||||
help = "How to use the bot"
|
||||
|
||||
[hint]
|
||||
send_link = "Send me a link to a video or a song and I will fetch it. /help has the details."
|
||||
|
||||
[dl]
|
||||
usage = "Add a link after the command, or reply to a message that has a link.\nExample: <code>/dl https://example.com/video</code>"
|
||||
|
||||
[info]
|
||||
usage = "Add a link after the command.\nExample: <code>/info https://example.com/video</code>"
|
||||
line = "{{.Label}}: {{.Size}}"
|
||||
size_unknown = "size unknown"
|
||||
|
||||
[queue]
|
||||
empty = "You have no downloads in progress."
|
||||
|
||||
[queue.header]
|
||||
one = "<b>You have {{.Count}} download in progress</b>"
|
||||
other = "<b>You have {{.Count}} downloads in progress</b>"
|
||||
|
||||
[cancel]
|
||||
nothing = "There is nothing to cancel."
|
||||
|
||||
[cancel.done]
|
||||
one = "Cancelled {{.Count}} download."
|
||||
other = "Cancelled {{.Count}} downloads."
|
||||
|
||||
[card]
|
||||
looking = "Looking up the link…"
|
||||
pick = "Pick a format:"
|
||||
cancelled = "Cancelled."
|
||||
|
||||
[btn]
|
||||
best = "Best"
|
||||
res = "{{.Height}}p"
|
||||
mp3 = "MP3"
|
||||
m4a = "M4A"
|
||||
thumb = "Thumbnail"
|
||||
subs = "Subtitles ({{.Lang}})"
|
||||
with_size = "{{.Label}} · {{.Size}}"
|
||||
cancel = "Cancel"
|
||||
|
||||
[status]
|
||||
queued = "In the queue. Position {{.Position}}, about {{.Wait}}."
|
||||
downloading = "Downloading…"
|
||||
downloading_bytes = "Downloading… {{.Done}}"
|
||||
downloading_progress = "Downloading…\n{{.Bar}} {{.Percent}}\n{{.Done}} of {{.Total}}"
|
||||
processing = "Processing the file…"
|
||||
uploading = "Sending it to Telegram…"
|
||||
done = "Done. Enjoy."
|
||||
cancelled = "Cancelled."
|
||||
failed = "That did not work. {{.Reason}}"
|
||||
|
||||
[notice]
|
||||
cancelled = "Cancelled."
|
||||
not_yours = "These buttons belong to the person who asked."
|
||||
too_late = "Too late to cancel that."
|
||||
expired = "This card has expired. Send the link again."
|
||||
already_chosen = "A download from this card is already running."
|
||||
|
||||
[limit]
|
||||
too_large = "This file is larger than your limit of {{.MaxSize}}. Try a lower quality."
|
||||
too_long = "This is longer than your limit of {{.MaxDuration}}."
|
||||
live = "Live streams cannot be downloaded."
|
||||
queue_full = "The queue is full right now. Please try again in a few minutes."
|
||||
|
||||
[limit.active_jobs]
|
||||
one = "You already have {{.Count}} download running. Wait for it to finish or use /cancel."
|
||||
other = "You already have {{.Count}} downloads running. Wait for one to finish or use /cancel."
|
||||
|
||||
[unit.seconds]
|
||||
one = "{{.Count}} second"
|
||||
other = "{{.Count}} seconds"
|
||||
|
||||
[unit.minutes]
|
||||
one = "{{.Count}} minute"
|
||||
other = "{{.Count}} minutes"
|
||||
|
||||
[unit.hours]
|
||||
one = "{{.Count}} hour"
|
||||
other = "{{.Count}} hours"
|
||||
|
||||
# One message per failure class. The raw tool output goes to the owner logs
|
||||
# only, never to the user.
|
||||
[error]
|
||||
unsupported_url = "I cannot download from that link."
|
||||
not_found = "Nothing was found at that link. It may have been removed."
|
||||
private = "This content is private or for members only."
|
||||
login_required = "This content needs a login on the site, so I cannot fetch it."
|
||||
geo_blocked = "This content is not available in the region I download from."
|
||||
site_blocked = "The site refused the download right now. Please try again later."
|
||||
rate_limited = "The site is limiting requests right now. Please try again in a few minutes."
|
||||
live_stream = "Live streams cannot be downloaded."
|
||||
drm = "This content is copy protected and cannot be downloaded."
|
||||
too_large = "The file is larger than your limit. Try a lower quality."
|
||||
too_long = "This is longer than your limit."
|
||||
no_media = "No video or audio was found in the format you picked."
|
||||
no_subtitles = "No subtitles were found in that language."
|
||||
network = "A network problem interrupted the download. Please try again."
|
||||
timeout = "The download took too long and was stopped."
|
||||
processing_failed = "The file was downloaded but could not be processed."
|
||||
cancelled = "The download was cancelled."
|
||||
worker_lost = "The download was interrupted. Please try again."
|
||||
internal = "Something went wrong on my side. Please try again."
|
||||
unknown = "The download failed. Please try again later."
|
||||
playlist = "That link is a playlist. Send the link of a single video for now."
|
||||
send_failed = "I could not send the file to Telegram. Please try again."
|
||||
Reference in New Issue
Block a user