A Telegram command bot for searching and displaying Finnish student songs from the Fiisut-V repository.
- Command Search: Use
/fiisu <search_query>to search for songs - Song Display: Returns formatted song lyrics with HTML formatting
- Fast Search: Simple but effective text-based search through song names and lyrics
- Smart Results: Shows single song directly or list of matches for broader searches
The easiest way to run the bot is using Docker Compose:
-
Clone and setup:
git clone <your-repo-url> cd fiisubot git submodule init && git submodule update
-
Configure environment:
cp .env.example .env # Edit .env and add your TELEGRAM_BOT_TOKEN -
Run the bot:
docker-compose up -d
-
View logs:
docker-compose logs -f bot
-
Clone the repository:
git clone <your-repo-url> cd fiisubot
-
Initialize the Fiisut-V submodule:
git submodule init git submodule update
-
Install dependencies:
pip install python-telegram-bot
Or using Poetry:
poetry install
-
Extract songs:
python extract_songs.py
-
Create bot and get token:
- Message @BotFather on Telegram
- Create a new bot with
/newbot - Copy the bot token
-
Set environment variable:
export TELEGRAM_BOT_TOKEN="your_bot_token_here"
-
Run the bot:
python fiisubot.py
For development with live code reloading:
# Copy environment file
cp .env.example .env
# Add your bot token to .env
# Run in development mode
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up# Production deployment
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
# Check status
docker-compose ps
# View logs
docker-compose logs -f
# Update deployment
docker-compose pull
docker-compose up -d# Build the image
docker build -t fiisubot .
# Run the container
docker run -d \
--name fiisubot \
--restart unless-stopped \
-e TELEGRAM_BOT_TOKEN="your_bot_token_here" \
fiisubotThe project uses GitHub Actions for continuous integration and deployment:
-
CI/CD Pipeline (
.github/workflows/ci.yml):- Linting: Code formatting with Black and linting with Pylint
- Testing: Unit tests and bot functionality validation
- Build: Multi-platform Docker image build and push to GHCR
Production images are automatically built and pushed to GitHub Container Registry:
# Latest (main branch)
docker pull ghcr.io/fyysikkokilta/fiisubot:latest
# Specific version
docker pull ghcr.io/fyysikkokilta/fiisubot:v1.0.0# Run tests
poetry run test
# Format code
poetry run format
# Check formatting
poetry run format-check
# Lint code
poetry run lint
# Extract songs
poetry run extract-fiisut- Update version in
pyproject.toml - Update
CHANGELOG.md(if exists) - Create and push a version tag:
git tag v1.0.0 git push origin v1.0.0
- GitHub Actions will automatically create a release and build images
| Variable | Description | Default |
|---|---|---|
TELEGRAM_BOT_TOKEN |
Bot token from @BotFather | Required |
LOG_LEVEL |
Logging level (DEBUG, INFO, WARNING, ERROR) | INFO |
PYTHONUNBUFFERED |
Python output buffering | 1 |
docker-compose.yml- Base configurationdocker-compose.prod.yml- Production overrides (uses GHCR images)
Once the bot is running:
- Start a chat with your bot
- Use
/startto see the welcome message and instructions - Use
/fiisu <search_term>to search for songs - The bot will send the formatted song lyrics
Examples:
/fiisu teemu- Search for songs containing "teemu"/fiisu juomalaulu- Search for drinking songs/fiisu polyteknikko- Search for polytechnic songs
# Start services
docker-compose up -d
# Stop services
docker-compose down
# Restart service
docker-compose restart bot
# View logs
docker-compose logs -f bot
# Update and restart
docker-compose pull && docker-compose up -d
# Check resource usage
docker stats fiisubot# Extract songs
poetry run extract-fiisut
# Run bot
poetry run bot
# Run tests
poetry run test
# Format code
poetry run format
# Lint code
poetry run lintfiisubot/
├── fiisubot.py # 🤖 Main bot file
├── extract_songs.py # 🎵 Song extraction script
├── songs.json # 📄 Song database (generated)
├── Fiisut-V/ # 📁 Song repository (submodule)
├── .github/ # 🔄 CI/CD workflows
│ ├── workflows/
│ └── ci-cd.yml # Main CI/CD pipeline
├── docker-compose.yml # 🐳 Base Docker Compose config
├── docker-compose.prod.yml # 🚀 Production overrides
├── Dockerfile # 📦 Container definition
├── .env.example # ⚙️ Environment template
├── pyproject.toml # 📋 Python dependencies
└── README.md # 📖 This file
The bot includes health checks that verify connectivity to Telegram's API:
# Check health status
docker-compose exec bot python -c "import requests; print('✓ Healthy' if requests.get('https://api.telegram.org').status_code == 200 else '✗ Unhealthy')"View real-time logs:
# All logs
docker-compose logs -f
# Last 100 lines
docker-compose logs --tail=100 bot
# Error logs only
docker-compose logs -f bot | grep ERROR- Bot not responding: Check if the token is correct and the bot is started
- No songs found: Ensure
songs.jsonexists and contains data - Permission denied: Check if inline mode is enabled for your bot
Run with debug logging:
# Local
LOG_LEVEL=DEBUG python fiisubot.py
# Docker Compose
echo "LOG_LEVEL=DEBUG" >> .env
docker-compose restart bot- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
poetry run test - Format code:
poetry run format - Create a pull request
The CI pipeline will automatically run tests and linting on your PR.
python-telegram-bot- Telegram Bot API wrappertqdm- Progress bars for extractionTexSoup- LaTeX parsing (for extraction)
MIT for code, all copyrights held for songs from Fiisut-V.