tg msg | Site ui |
---|---|
Automatically post movies and TV shows to Telegram channels with rich media previews.
- Cloudflare Account: Required for Workers and Pages
- GitHub Account: For repository hosting and CI/CD
- Telegram Account: For bot and channel creation
- TMDB Account: For API access
- Create Cloudflare account at cloudflare.com
- Verify your email address
- Add a payment method (required for Workers beyond free tier)
Create API token with these permissions:
- Go to API Tokens
- Click "Create Token"
- Use "Edit Cloudflare Workers" template
- Add these additional permissions:
- Account: Workers KV Storage: Edit
- Account: Workers Scripts: Edit
- Account: Workers Tail: Read
- Account: Cloudflare Pages: Edit
- Zone: Cache Purge: Purge
- Limit token to specific resources:
- Include: All accounts
- Include: Specific zone (your domain if using custom domain)
- Save token securely (will be used in GitHub Secrets)
git clone https://github.com/your-username/imdb-tg-post.git
cd imdb-tg-post
-
Create new Worker:
- Go to Workers & Pages
- Click "Create application"
- Choose "Create Worker"
- Name:
imdb-tg-post-back
-
Set environment variables:
- Go to Worker → Settings → Variables
- Add these variables under "Environment Variables":
TELEGRAM_BOT_TOKEN
: Your Telegram bot tokenTMDB_API_KEY
: Your TMDB API keyAUTH_TOKEN
: Generated secure token (openssl rand -hex 32
)
- Add under "Secrets":
- Repeat same variables as secrets
Edit public/script.js
:
// ======= REQUIRED CONFIGURATION ======= //
const workerUrl = 'https://your-worker.your-username.workers.dev';
const AUTH_TOKEN = 'same-as-worker-auth-token';
// ===================================== //
-
Create bot with @BotFather:
/newbot Bot name: MyContentBot Username: MyContentBot
-
Save API token
-
Create channel and add bot as admin with:
- "Post messages" permission
- "Edit messages" permission (recommended)
-
Set webhook: use terminal (termux)
curl -X POST \
-H "Content-Type: application/json" \
-d '{"url": "https://your-worker.your-username.workers.dev/bot"}' \
"https://api.telegram.org/botYOUR_BOT_TOKEN/setWebhook"
Set these in repo → Settings → Secrets → Actions:
Secret Name | Value |
---|---|
CF_API_TOKEN |
Cloudflare API token with permissions |
CF_ACCOUNT_ID |
Cloudflare account ID |
TELEGRAM_BOT_TOKEN |
Telegram bot token |
TMDB_API_KEY |
TMDB API key |
AUTH_TOKEN |
Same token as in worker |
- Push to main branch:
git add .
git commit -m "Initial setup"
git push origin main
- Monitor deployment in GitHub → Actions
- Access frontend:
https://your-project.pages.dev
- Open settings (⚙️) and enter:
- Telegram Channel ID
- (Optional) Default custom domain
- Save settings
For the API token, these permissions are required:
Service | Permission | Reason |
---|---|---|
Account Settings | Read | Access account info |
Cloudflare Pages | Edit | Deploy frontend |
Workers Scripts | Edit | Deploy worker |
Workers Secrets | Edit | Set environment variables |
Workers KV Storage | Edit | Future feature support |
Zone Cache Purge | Purge | Clear cache after deploy |
- Search Content: Type movie/TV show title
- Select Result: Choose from TMDB results
- Add Details (optional):
- Season/Episode numbers
- Custom link
- Personal note
- Post to Telegram: Click submit button
Deployment Fails:
- Verify Cloudflare API token permissions
- Check account limits (free tier has daily limits)
- Ensure secrets are correctly set in GitHub
Telegram Issues:
- Check bot is channel admin:
/admin
in channel - Verify webhook:
https://api.telegram.org/botYOUR_TOKEN/getWebhookInfo
- Test bot commands in private chat
TMDB Errors:
- Validate API key at TMDB
- Check worker logs for failed requests
- Ensure worker has internet access
imdb-tg-post/
├── README.md
├── .gitignore
├── worker/ # Cloudflare Worker
│ ├── src
│ │ └── worker.js # Backend logic
│ ├── package.json
│ └── wrangler.toml # Deployment config
├── public/ # Frontend
│ ├── index.html # Main UI
│ ├── script.js # Client logic (configure here)
│ └── style.css # Styles
└── .github/workflows # CI/CD
└── deploy.yml # Deployment workflow
MIT License - Free for personal and commercial use