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:
co-authored by
Claude Fable 5.2
parent
7d4893bc3f
commit
51371da0e0
+35
-2
@@ -89,8 +89,36 @@ func Load(fsys fs.FS, log *slog.Logger) (*Bundle, error) {
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// Pseudo is the pseudo-locale: English with every letter accented and
|
||||
// each string wrapped in brackets. Text that shows up plain while it is
|
||||
// selected did not come from the catalog.
|
||||
const Pseudo = "en-XA"
|
||||
|
||||
// Hidden reports whether a language is for testing and should not be
|
||||
// offered to users.
|
||||
func (b *Bundle) Hidden(lang string) bool { return strings.EqualFold(lang, Pseudo) }
|
||||
|
||||
// Reload replaces the catalogs with the ones in fsys. When they do not
|
||||
// load, the old ones stay in use and the error says why.
|
||||
func (b *Bundle) Reload(fsys fs.FS) error {
|
||||
fresh, err := Load(fsys, b.log)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
b.bundle, b.tags, b.names, b.matcher = fresh.bundle, fresh.tags, fresh.names, fresh.matcher
|
||||
b.localizers = map[string]*goi18n.Localizer{}
|
||||
b.printers = map[string]*message.Printer{}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Langs returns the loaded language tags, English first.
|
||||
func (b *Bundle) Langs() []string { return append([]string(nil), b.names...) }
|
||||
func (b *Bundle) Langs() []string {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
return append([]string(nil), b.names...)
|
||||
}
|
||||
|
||||
// Resolve maps any language code, such as the language_code Telegram sends,
|
||||
// to the closest loaded language. Regional variants fall back to their base
|
||||
@@ -103,6 +131,8 @@ func (b *Bundle) Resolve(code string) string {
|
||||
if err != nil {
|
||||
return Default
|
||||
}
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
_, idx, conf := b.matcher.Match(tag)
|
||||
if conf == language.No {
|
||||
return Default
|
||||
@@ -189,7 +219,10 @@ func (b *Bundle) Has(lang, id string) bool {
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
_, gotTag, err := goi18n.NewLocalizer(b.bundle, lang).LocalizeWithTag(&goi18n.LocalizeConfig{
|
||||
b.mu.Lock()
|
||||
bundle := b.bundle
|
||||
b.mu.Unlock()
|
||||
_, gotTag, err := goi18n.NewLocalizer(bundle, lang).LocalizeWithTag(&goi18n.LocalizeConfig{
|
||||
MessageID: id, PluralCount: 2, TemplateData: map[string]any{},
|
||||
})
|
||||
return err == nil && gotTag == tag
|
||||
|
||||
Reference in New Issue
Block a user