Telegram bot written in Go that removes tracking parameters from links and makes them embed nicely.
When a message contains a link it can clean, the bot reposts it as @user said: <cleaned message> (with
buttons to the original links) and deletes the original. Instagram posts and TikTok photo posts are
downloaded and reposted as photos, videos or albums.
Add it to your Groupchat or use it private here: @sanitizeurlbot
- Send or forward a message with a link; the bot replaces it with the cleaned version.
- Include
nocutanywhere in the message to make the bot ignore it. - In groups, include
anonto repost without the@user said:prefix. - Inline mode: type
@sanitizeurlbot <link>in any chat to send the cleaned link yourself.
docker run -d -e TELEGRAM_BOT_TOKEN=<your-token> mecoblock/sanitizetelebot
alternatively you can use the compose.yml:
services:
sanitizetelebot:
image: mecoblock/sanitizetelebot
environment:
- TELEGRAM_BOT_TOKEN=#Your token here
networks: {}
- Get a Telegram Bot Token from BotFather
- Download the lastest artifact from the actions tab
- Create a token.txt file and paste in your Token from Botfather
- Run the executable
- Get a Telegram Bot Token from BotFather
- Clone the Repo
- Open the Terminal in the project directory and type
go build . - Create a token.txt file and paste in your Token from Botfather
- Run the executable
On startup the bot logs Connected to Telegram as @<bot> ... Listening for messages... once the token
has been accepted. The token is redacted from all log output.
Common tracking parameters (utm_*, fbclid, gclid, igsh, ...) are removed from every link; see
rules.go for the full list.
x.com links are rewritten to fixupx.com so Telegram shows a proper preview.
- Short links (
vm.tiktok.com,pro.tiktok.com) are expanded first. - Video links are rewritten to
vm.dstn.tofor an embeddable preview. - Photo posts (
/photo/) are downloaded via tikwm.com and reposted as an album (split into parts of 10), with the author and caption in an expandable quote below the link.
Posts, carousels (including mixed photo/video), reels and /tv/ links are downloaded by the bot itself
and reposted as photos, videos or an album (split into parts of 10). The author and caption are shown
in an expandable quote below the link.
The bot loads the public post page (instagram.com/p/<shortcode>/) like a logged-out browser and reads
the media from the JSON Instagram embeds in it; no third-party proxy is involved. /share/ links are
resolved to the canonical post URL, and all query parameters except img_index and q are dropped.
If a post can't be fetched (private account, login wall, rate limit, ...) the reason is logged and the cleaned instagram.com link is sent instead. Stories need a logged-in account, so story links are only cleaned.
| Environment variable | Default | Effect |
|---|---|---|
INSTAGRAM_LOCAL_FETCH |
true |
Set to false to never download Instagram media and only clean links. |
INSTAGRAM_FALLBACK_HOST |
(empty) | e.g. eeinstagram.com: rewrite post links to this host when local fetching is off or fails. |
To check parsing without Telegram: go run ./cmd/igprobe <instagram url>..., or
IG_LIVE_TEST=1 go test -run TestInstagramLive -v . (downloads into a temp dir).