Phase 5: groups

Group wallets, group passes, spending rules and admin-only settings.

- Groups recorded from my_chat_member; admin rights verified with
  getChatMember and cached for five minutes
- Group context in entitlement resolution: group pass, group credits under
  the spending rule (anyone, admins only, capped per person per day) and
  the group's daily cap; refunds go back to the wallet that paid
- Group gate before any lookup: bot on or off, who may use it, allowed
  and blocked sites, plus the owner's maintenance mode
- /settings with inline toggles checked on every press, /grouplang,
  /autodetect, /allow, /block, /spending, /groupwallet, /grouppass,
  /groupstats
- Deep links with the target pre-selected: paying for a group happens in
  the private chat; a refused download in a group offers "Buy for me" and
  "Add group credits"
- Optional link detection, tidy mode, default quality and language per
  group; per-member usage
- /quality, /language, /app, /privacy, /terms, /support
- Remaining owner tools: /stats, /queue all, /user, /group, /ban, /unban,
  /grant (passes and gift codes), /credit, /refund, /blocklist,
  /broadcast with confirmation, /maint, /reload i18n

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Michilis
2026-11-18 09:46:32 +00:00
co-authored by Claude Fable 5.2
parent 7d4893bc3f
commit 51371da0e0
23 changed files with 3231 additions and 81 deletions
+11 -1
View File
@@ -479,10 +479,20 @@ func TestGroupOverLimitUsesDeepLinks(t *testing.T) {
if offer.ChatID() != group {
t.Fatalf("the offer must answer in the group")
}
// Both targets are offered, and both are plain links: web app buttons
// and invoices do not belong in a group.
btns := offer.Buttons()
if len(btns) != 1 || btns[0].Text != "Buy for me" || btns[0].Data != "" {
if len(btns) != 2 || btns[0].Text != "Buy for me" || btns[1].Text != "Add group credits" {
t.Fatalf("group offer buttons = %+v", btns)
}
for _, b := range btns {
if b.Data != "" || !strings.HasPrefix(b.URL, "https://t.me/"+fakeserver.BotUsername+"?start=") {
t.Fatalf("group offer button is not a deep link: %+v", b)
}
}
if !strings.HasSuffix(btns[1].URL, fmt.Sprintf("?start=gw_%d", group)) {
t.Fatalf("group credits link = %q", btns[1].URL)
}
prefix := "https://t.me/" + fakeserver.BotUsername + "?start=buy_"
if !strings.HasPrefix(btns[0].URL, prefix) {
t.Fatalf("deep link = %q", btns[0].URL)