Phase 6: inline mode and docs

- Inline mode (INLINE_MODE_ENABLED): "@bot <link>" sends the cached file
  by file_id when the user's limits admit it without payment, and
  otherwise one result that opens the bot with /start il_<token> for the
  link. An inline send counts as a download when Telegram reports it
  chosen (inline feedback). The bot asks Telegram for inline_query and
  chosen_inline_result updates.
- README, OPERATIONS and ARCHITECTURE describe the new flows, Stars,
  inline mode and every new setting; docs/SCREENS.md regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Michilis
2026-11-18 21:47:26 +00:00
co-authored by Claude Opus 5.5
parent d64db03f21
commit 44d0905fa3
18 changed files with 591 additions and 27 deletions
+17
View File
@@ -103,6 +103,8 @@ type Bot struct {
// cancelledAt is when each user last sent /cancel. A playlist item
// that was already being looked up at that moment must not start.
cancelledAt map[int64]time.Time
// inlineChoices are cached files offered inline, by result token.
inlineChoices map[string]inlineChoice
// menuButtons is the language each private chat's menu button was
// last labelled in.
menuButtons map[int64]string
@@ -164,6 +166,7 @@ func New(ctx context.Context, d Deps) (*Bot, error) {
cancelledAt: map[int64]time.Time{},
broadcasts: map[string]string{},
menuButtons: map[int64]string{},
inlineChoices: map[string]inlineChoice{},
reloadI18n: d.ReloadI18n,
broadcastGap: 50 * time.Millisecond,
admins: d.Admins,
@@ -304,6 +307,10 @@ func updateChatID(u telego.Update) int64 {
return u.MyChatMember.Chat.ID
case u.PreCheckoutQuery != nil:
return u.PreCheckoutQuery.From.ID
case u.InlineQuery != nil:
return u.InlineQuery.From.ID
case u.ChosenInlineResult != nil:
return u.ChosenInlineResult.From.ID
case u.WidgetQuery != nil:
if u.WidgetQuery.Chat != nil {
return u.WidgetQuery.Chat.ID
@@ -336,6 +343,10 @@ func (b *Bot) HandleUpdate(ctx context.Context, u telego.Update) {
b.handleWidgetQuery(ctx, u.WidgetQuery)
case u.PreCheckoutQuery != nil:
b.handlePreCheckout(ctx, u.PreCheckoutQuery)
case u.InlineQuery != nil:
b.handleInlineQuery(ctx, u.InlineQuery)
case u.ChosenInlineResult != nil:
b.handleChosenInlineResult(ctx, u.ChosenInlineResult)
}
}
@@ -353,6 +364,8 @@ func updateUser(u telego.Update) (*telego.User, *telego.Chat) {
return &u.CallbackQuery.From, nil
case u.PreCheckoutQuery != nil:
return &u.PreCheckoutQuery.From, nil
case u.InlineQuery != nil:
return &u.InlineQuery.From, nil
}
return nil, nil
}
@@ -369,6 +382,10 @@ func updateType(u telego.Update) string {
return "widget_query"
case u.PreCheckoutQuery != nil:
return "pre_checkout_query"
case u.InlineQuery != nil:
return "inline_query"
case u.ChosenInlineResult != nil:
return "chosen_inline_result"
}
return "other"
}