A Telegram bot for sending random cat images to users.
CatSuperpositionBot is a simple and cute Telegram bot that sends users random cat images on request. The bot uses The Cat API to fetch images.
- 🐱 Sends random cat images
- 📱 Convenient keyboard with buttons
- 🔄 Backup API (The Dog API) if the main one is unavailable
- 📝 Logging of all actions
- ❓ Built-in help
/start- Start interacting with the bot/newcat- Get a new cat image/help- Show help
git clone <repository-url>
cd kittybotpython3 -m venv venv
source venv/bin/activate # On macOS/Linux
# or
venv\Scripts\activate # On Windowspip install -r requirements.txtCreate a .env file in the root directory of the project:
TOKEN=your_bot_token
python kittybot.pySee detailed deployment instructions in DEPLOY.md.
Quick guide:
- Upload the project to GitHub
- Create an account on PythonAnywhere
- Create a Flask web app
- Clone the repository
- Install dependencies
- Set up the webhook
- Restart the app
Deployment files:
app.py- Flask app for webhookrun_bot.py- script for running via cronDEPLOY.md- detailed instructions
kittybot/
├── kittybot.py # Main bot file (local development)
├── app.py # Flask app for PythonAnywhere
├── run_bot.py # Script for running via cron
├── requirements.txt # Python dependencies
├── .env # Environment variables (token)
├── .gitignore # Git ignore file
├── bot.log # Bot logs (created automatically)
├── README.md # This file
└── DEPLOY.md # Deployment instructions
- Python 3.8+
- pyTelegramBotAPI - library for working with Telegram Bot API
- requests - HTTP client for API requests
- python-dotenv - loading environment variables
- logging - logging system
The bot uses the following APIs:
- The Cat API (https://api.thecatapi.com/) - main image source
- The Dog API (https://api.thedogapi.com/) - backup source
The bot logs to the bot.log file and outputs logs to the console. Logs include:
- Bot startup information
- Errors when fetching images
- Warnings about API unavailability
- The bot token is stored in the
.envfile (not committed to Git) - All dependencies are pinned in
requirements.txt - Error handling to prevent bot crashes
For development, it is recommended to:
- Use a virtual environment
- Follow PEP 8 for code style
- Add logging for debugging
- Test the bot in a private chat
MIT License