Kortopi is a Telegram bot running on Cloudflare Workers that automatic cleaning of tracking parameters (like utm_*, fbclid) from shared links, protecting privacy and keeping groups clean.
- Link Cleaning: Automatically removes tracking parameters and resolves redirects.
- Group Interaction: "Delete & Repost" mechanism to maintain chat cleanliness.
- Permissions: Whitelist support for users and groups.
No server required. You can deploy this using the free tier of Cloudflare Workers.
- Cloudflare Account.
- Telegram Bot Token (via @BotFather).
Node.jsandnpminstalled.
Clone the code and install dependencies:
npm installWe recommend putting non-sensitive config in wrangler.toml and sensitive config (like Tokens) in Cloudflare Secrets.
-
Modify
wrangler.toml(Non-sensitive):[vars] # Comma-separated User IDs allowed to PM the bot. Leave empty for no restriction. ALLOWED_USERS = "12345678" # Comma-separated Group IDs where the bot is active. ALLOWED_GROUPS = "-100xxxxxxx,-100yyyyyyy" # (Optional) Target Group ID to forward private messages to. TARGET_GROUP_ID = "-100xxxxxxx"
-
Set Secrets (Sensitive): Set the Bot Token via command line. Do not commit this to code.
npx wrangler secret put BOT_TOKEN
(Enter your Telegram Bot Token when prompted)
npm run deployAfter success, you will get a Worker URL like https://kortopi.your-subdomain.workers.dev.
You need to tell Telegram to push messages to your Worker. Replace <YOUR_WORKER_URL> and <BOT_TOKEN> below and run in terminal:
curl -F "url=https://<YOUR_WORKER_URL>/webhook" https://api.telegram.org/bot<BOT_TOKEN>/setWebhookStart local dev server:
# Set local env vars first
echo "BOT_TOKEN=your_fake_token" > .dev.vars
npm run devAll cleaning rules are in src/config.ts. You can adjust the global blocklist or domain-specific rules there.