Phase 1: quick flow fixes

- One message per job: the status message is deleted once the file is
  sent, or shortened to "Sent." when Telegram keeps it.
- No reply quotes in private chats; groups keep them.
- Queue status only mentions the position when the wait is above
  QUEUE_NOTICE_THRESHOLD_SECONDS or somebody is ahead. Status edits are
  throttled to one per 2.5 s per message; a state that arrives too soon
  is shown later instead of dropped. The wait estimate is 0 with a free
  slot.
- Caption with title (uploader and date when generic), uploader,
  duration, a short source link without tracking parameters and an
  optional "via @bot" line (CAPTION_ATTRIBUTION). Uploaded videos get a
  320 px JPEG thumbnail; merged MP4s are written with faststart.
- Buttons under the result: Audio (MP3), Other quality, Thumbnail,
  Delete. Requester only in groups.
- Language resolved once per update and passed in the context. A
  fallback to English is logged as a bug; a test walks every screen in
  Spanish and Dutch. Language picker on the first /start.
- Sizes without a zero decimal ("50 MB").
- First link of a new user shows the card once and sets the default to
  "best that fits my limit".
- Errors offer the next step (Try again, Smaller quality, Upgrade, Open
  app); passing lookup failures are retried once.
- Up to MULTI_LINK_MAX links per message; a link sent a moment ago gets
  "already sent" with a Send again button.
- Mini App menu button, labelled per private chat in the user's
  language.
- Personal /settings in private chats with an "Add me to a group"
  button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Michilis
2026-11-18 20:08:58 +00:00
co-authored by Claude Opus 5.5
parent 3c153af97f
commit 6843053582
52 changed files with 3369 additions and 271 deletions
+11 -8
View File
@@ -97,8 +97,12 @@ func (b *Bot) jobState(ctx context.Context, d *db.Delivery, job *db.Job) widget.
s := widget.Job{Kind: "running", Progress: -1, RTL: i18n.Dir(lang) == "rtl", Cancel: b.tr.T(lang, "btn.cancel", nil)}
switch job.Status {
case db.JobQueued:
s.Kind = "queued"
pos, _ := b.sched.Position(ctx, job, b.slots())
if b.quietQueue(pos) {
s.Message = b.tr.T(lang, "status.downloading", nil)
break
}
s.Kind = "queued"
s.Message = b.tr.T(lang, "app.queue.waiting", i18n.Args{"Position": pos.Ahead + 1, "Wait": b.tr.Span(lang, pos.Wait)})
case db.JobRunning:
switch {
@@ -190,9 +194,7 @@ func (b *Bot) startLiveJob(ctx context.Context, d *db.Delivery, job *db.Job, dat
Caption: clip(titleLine(job.Title), 1024), ParseMode: telego.ModeHTML,
AllowQueries: true, ReplyMarkup: kb,
}
if d.ReplyToMessageID != 0 {
params.ReplyParameters = &telego.ReplyParameters{MessageID: int(d.ReplyToMessageID), AllowSendingWithoutReply: true}
}
// Widgets are for private chats, where nothing is quoted.
msg, err := b.api.SendWidget(ctx, params)
if err != nil {
b.widgetFailed("status", err)
@@ -226,7 +228,7 @@ func (b *Bot) startLiveJob(ctx context.Context, d *db.Delivery, job *db.Job, dat
// liveFinal shows the outcome of a delivery on its widget. It reports
// false when the delivery has no widget, or the widget is gone.
func (b *Bot) liveFinal(ctx context.Context, d *db.Delivery, text string) bool {
func (b *Bot) liveFinal(ctx context.Context, d *db.Delivery, text string, kb *telego.InlineKeyboardMarkup) bool {
lj := b.liveFor(ctx, d)
b.liveMu.Lock()
delete(b.live, d.ID)
@@ -243,9 +245,10 @@ func (b *Bot) liveFinal(ctx context.Context, d *db.Delivery, text string) bool {
if err := b.editWidget(ctx, d.ChatID, lj.messageID, data); err != nil && tg.IsMessageGone(err) {
return false
}
// The caption keeps the title; the buttons under it go.
if lj.buttons != "" {
_ = b.edit(ctx, d.ChatID, lj.messageID, true, title, nil)
// The caption keeps the title; the live buttons under it go, and the
// next steps, if any, take their place.
if lj.buttons != "" || kb != nil {
_ = b.edit(ctx, d.ChatID, lj.messageID, true, title, kb)
}
return true
}