- Python 3.x
- Required packages:
python-telegram-bot,python-dotenv
- Install the required packages:
pip install python-telebot python-dotenv- Create a
.envfile in the root directory with your bot token:
INDICARE_BOT_TOKEN=your_bot_token_here
- Configure allowed users by updating the
allowed_user_idslist insrc/indicare.pywith the appropriate Telegram usernames or phone numbers.
- Navigate to the project directory
- Run the bot:
python src/indicare.pyThe bot will start and respond to messages from authorized users. It will:
- Respond to
/startor/hellocommands with a welcome message - Format any text messages with Indicare's contact information
- Only respond to authorized users listed in the
allowed_user_ids
Deploy using Cloudflare webhook/worker:
-
Deploy to Cloudflare:
- Go to dash.cloudflare.com and log in/sign up
- Navigate to Workers & Pages in the left menu
- For first-time deployment:
- Click "Create application" -> "Create Worker"
- Give it a name and click "Deploy"
- For existing deployment:
- Click the worker name
- Press "Edit code" to update it
-
Set Environment Variables:
- Click "Settings" -> "Environment Variables"
- Add variable named
API_KEYwith your Telegram bot token as the value - Save and deploy
-
Check Current Webhook Status:
curl "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getWebhookInfo"Response will look like:
{"ok":true,"result":{"url":"","has_custom_certificate":false,"pending_update_count":1}}If the
"url":""is empty, it means no webhook is set up. -
Set Up Webhook:
curl "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook?url=<YOUR_WORKER_URL>"Replace:
<YOUR_BOT_TOKEN>with your Telegram bot token<YOUR_WORKER_URL>with your Cloudflare Worker URL (e.g.,https://your-worker.your-subdomain.workers.dev)
-
Verify Webhook Setup:
- Run the getWebhookInfo command again
- The response should now show your Worker URL:
{"ok":true,"result":{"url":"https://your-worker.your-subdomain.workers.dev","has_custom_certificate":false}}
Note: When the webhook is properly set up, you don't need to run the Python bot (src/indicare.py). The bot will work through the Cloudflare Worker instead.
- Message formatting for Indicare's promotional content
- User authorization system
- Logging system for tracking bot usage
- Markdown support for formatted messages