A Telegram bot that manages paid access to your premium Telegram group. Users must complete a $10 USD PayPal payment before receiving the group invite link.
- π€ Telegram Bot Integration - Seamless user interaction via Telegram
- π³ PayPal Payment Processing - Secure payment handling via PayPal API
- ποΈ SQLite Database - User and payment tracking
- π₯ User Management - Track payments and invite status
- π Admin Dashboard - Statistics and user management
- π Secure - Payment verification and user authentication
- π Easy Deployment - Simple setup and configuration
- Python 3.8 or higher
- PayPal Developer Account
- Telegram Bot Token
- Telegram Group Admin Access
# Clone the repository
git clone <your-repo-url>
cd telegram-invite-bot
# Install dependencies
pip install -r requirements.txt-
Copy and edit the environment file:
cp .env.example .env
-
Update
.envwith your credentials:# Telegram Bot Configuration TELEGRAM_BOT_TOKEN=your_bot_token_here TELEGRAM_GROUP_INVITE_LINK=your_group_invite_link # PayPal Configuration PAYPAL_CLIENT_ID=your_paypal_client_id PAYPAL_CLIENT_SECRET=your_paypal_client_secret PAYPAL_MODE=sandbox # Change to 'live' for production # Bot Configuration PAYMENT_AMOUNT=10.00 PAYMENT_CURRENCY=USD ADMIN_USER_ID=your_telegram_user_id
-
Get your Telegram User ID:
- Message @userinfobot on Telegram to get your user ID
- Add this ID to
ADMIN_USER_IDin.env
-
Create PayPal App:
- Go to PayPal Developer
- Create a new app
- Get your Client ID and Client Secret
- Add them to your
.envfile
-
Set PayPal Mode:
- Use
sandboxfor testing - Use
livefor production
- Use
-
Create Bot:
- Message @BotFather on Telegram
- Create a new bot with
/newbot - Get your bot token
- Add it to your
.envfile
-
Get Group Invite Link:
- Create a Telegram group
- Make your bot an admin (optional)
- Generate an invite link
- Add it to your
.envfile
python bot.py-
Set up your webhook URL in
bot.py:self.webhook_base_url = "https://your-domain.com"
-
Run the webhook server:
python webhook_server.py
-
Set up reverse proxy (nginx example):
server { listen 443 ssl; server_name your-domain.com; location /webhook/ { proxy_pass http://127.0.0.1:5000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } }
/start- Start the bot and see payment options/help- Show help information/status- Check payment status/pay- Initiate payment process
/admin- Show admin panel/stats- View bot statistics
telegram-invite-bot/
βββ bot.py # Main bot application
βββ config.py # Configuration management
βββ database.py # Database operations
βββ paypal_handler.py # PayPal integration
βββ webhook_server.py # Webhook server (optional)
βββ requirements.txt # Python dependencies
βββ .env # Environment variables
βββ README.md # This file
The bot uses SQLite with the following tables:
- users - User information and payment status
- payments - Payment records
- payment_sessions - Temporary payment sessions
- Environment Variables - Keep your
.envfile secure - PayPal Verification - All payments are verified with PayPal
- User Authentication - Admin commands require user ID verification
- HTTPS - Use HTTPS for webhook endpoints in production
-
Bot not responding:
- Check your bot token
- Ensure the bot is not blocked
- Check internet connection
-
PayPal errors:
- Verify client ID and secret
- Check PayPal mode (sandbox/live)
- Ensure PayPal app permissions
-
Database errors:
- Check file permissions
- Ensure SQLite is installed
- Check disk space
The bot logs important events. Check the console output for error messages.
-
Create Dockerfile:
FROM python:3.9-slim WORKDIR /app COPY requirements.txt . RUN pip install -r requirements.txt COPY . . CMD ["python", "bot.py"]
-
Build and run:
docker build -t invite-bot . docker run -d --env-file .env invite-bot
-
Create service file:
[Unit] Description=Telegram Invite Bot After=network.target [Service] Type=simple User=botuser WorkingDirectory=/path/to/bot ExecStart=/usr/bin/python3 bot.py Restart=always [Install] WantedBy=multi-user.target
-
Enable and start:
sudo systemctl enable invite-bot.service sudo systemctl start invite-bot.service
If you encounter any issues:
- Check the troubleshooting section
- Review the logs for error messages
- Ensure all configuration is correct
- Test with PayPal sandbox first
This project is licensed under the MIT License.
This bot is for educational purposes. Ensure compliance with:
- Telegram Terms of Service
- PayPal Acceptable Use Policy
- Local laws and regulations
- Data protection requirements
Note: Always test thoroughly with PayPal sandbox before going live with real payments.