Complete step-by-step guide for setting up and running the bot.
Before you begin, ensure you have:
- Python 3.9+ - Download Python
- Telegram Account - For creating and using the bot
- Internet Connection - For installing dependencies and running scans
- Git - For cloning the repository
- Code Editor - VSCode, PyCharm, or any preferred editor
- Open Telegram and search for @BotFather
- Start a chat and send
/newbot - Follow the instructions:
- Choose a name for your bot (e.g., "API Checker Bot")
- Choose a username (must end in 'bot', e.g., "api_checker_bot")
- BotFather will provide you with a token like:
123456789:ABCdefGHIjklMNOpqrsTUVwxyz - Keep this token secure! Don't share it publicly.
- Navigate to project directory
cd d:\API_Bot- Create virtual environment
# Create venv
python -m venv venv
# Activate (Windows)
venv\Scripts\activate
# Activate (Linux/Mac)
source venv/bin/activateYou should see (venv) in your terminal prompt.
If you already have the files, just activate the virtual environment:
cd d:\API_Bot
venv\Scripts\activateWith virtual environment activated:
# Upgrade pip
python -m pip install --upgrade pip
# Install all requirements
pip install -r requirements.txt
# Install Playwright browsers (required for advanced features)
playwright install chromiumNote: This may take a few minutes depending on your internet speed.
python -c "import telegram; print('β
python-telegram-bot installed')"
python -c "import httpx; print('β
httpx installed')"
python -c "import dns.resolver; print('β
dnspython installed')"- Create environment file
copy .env.example .env- Edit .env file
Open .env in your text editor and add your bot token:
# Telegram Bot Configuration
TELEGRAM_BOT_TOKEN=123456789:ABCdefGHIjklMNOpqrsTUVwxyz
# Database (default is fine)
DATABASE_PATH=bot_data.db
# Scanning Configuration
MAX_PARALLEL_SCANS=5
REQUEST_TIMEOUT=30
MAX_RETRIES=3
# Optional: API Keys
HAVEIBEENPWNED_API_KEY=optional_api_key
# Logging
LOG_LEVEL=INFO
LOG_FILE=bot.logImportant: Replace the bot token with your actual token from BotFather!
- Save the file
python bot.pyYou should see:
2026-01-24 12:00:00 | INFO | database:initialize - Database initialized successfully
2026-01-24 12:00:00 | INFO | bot:post_init - Bot initialized successfully
2026-01-24 12:00:00 | INFO | bot:run - Starting bot...
- Open Telegram
- Search for your bot by username
- Start a chat and send
/start - You should receive the welcome message!
- Try sending a URL:
https://google.com
Send these commands to your bot:
/start - Should show welcome message
/help - Should show help text
/stats - Should show statistics (0 initially)
/settings - Should show settings options
Send a URL to test scanning:
https://github.com
example.com
api.telegram.org
The bot should:
- Show "π Scanning..." message
- Run all checks in parallel
- Display formatted results
- Show action buttons
- Scan a URL
- Click "π Bookmark" button
- Send
/bookmarkscommand - You should see your saved bookmark with status indicator
Solution:
- Double-check your token in
.envfile - Ensure no extra spaces or quotes
- Get a fresh token from BotFather
Solution:
# Ensure venv is activated
venv\Scripts\activate
# Reinstall requirements
pip install -r requirements.txtSolution:
- Close any other instances of the bot
- Check Task Manager for Python processes
- Restart your terminal
Solution:
Edit config.py:
REQUEST_TIMEOUT = 60 # Increase timeout
MAX_PARALLEL_SCANS = 3 # Reduce concurrent scansSolution:
playwright install chromiumSolution:
Check config.py and update DNS servers:
DNS_SERVERS = ['8.8.8.8', '1.1.1.1'] # Use Google/Cloudflare DNSTo update dependencies:
pip install --upgrade -r requirements.txtTo restart the bot:
- Press
Ctrl+Cto stop - Run
python bot.pyagain
Edit config.py:
DNS_SERVERS = [
'8.8.8.8', # Google
'1.1.1.1', # Cloudflare
'208.67.222.222' # OpenDNS
]DNS_TIMEOUT = 5
HTTP_TIMEOUT = 30
SSL_TIMEOUT = 10RATE_LIMIT_REQUESTS = 10 # Requests
RATE_LIMIT_PERIOD = 60 # Per 60 secondsIn .env:
LOG_LEVEL=DEBUGThe bot uses SQLite. You can view it with:
# Install SQLite browser
pip install sqlitebrowser
# Or use command line
sqlite3 bot_data.dbSQL queries:
-- View bookmarks
SELECT * FROM bookmarks;
-- View scan history
SELECT * FROM scan_history LIMIT 10;
-- View user preferences
SELECT * FROM user_preferences;copy bot_data.db bot_data_backup.dbdel bot_data.db
python bot.py # Will recreate with fresh tablesscreen -S apibot
python bot.py
# Press Ctrl+A, then D to detachTo reattach:
screen -r apibotnohup python bot.py > bot.log 2>&1 &Create /etc/systemd/system/apibot.service:
[Unit]
Description=API Resource Availability Bot
After=network.target
[Service]
Type=simple
User=your_user
WorkingDirectory=/path/to/API_Bot
Environment="PATH=/path/to/API_Bot/venv/bin"
ExecStart=/path/to/API_Bot/venv/bin/python bot.py
Restart=always
[Install]
WantedBy=multi-user.targetEnable and start:
sudo systemctl enable apibot
sudo systemctl start apibotnpm install -g pm2
pm2 start bot.py --name apibot --interpreter python
pm2 save
pm2 startup- Never commit
.envfile - It's in.gitignore - Use environment variables for sensitive data
- Restrict database file permissions
chmod 600 bot_data.db # Linux- Keep dependencies updated
pip list --outdated
pip install --upgrade package_name- Monitor logs regularly
tail -f bot.log# Windows
tasklist | findstr python
# Linux
ps aux | grep bot.py# Windows (PowerShell)
Get-Content bot.log -Wait -Tail 50
# Linux
tail -f bot.log# Windows
dir bot_data.db
# Linux
ls -lh bot_data.dbIf you encounter issues:
- Check logs:
bot.logcontains detailed error information - Enable debug mode: Set
LOG_LEVEL=DEBUGin.env - Test components individually: Run scanner modules separately
- Check dependencies: Ensure all packages are installed
- Verify credentials: Double-check bot token
# Test availability checker
from scanners.availability_checker import AvailabilityChecker
import asyncio
async def test():
checker = AvailabilityChecker()
result = await checker.check('https://google.com')
print(result)
asyncio.run(test())Once your bot is running:
- β Test all features thoroughly
- β
Customize messages in
config.py - β Adjust timeouts and limits for your needs
- β Set up automated backups
- β Monitor performance and logs
- β Share your bot with users!
Your bot should now be fully operational! π
Send a URL to your bot and watch it analyze! If you have any issues, refer to the troubleshooting section above.