Skip to content

Bitcoin-Calendar/telegram-bot

Repository files navigation

Bitcoin Historical Events Telegram Bot

A modular Python Telegram bot that automatically posts Bitcoin historical events to Telegram channels. Features clean architecture, multi-language support, and comprehensive testing.

🚀 Quick Start

1. Setup Environment

cp env.example .env
# Edit .env with your configuration

2. Test the Bot

# Test English bot (posts to test channel)
./scripts/test-bot-en.sh

# Test Russian bot (posts to test channel)  
./scripts/test-bot-ru.sh

3. Run in Production

# Production English bot
docker-compose up --build --abort-on-container-exit bitcoin-events-bot-en

# Production Russian bot
docker-compose up --build --abort-on-container-exit bitcoin-events-bot-ru

📁 Project Structure

telegram-bot/
├── bot.py                 # Main entry point
├── config.py             # Configuration management
├── api_client.py         # API communication
├── message_formatter.py  # Message formatting & URLs
├── telegram_client.py    # Telegram posting
├── docker-compose.yml    # Docker services
├── scripts/              # Test scripts
│   ├── test-bot-en.sh   # English test script
│   └── test-bot-ru.sh   # Russian test script
└── docs/                # Detailed documentation

⚙️ Configuration

Required environment variables in .env:

TELEGRAM_BOT_TOKEN=your_bot_token
RUSSIAN_CHAT_ID=@your_russian_channel
ENGLISH_CHAT_ID=@your_english_channel
TELEGRAM_TEST_CHAT_ID=@your_test_channel
API_BASE_URL=http://your-api-url/api
API_KEY=your_api_key
TIMEZONE=UTC

Note: The bot checks for a valid API response containing event data. If using the test mode, ensure your test channel is correctly set in TELEGRAM_TEST_CHAT_ID and the bot is an administrator.

🧪 Testing

  • Test Mode: Posts to TELEGRAM_TEST_CHAT_ID instead of production channels
  • Safe Testing: No risk to production channels
  • Both Languages: Test English and Russian bots separately

📅 Automation

Add to crontab for daily posting. Note the use of --build is optional but recommended if you frequently update the code.

# Russian bot at 12 PM UTC
0 12 * * * cd /path/to/telegram-bot && docker-compose up --abort-on-container-exit bitcoin-events-bot-ru

# English bot at 3 PM UTC  
0 15 * * * cd /path/to/telegram-bot && docker-compose up --abort-on-container-exit bitcoin-events-bot-en

📚 Documentation

🌟 Features

  • Modular Architecture - Clean, maintainable code structure
  • Multi-Language Support - Russian and English bots
  • Smart URL Generation - Constructs proper event URLs from url_path
  • Media Support - Photos, videos, and text messages
  • Test Environment - Safe testing with separate test channel
  • Docker Ready - Complete containerization
  • Automated Posting - Cron job support

📄 License

MIT


⚡️zapmeacoffee

About

A bot publishing historical Bitcoin and FOSS events to Telegram

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published