https://github.com/itz-ashlynn/tg-botcodes
https://github.com/itz-ashlynn/tg-botcodes
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/itz-ashlynn/tg-botcodes
- Owner: Itz-Ashlynn
- License: mit
- Created: 2025-08-02T18:06:29.000Z (2 months ago)
- Default Branch: TG-Media-Bot
- Last Pushed: 2025-08-02T19:41:36.000Z (2 months ago)
- Last Synced: 2025-08-11T23:52:03.501Z (2 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 3
- Watchers: 0
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Telegram File Link Generator Bot

A Cloudflare Worker that acts as a Telegram bot to generate direct download links for files shared through Telegram.
## Features
- 🚀 Generates direct download links for Telegram files (up to 20MB)
- 🔒 Secure token-based access system
- 👥 Channel membership requirement
- 📊 User-specific link management
- ⚡ Lightning-fast delivery via Cloudflare's global network
- 🔄 Automatic link expiration after 24 hours## Prerequisites
- Cloudflare account with Workers access
- Telegram bot token from [@BotFather](https://t.me/BotFather)
- Telegram channel (for membership verification)## Configuration
### Environment Variables
Set these in your Cloudflare Worker settings:
| Variable Name | Type | Description | Example Value |
|---------------------|---------|----------------------------------------------|--------------------------------------|
| `BOT_TOKEN` | Secret | Your Telegram bot token | `123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11` |
| `WORKER_DOMAIN` | Variable| Your worker's domain | `https://file.example.workers.dev` |
| `CHANNEL_ID` | Variable| Your Telegram channel ID | `-1001234567890` |
| `CHANNEL_USERNAME` | Variable| Your channel username (with @) | `@MyChannel` |### KV Namespace Binding
Create a KV namespace named `ashlynn` and bind it to your Worker.
## Installation
1. **Create a new Worker** in your Cloudflare dashboard
2. **Paste the code** from `worker.js`
3. **Configure the environment variables** as shown above
4. **Bind the KV namespace** named `ashlynn`
5. **Deploy the Worker**## Setting Up the Webhook
After deployment, set up your Telegram webhook by visiting:
```
https://your-worker.workers.dev/set-webhook
```Or manually using cURL:
```bash
curl -X POST "https://api.telegram.org/bot/setWebhook" \
-H "Content-Type: application/json" \
-d '{"url": "https://your-worker.workers.dev/webhook"}'
```## Usage
1. Send any file (up to 20MB) to the bot
2. The bot will generate a direct download link
3. Use `/links` to view all your active download links## API Endpoints
| Endpoint | Method | Description |
|-------------------|--------|--------------------------------------|
| `/webhook` | POST | Telegram bot webhook endpoint |
| `/file/:id/:token`| GET | Download file endpoint |
| `/set-webhook` | GET | Setup Telegram webhook |## Troubleshooting
### Common Issues
1. **"Method Not Allowed" error**:
- Ensure you're making POST requests to `/webhook`
- Telegram automatically sends POST requests for webhooks2. **Webhook not working**:
- Verify the webhook is set correctly by visiting:
```
https://api.telegram.org/bot/getWebhookInfo
```
- Check your Worker logs for errors3. **File download issues**:
- Links expire after 24 hours of inactivity
- Maximum file size is 20MB## License
This project is licensed under the MIT License.
---
**Made with ❤️ by [Ashlynn's Repository](https://t.me/Ashlynn_Repository)**