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
+238
View File
@@ -37,6 +37,8 @@ In a group, use /dl with a link, or reply /dl to a message that has a link.
/history - your past downloads, with one tap to get them again
/queue - your running downloads
/cancel - cancel your downloads
/quality - your default format
/language - change my language
<b>Account</b>
/account - your pass, balance and usage
@@ -47,6 +49,10 @@ In a group, use /dl with a link, or reply /dl to a message that has a link.
/referral - invite friends and earn sats
/donate - send a tip
<b>In groups</b>
/groupwallet and /grouppass - the group's balance and pass
/settings - group settings, for admins
<b>Your limits</b>
Up to {{.MaxSize}} and {{.MaxDuration}} per download."""
@@ -97,6 +103,10 @@ pick = "Pick a format:"
cancelled = "Cancelled."
[btn]
full_settings = "Open full settings"
add_group_credits = "Add group credits"
buy_group_pass = "Buy a group pass"
open_app = "Open app"
best = "Best"
res = "{{.Height}}p"
mp3 = "MP3"
@@ -128,6 +138,9 @@ failed = "That did not work. {{.Reason}}"
refunded = "{{.Amount}} went back to your balance."
[notice]
group_only = "This command works in groups."
admins_only = "Only admins of this group can do that."
saved = "Saved."
cancelled = "Cancelled."
not_yours = "These buttons belong to the person who asked."
too_late = "Too late to cancel that."
@@ -143,6 +156,11 @@ skip_too_late = "This download is not waiting in the queue anymore."
skip_private = "Open a private chat with me to pay for this."
[limit]
group_disabled = "The bot is switched off in this group."
group_admins_only = "In this group only admins can use the bot."
group_pass_only = "In this group you need a pass to use the bot. /buy in a private chat with me."
group_site = "The admins of this group do not allow downloads from that site."
maintenance = "I am down for maintenance. Please try again in a little while."
too_large = "This file is larger than your limit of {{.MaxSize}}. Try a lower quality."
too_long = "This is longer than your limit of {{.MaxDuration}}."
live = "Live streams cannot be downloaded."
@@ -292,6 +310,9 @@ cashu_off = "Cashu tokens are not accepted on this bot."
cashu_mint = "I do not accept tokens from that mint."
[invoice]
for_group = "For the group <b>{{.Group}}</b>"
group_balance = "The group balance is now {{.Balance}}."
group_pass_until = "The group pass is active until {{.Until}}."
memo = "The Noderunners Download Bot: {{.Title}}"
caption = """
<b>{{.Title}}</b> · {{.Amount}}
@@ -354,6 +375,81 @@ line = "{{.N}}. {{.Title}} · {{.Label}}"
# --- Owner commands ---------------------------------------------------------
[owner]
books_ok = "ledger and balances agree"
ln_ok = "reachable"
ln_down = "NOT reachable"
queue_empty = "No jobs are queued or running."
queue_line = "<code>{{.ID}}</code> {{.Status}} · {{.Lane}} · {{.Profile}} · worker {{.Worker}} · tags {{.Tags}}\n{{.Title}}"
user_usage = "Example: <code>/user 123456789</code>"
group_usage = "Example: <code>/group -1001234567890</code>"
not_found = "Not found."
user = """
<b>User {{.ID}}</b>
Name: {{.Name}} (@{{.Username}})
Language: {{.Lang}}
Banned: {{.Banned}}
Pass until: {{.Pass}}
Balance: {{.Balance}}
Today: {{.Downloads}} downloads, {{.Volume}}
Referrals: {{.Referrals}}
First seen: {{.Since}}"""
group = """
<b>Group {{.ID}}</b>
Title: {{.Title}}
Bot status: {{.Status}}
Bot enabled: {{.Enabled}}
Who can use it: {{.Who}}
Credit spending: {{.Spend}}
Pass until: {{.Pass}}
Balance: {{.Balance}}"""
ban_usage = "Example: <code>/ban 123456789</code> and <code>/unban 123456789</code>"
ban_owner = "An owner cannot be banned."
banned = "User {{.ID}} is banned."
unbanned = "User {{.ID}} is no longer banned."
grant_usage = """
Give a pass to a user or a group (groups have negative IDs):
<code>/grant 123456789 week</code>
Create a gift code:
<code>/grant code credits 1000 5</code>
<code>/grant code month</code>"""
gift_code = "Gift code: <code>{{.Code}}</code>\nUses: {{.Uses}}"
granted = "Done. The pass of {{.ID}} runs until {{.Until}}."
credit_usage = "Example: <code>/credit 123456789 500</code>"
refund_usage = "Examples:\n<code>/refund 123456789 500</code>\n<code>/refund 123456789 pass 24h</code>"
no_pass = "That wallet has no active pass to extend."
credited = "Done. {{.Amount}} added to {{.ID}}. Balance: {{.Balance}}."
blocklist_empty = "The blocklist is empty."
blocklist_header = "<b>Blocklist</b>"
blocklist_line = "{{.Kind}}: <code>{{.Value}}</code> {{.Reason}}"
blocklist_usage = """
<code>/blocklist</code>
<code>/blocklist add site example.com spam</code>
<code>/blocklist add key youtube:VIDEOID</code>
<code>/blocklist remove site example.com</code>"""
blocked = "Blocked: <code>{{.Value}}</code>"
unblocked = "Unblocked: <code>{{.Value}}</code>"
maint_usage = "Use <code>/maint on</code> or <code>/maint off</code>."
maint_on = "Maintenance mode is on. New downloads are refused for everyone but owners."
maint_off = "Maintenance mode is off."
reload_usage = "Use <code>/reload i18n</code>."
reload_builtin = "The translations are built into the binary. Set LOCALES_DIR to load them from a directory."
reload_failed = "Reloading failed, the old translations stay in use.\n<code>{{.Error}}</code>"
reloaded = "Translations reloaded: {{.Langs}}"
broadcast_usage = "Example: <code>/broadcast The bot will be down tonight from 22:00 UTC.</code>"
broadcast_preview = "<b>Preview</b>\n\n{{.Text}}"
broadcast_done = "Broadcast finished. Sent: {{.Sent}}. Failed: {{.Failed}}."
stats = """
<b>Stats</b>
Users: {{.Users}}
Last 24 hours: {{.Done}} done, {{.Failed}} failed
Queue: {{.Paid}} paid, {{.Free}} free, oldest waiting {{.Oldest}}
Workers: {{.Running}} of {{.Slots}} slots busy
Cache hit rate: {{.Rate}}, saved {{.Saved}}
Received: {{.Sats}}
Invoices since start: {{.Created}} created, {{.Settled}} settled
Lightning: {{.Lightning}}
Books: {{.Books}}
Maintenance: {{.Maint}}"""
never = "never"
state_active = "active"
state_offline = "offline"
@@ -389,3 +485,145 @@ other = "Asked {{.Count}} workers to update yt-dlp. They do so when they next ch
[owner.purged]
one = "Taken down: <code>{{.Key}}</code>\n{{.Count}} cached file was removed. The key is blocked."
other = "Taken down: <code>{{.Key}}</code>\n{{.Count}} cached files were removed. The key is blocked."
[owner.books_bad]
one = "{{.Count}} wallet DISAGREES with its ledger"
other = "{{.Count}} wallets DISAGREE with their ledgers"
[owner.queue_header]
one = "<b>{{.Count}} active job</b>"
other = "<b>{{.Count}} active jobs</b>"
[owner.broadcast_send]
one = "Send to {{.Count}} user"
other = "Send to {{.Count}} users"
# --- Groups ------------------------------------------------------------------
[word]
on = "on"
off = "off"
none = "none"
[settings]
text = """
<b>Group settings</b>
Balance: {{.Balance}} · Pass until: {{.Pass}}
Language: {{.Lang}}
Allowed sites: {{.Allowed}}
Blocked sites: {{.Blocked}}
Per person per day: {{.SpendCap}} · Group per day: {{.DailyCap}}
Tap to change. More with /grouplang, /allow, /block and /spending."""
button = "{{.Label}}: {{.Value}}"
enabled = "Bot"
auto_detect = "Detect pasted links"
delete_commands = "Delete command messages"
who = "Who can use it"
who_everyone = "everyone"
who_pass_holders = "pass holders"
who_admins = "admins"
spend = "Group credits"
spend_anyone = "anyone"
spend_admins = "admins only"
spend_capped = "anyone, capped"
quality = "Default quality"
lang_auto = "each member's own"
commands = """
<b>Settings of {{.Group}}</b>
Send these in the group, as an admin:
/settings - quick switches
/grouplang code - language of the bot in the group
/autodetect on - fetch links without a command
/allow site - only allow some sites
/block site - block a site
/spending rule - who may spend group credits"""
[quality]
ask = "Ask every time"
pick = "Pick your default format. I will then start right away instead of asking."
set = "Default format: {{.Quality}}"
[language]
name = "English"
auto = "Follow my Telegram language"
pick = "Pick a language:"
set = "Language: {{.Lang}}"
[grouplang]
usage = "Add a language code, or <code>auto</code> to follow each member.\nAvailable: {{.Langs}}"
auto = "The bot now answers each member in their own language."
set = "The bot now speaks {{.Lang}} in this group."
[autodetect]
usage = "Use <code>/autodetect on</code> or <code>/autodetect off</code>."
on = "I will now fetch links pasted in this group without a command. For that I need to see messages: make me an admin, or turn off group privacy for me in @BotFather."
off = "I will only act on commands in this group."
[allow]
list = "Allowed sites: {{.Sites}}\nAdd with <code>/allow example.com</code>, remove with <code>/allow remove example.com</code>, reset with <code>/allow clear</code>. With an empty list every site is allowed."
[block]
list = "Blocked sites: {{.Sites}}\nAdd with <code>/block example.com</code>, remove with <code>/block remove example.com</code>, reset with <code>/block clear</code>."
[sites]
bad_host = "That does not look like a site. Example: <code>example.com</code>"
[spending]
usage = """
Who may spend group credits:
<code>/spending admins</code>
<code>/spending anyone</code>
<code>/spending capped 200</code> (sats per person per day)
<code>/spending daily 5000</code> (sats per day for the whole group, 0 for no cap)"""
set = "Group credits: {{.Rule}}.\nPer person per day: {{.SpendCap}}. Group per day: {{.DailyCap}}."
[groupwallet]
text = "<b>Group wallet</b>\nBalance: {{.Balance}}\n{{.Pass}}\nWho can spend credits: {{.Rule}}"
pass_none = "Pass: none"
pass_until = "Pass: active until {{.Until}}"
[grouppass]
text = "<b>Group pass</b>\n{{.Pass}}\nWith a group pass everyone here downloads with the higher limits and in the priority queue."
[groupstats]
empty = "Nobody used the bot here in the last 7 days."
header = "<b>Last 7 days</b>"
[groupstats.line]
one = "{{.Name}}: {{.Count}} download, {{.Size}}, {{.Sats}}"
other = "{{.Name}}: {{.Count}} downloads, {{.Size}}, {{.Sats}}"
[groupbuy]
unknown = "I do not know that group, or I am no longer in it."
intro = "<b>{{.Group}}</b>\nGroup balance: {{.Balance}}\n\nWhat you buy here belongs to the group: a pass covers every member, credits are spent by the group's rules."
[app]
unavailable = "The app is not set up on this bot."
open = "Open the app to manage downloads, passes and groups."
# --- Static pages ------------------------------------------------------------
[static]
privacy = """
<b>Privacy</b>
I store what I need to work: your Telegram ID and name, your language, the links you send me and the files made from them, your balance and purchases, and counts of your usage.
Downloaded files are kept for a limited time so repeats are fast, then deleted. Files from links that need a login are never kept or shared.
I do not sell data and I do not ask who you are. Payments are in sats over Lightning.
To have your data removed, contact {{.Contact}}."""
terms = """
<b>Terms</b>
Use the bot only for content you have the right to download. You are responsible for what you fetch and share.
Passes and credits are not refundable once used. A download that fails is refunded automatically.
The service comes as it is, without a guarantee that a given site works. Abuse leads to a ban.
Questions: {{.Contact}}"""
support = "Need help? Write to {{.Contact}}.\n\n/help lists what I can do."