Lightning payments through LNbits, wallets, passes, credits, the entitlement resolver and priority lanes. - internal/entitle: pure resolver (one-off, own pass, group pass, group credits, own credits, free) with a table-driven suite and an invariant check over every input combination - internal/billing: wallets, append-only ledger with dedupe keys, stacking passes, purchases, gift codes, referral reward - LNbits client verified against v0.12.12 and v1.7.1 source - Settlement by one conditional UPDATE: idempotent under any mix of webhooks, polls and the check button. Webhooks are unsigned, so every payment is confirmed with LNbits before it is credited - Polling fallback, reconciliation of all unsettled invoices at startup, late payments still honored, no expiry while LNbits is unreachable - Charge, quota and job are written in one transaction; failed, cancelled and undeliverable downloads are refunded exactly once - Paid lane first with one slot of the fleet reserved for free users - Daily download quota and daily volume cap, per-user and per-group rate limits - Bot: /buy /account /limits /credits /redeem /referral /donate, QR invoice message that flips to paid, over-limit offer (passes or this file only), deep links from groups, skip the queue - Fake LNbits server for tests; end-to-end money flows including a payment made while the core was down Cashu redemption is behind an interface and not implemented. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
package bot
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/mymmrac/telego"
|
|
)
|
|
|
|
// menuCommands are the commands shown in Telegram's command menu, in
|
|
// order. Names are lowercase ASCII in every language; only descriptions
|
|
// are translated, under "menu.<name>".
|
|
var menuCommands = []string{"dl", "audio", "thumb", "info", "queue", "cancel", "account", "buy", "help"}
|
|
|
|
// RegisterCommands publishes the command menu. A failure is logged and
|
|
// otherwise ignored: the bot works without a menu.
|
|
func (b *Bot) RegisterCommands(ctx context.Context) {
|
|
for _, lang := range b.tr.Langs() {
|
|
cmds := make([]telego.BotCommand, 0, len(menuCommands))
|
|
for _, name := range menuCommands {
|
|
cmds = append(cmds, telego.BotCommand{Command: name, Description: b.tr.T(lang, "menu."+name, nil)})
|
|
}
|
|
params := &telego.SetMyCommandsParams{Commands: cmds}
|
|
if lang != b.tr.Langs()[0] {
|
|
// The source language is the default menu; the others are
|
|
// registered for their own language code.
|
|
params.LanguageCode = lang
|
|
}
|
|
if err := b.api.SetMyCommands(ctx, params); err != nil {
|
|
b.log.Warn("setMyCommands failed", "lang", lang, "err", err)
|
|
}
|
|
}
|
|
}
|