This project is a Telegram bot that sends random cat and dog images to users. The bot uses the Telegram Bot API, thecatapi.com, and thedogapi.com to fetch images.
- Sends a random cat image when the
/newcat
command is used. - Sends a random dog image when the
/newdog
command is used. - Greets users with a welcome message and options to request cat or dog images.
- Python 3.7+
- Docker
- Docker Compose
- Telegram Bot API token
- API keys for The Cat API and The Dog API (if required)
- Clone the repository:
git clone git@github.com:vhg860/kittybot.git cd kittybot
- Create and activate a virtual environment (optional but recommended):
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
- Install the dependencies:
pip install -r requirements.txt
- Create a .env file in the root of the project and add your Telegram Bot token:
TOKEN=your_telegram_bot_token
- Run the bot locally:
python kittybot.py
- Build the Docker image:
docker-compose build
- Run the Docker container:
docker-compose up
This project uses GitHub Actions for CI/CD. The workflow is configured to:
- Build and push the Docker image to Docker Hub.
- Deploy the new image to a remote server.
- Ensure that the .env file is present in the project directory on the server and contains the TOKEN variable.
- Deploy using Docker Compose:
docker-compose -f docker-compose.production.yml pull docker-compose -f docker-compose.production.yml up -d
-
Fork or clone this repository.
-
Go to the repository settings on GitHub.
-
Add the following secrets in the Settings > Secrets and variables > Actions > New repository secret:
- DOCKER_USERNAME: Your Docker Hub username.
- DOCKER_PASSWORD: Your Docker Hub password.
- SSH_KEY: Private SSH key for accessing your server.
- SSH_PASSPHRASE: Private SSH passphrase.
- HOST: IP address or domain of your server.
- USERNAME: SSH username for your server.
- TELEGRAM_TO: ID chat or chanel in Telegram for notifications.
- TELEGRAM_TOKEN: the token of your Telegram bot for sending notifications.
- Start a chat with your Telegram bot.
- Use the /start command to initialize the bot.
- Use the /newcat command to get a random cat image.
- Use the /newdog command to get a random dog image.
.
├── .github
│ └── workflows
│ └── main.yml # GitHub Actions workflow
├── .env # Environment variables
├── Dockerfile # Dockerfile for building the image
├── docker-compose.yml # Docker Compose configuration (development)
├── docker-compose.production.yml # Docker Compose configuration (production)
├── requirements.txt # Python dependencies
└── kittybot.py # Main bot script