mirror of
https://github.com/tiennm99/tiennm99bot.git
synced 2026-10-11 03:13:46 +00:00
/addsticker becomes a single stateless command in util, writing to one env-configured set (STICKER_PACK_NAME, default miti99_by_miti99bot). AddStickerToSet takes the set owner's user ID rather than the caller's, so nothing is per-user any more: the sticker module's pack records, slug reservations, pending deletes, per-user locks and its eight other commands are removed with it. The pack creates itself on first use. A positive STICKERSET_INVALID from the add triggers createNewStickerSet owned by OWNER_ID, seeded with the sticker that triggered it and titled with the slug half of the name; a name that is occupied but unwritable is reported instead of taken over. The mandatory "_by_<bot_username>" suffix is Telegram's own proof of authorship, so a misconfigured pack name is refused offline before any API call. StickerSet exposes no owner ID, so ownership is only provable when Telegram refuses. Video, GIF, animation and video-note sources are transcoded to WEBM/VP9 with ffmpeg: long edge scaled to exactly 512 in either direction, cut to 3s, capped at 30fps, audio dropped, retried down a CRF ladder until under 256KB. Animated and video stickers are copied by file_id with no conversion. Sticker format is per-sticker since Bot API 7.2, so one pack holds all three. ffmpeg cannot ship in distroless/static and Go has no VP9 encoder, so the runtime base becomes alpine with apk add ffmpeg. The image grows from roughly 20MB to 213MB, and the transcode holds the single dispatcher worker — bounded at 20s per encode and a 45s handler deadline for moving sources, against 10s for stills.
56 lines
2.8 KiB
Bash
56 lines
2.8 KiB
Bash
# miti99bot — self-host (Coolify + MongoDB Atlas) environment.
|
|
# Copy to .env and fill in. .env is gitignored — never commit real secrets.
|
|
|
|
# ============================ Required ============================
|
|
# Telegram bot token from @BotFather.
|
|
TELEGRAM_BOT_TOKEN=123456:ABC-DEF...
|
|
|
|
# MongoDB Atlas connection. MONGO_URL is the full SRV string INCLUDING the
|
|
# db username + password — treat it as a secret (it is never logged).
|
|
# Create a least-privilege user: readWrite on this one database only.
|
|
MONGO_URL=mongodb+srv://botuser:STRONG_UNIQUE_PASSWORD@cluster0.xxxxx.mongodb.net/?retryWrites=true&w=majority
|
|
MONGO_DATABASE=miti99bot
|
|
|
|
# ============================ Operational =========================
|
|
# Comma-separated module list. Empty = load every module, including any module
|
|
# added later — so list them explicitly when a deployment should only gain a new
|
|
# module deliberately.
|
|
MODULES=util,misc,amlich,wordle,loldle,lol,stock,gold,coin,stats,monkeyd
|
|
# Telegram user id for owner-only commands (renamed from BOT_OWNER_ID).
|
|
OWNER_ID=
|
|
# Comma-separated admin Telegram user ids (renamed from ADMIN_USER_IDS).
|
|
ADMIN_IDS=
|
|
|
|
# Sticker set /addsticker writes to. Every user contributes to this one pack.
|
|
# MUST end in _by_<this bot username>: Telegram requires that suffix on sets a
|
|
# bot creates and refuses to edit sets it did not create, so the suffix is what
|
|
# proves the pack is manageable. Created automatically, owned by OWNER_ID, on
|
|
# the first /addsticker if it does not exist yet. Unset = the default below.
|
|
STICKER_PACK_NAME=miti99_by_miti99bot
|
|
|
|
# SOURCE_COMMIT (commit SHA) is read at startup for the deploynotify owner DM.
|
|
# Do NOT set it here. Coolify provides it at runtime. Keep "Include Source
|
|
# Commit in Build" disabled so Docker layer cache survives across commits.
|
|
# Local `docker compose up` has none, so deploynotify reports "unknown".
|
|
|
|
# PandaScore API token for the lol module's schedule fetches (free tier at
|
|
# https://app.pandascore.co/dashboard, no credit card). Secret — never logged.
|
|
# Without it every /lol* fetch fails; the stale cache covers ≤60 min.
|
|
LOL_PANDASCORE_TOKEN=
|
|
|
|
# Optional /wheelofnames GIF renderer. Standard deployment:
|
|
# https://github.com/tiennm99/wheelofnames. Leave blank to fall back to text
|
|
# selection.
|
|
WHEELOFNAMES_API_URL=
|
|
# Bearer token matching the wheelofnames service API_TOKEN when URL is set.
|
|
WHEELOFNAMES_API_TOKEN=
|
|
|
|
# ====================== Leave UNSET on self-host ==================
|
|
# Defaults are correct for self-host:
|
|
# KV_PROVIDER — auto-selects mongodb because MONGO_URL is set
|
|
# PORT — defaults to 8080 (internal health server)
|
|
# TELEGRAM_WEBHOOK_SECRET — long polling has no webhook
|
|
# GOLD_VNAPP_API_KEY — gold module auto-fetches + caches the key to Mongo
|
|
# Stock/coin/gold URL env overrides are not supported; modules use coded
|
|
# default providers.
|