Skip to content

kerivin/media-embedder-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Media Embedder Bot for Telegram

The bot replaces regular links with ones that display embed media, so you can watch it directly in Telegram.

Deploy to Cloudflare Workers

Supported embeds

I'm not the author of the embed services themselves, the bot just creates a link to them. If you run into a problem with embeds, you can report it to the original author.

Usage

@bot_username <post link>

Write this in any chat, you don't need to add the bot to any chat or start chat with it

Installation

You don't need to install anything on your PC, and you can run this bot entirely for free.

Fast way if you have a Github account

Deploy to Cloudflare Workers

  1. Configure secrets in Github project settings:
    • CLOUDFLARE_ACCOUNT_ID - secret, found on Cloudflare -> Workers & Pages -> Overview
    • CLOUDFLARE_API_TOKEN - secret, create Edit Workers here
    • ENV_BOT_SECRET - secret for setWebhook, allowed symbols: A-Z, a-z, 0-9, _ and -
    • ENV_BOT_TOKEN - secret, you've got this after creating a bot with BotFather
  2. Adjust wrangler.toml according to your needs (for example, link to your own JSON replacement map in ENV_LIST_URL). See here
  3. Paste the Worker address into a browser address bar, add /registerWebhook at the end and press Enter
    • You can find the Worker address if you go to Cloudflare -> Workers & Pages -> media-embedder-bot -> Right click on "Visit" button -> Copy link
    • By default, it should look something like https://media-embedder-bot.<USERNAME>.workers.dev/registerWebhook
  4. If it says Ok, your bot is ready!
Fast way if you don't want to bother
  1. Register a new bot with BotFather, set inline mode by /setinline
  2. Create Cloudflare Worker "media-embedder-bot" (free plan doesn't require a card)
  3. Set secrets and variables in worker settings:
    • ENV_BOT_SECRET - secret for setWebhook, allowed symbols: A-Z, a-z, 0-9, _ and -
    • ENV_BOT_TOKEN - secret, you've got this after creating a bot with BotFather
    • ENV_LIST_URL - text, use this value: https://raw.githubusercontent.com/kerivin/media-embedder-bot/refs/heads/main/list.json
  4. Press Edit Code on your worker page, copy the content of worker.js, paste it into the editor and press Deploy
  5. Paste the Worker address into a browser address bar, add /registerWebhook at the end and press Enter
    • You can find the Worker address if you go to Cloudflare -> Workers & Pages -> media-embedder-bot -> Right click on "Visit" button -> Copy link
    • By default, it should look something like https://media-embedder-bot.<USERNAME>.workers.dev/registerWebhook
  6. If it says Ok, your bot is ready!
Manual Github way
  1. Register a new bot with BotFather, set inline mode by /setinline
  2. Create Cloudflare Worker "media-embedder-bot" (free plan doesn't require a card)
  3. Fork this repo and add secrets in Github project settings:
    • CLOUDFLARE_ACCOUNT_ID - secret, found on Cloudflare -> Workers & Pages -> Overview
    • CLOUDFLARE_API_TOKEN - secret, create Edit Workers here
    • ENV_BOT_SECRET - secret for setWebhook, allowed symbols: A-Z, a-z, 0-9, _ and -
    • ENV_BOT_TOKEN - secret, you've got this after creating a bot with BotFather
  4. Adjust wrangler.toml according to your needs (for example, link to your own JSON replacement map in ENV_LIST_URL). See here
  5. Deploy (trigger Github Actions, for example by push in main branch)
  6. Paste the Worker address into a browser address bar, add /registerWebhook at the end and press Enter
    • You can find the Worker address if you go to Cloudflare -> Workers & Pages -> media-embedder-bot -> Right click on "Visit" button -> Copy link
    • By default, it should look something like https://media-embedder-bot.<USERNAME>.workers.dev/registerWebhook
  7. If it says Ok, your bot is ready!

Credits

Telegram Bot on Cloudflare Workers