This repository contains a general-purpose Telegram Referral Bot designed to help organizations or communities grow their audience through a referral system. Users can generate unique referral links, track their referrals, and view referral statistics. This bot ensures users are subscribed to a specific Telegram channel before they can use the bot’s features.
- Referral Generation: Users can generate and share unique referral links.
- Subscription Check: Ensures users are subscribed to a specific Telegram channel before proceeding with the referral system.
- Referral Tracking: Tracks successful referrals and updates invite counts for the referrers.
- Leaderboard: Displays a leaderboard of top referrers with invites.
- Hosted on AWS: The bot is designed to run continuously using AWS services like EC2 and RDS.
- Python 3.x
- MySQL (or another compatible database for referral tracking)
- A Telegram Bot API Token (obtained from BotFather)
- A Telegram channel where users need to subscribe
-
Clone the repository:
git clone https://github.com/samuelbrhane/Python-telegram-referral-bot.git cd Python-telegram-referral-bot -
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables: You need to set environment variables for the bot to access sensitive data like the API token and database credentials. You can add these in your shell, or configure them in AWS if you're using EC2.
Example:
export BOT_TOKEN='your-telegram-bot-token' export DB_HOST='your-database-host' export DB_USER='your-database-user' export DB_PASSWORD='your-database-password' export DB_NAME='your-database-name' export bot_username='your-bot-user' export CHANNEL_USERNAME='your-telegram-channel-name' export CHANNEL_URL='your-telegram-channel-url'
-
Start the bot:
python bot.py
The bot is designed to run continuously, so you may want to host it on AWS EC2 with an RDS MySQL instance for database operations.
- Set up an EC2 instance for running the bot.
- Set up an RDS MySQL instance for storing referral data.
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.