A Telegram bot that rewrites social share links into cleaner public URLs.
Designed to run on EdgeOne Makers Edge Functions (similar in spirit to Cloudflare Workers).
This repository is a self-host template. Deploy your own instance; do not treat other people’s production bots as a free public service.
After the site deploys, you still need to call Telegram setWebhook once (see Quick start). EdgeOne cannot set the webhook for you.
Official docs: Deploy button.
| Source | Result |
|---|---|
x.com |
fixupx.com |
twitter.com |
fxtwitter.com |
bsky.app |
fxbsky.app |
zhihu.com / zhuanlan.zhihu.com |
fxzhihu.com / zhuanlan.fxzhihu.com |
b23.tv (and similar short hosts) |
clean bilibili.com (tracking removed) |
Long bilibili.com links with trackers |
same cleaning (p=1 dropped; p≥2 and t kept) |
- Replies with plain URLs only (easy to copy).
- Stays silent when the message has no supported links.
- Optional private mode: only allowlisted users get any reply (see below).
.
├─ edge-functions/
│ ├─ api/
│ │ ├─ telegram.js # POST /api/telegram (webhook)
│ │ └─ health.js # GET /api/health
│ └─ lib/ # link rewrite, bilibili resolve, allowlist
├─ public/index.html # optional landing page
├─ edgeone.json
├─ .env.example
├─ LICENSE # MIT
└─ package.json
| Field | Value |
|---|---|
| Root directory | ./ |
| Build / install command | leave empty |
| Output directory | public |
edgeone.json sets "outputDirectory": "public".
Use @BotFather → /newbot and copy the HTTP API token.
- Import this repository into EdgeOne Makers (or your preferred host that runs the same
edge-functionslayout). - Configure environment variables (host console — never commit secrets):
| Name | Required | Default | Description |
|---|---|---|---|
BOT_TOKEN |
yes | — | BotFather API token |
WEBHOOK_SECRET |
recommended | — | Random string; must match setWebhook secret_token |
PRIVILEGED_ONLY |
no | false |
When true, only privileged users receive replies |
BOOTSTRAP_PRIVILEGED_IDS |
no* | empty | Comma-separated Telegram user ids (*needed if PRIVILEGED_ONLY=true) |
KV is optional. You do not need to bind KV for a normal public bot, or for private mode with a fixed allowlist in BOOTSTRAP_PRIVILEGED_IDS.
- Deploy and note the HTTPS origin (e.g.
https://your-app.edgeone.app).
export BOT_TOKEN='...'
export WEBHOOK_SECRET='...' # same as env, if set
export BASE='https://YOUR_DOMAIN'
curl -sS "https://api.telegram.org/bot${BOT_TOKEN}/setWebhook" \
--data-urlencode "url=${BASE}/api/telegram" \
--data-urlencode "secret_token=${WEBHOOK_SECRET}" \
--data-urlencode 'allowed_updates=["message"]'curl -sS "https://api.telegram.org/bot${BOT_TOKEN}/getWebhookInfo"GET https://YOUR_DOMAIN/api/health→{"ok":true,...}- In Telegram:
/start, then paste anx.comorb23.tvlink
| Command | Audience | Action |
|---|---|---|
/help |
everyone who can talk to the bot | usage |
/whoami |
same | numeric Telegram user id |
When PRIVILEGED_ONLY=true, non-allowlisted users get no replies (including commands).
Not listed in /help. Only users already on the allowlist can use them; others get silence.
| Command | Requires | Action |
|---|---|---|
/status |
privileged | show mode + whether KV is bound |
/grant <id> |
privileged + PRIV_KV | add user to KV allowlist |
/revoke <id> |
privileged + PRIV_KV | remove from KV |
/list |
privileged | list bootstrap + KV ids |
| Goal | Configuration |
|---|---|
| Open bot (default) | omit PRIVILEGED_ONLY or set false — no KV needed |
| Only you / a fixed list | PRIVILEGED_ONLY=true and BOOTSTRAP_PRIVILEGED_IDS=111,222 — no KV needed |
| Dynamic allowlist | bind EdgeOne KV as variable name PRIV_KV, keep at least one bootstrap id who can /grant others |
Discover your user id with /whoami while the bot is still open (PRIVILEGED_ONLY off), then enable private mode and redeploy.
- Never commit
.envor real tokens (see.gitignoreand.env.example). - Prefer
WEBHOOK_SECRETso random clients cannot POST fake updates to your webhook URL. - If a token leaks: BotFather → revoke → update host env →
setWebhookagain.
- FxEmbed — FixupX / FxTwitter / FxBluesky
- fxzhihu — Zhihu fix instances
- b23.tv-tools, b23.wtf — short-link expansion & tracking cleanup ideas
- EdgeOne Makers — hosting platform
- Development assistance from Grok (xAI)