How geunsam2/korail_ktx_macro_telegrambot works
This is a Telegram bot that monitors sold-out KTX journeys and attempts reservations when seats become available. Users submit credentials and journey preferences through a multi-step conversation; the reservation service coordinates Korail search/reservation, then webhook callbacks report results and initiate payment reminders. Command, admin, subscription, and multi-seat reminder capabilities are also represented. Evidence is limited to the README and indexed excerpts; background-process and some service internals were not fully sampled, so uncertain links are omitted.
Main entry points: telegram_webhook.py Webhook routes · redis.py Redis state · conversation_handler.py Reservation dialogue · korail_service.py Korail search and booking
Components 22
App and Webhooks
- Flask app
src/app.py - Webhook routes
src/api/telegram_webhook.py - Payment check
src/api/payment_check.py - Configuration
src/config/settings.py - Logging
src/utils/logger.py
User Interaction
- Bot commands
src/handlers/command_handler.py - Reservation dialogue
src/handlers/conversation_handler.py - Message templates
src/telegramBot/messages.py - Input validation
src/utils/validators.py
Reservation Domain
- Reservation orchestration
src/services/reservation_service.py - Korail search and booking
src/services/korail_service.py - Reservation worker
src/telegramBot/telebotBackProcess.py - Station codes
src/utils/station_codes.py - Reservation models
src/models/reservation.py
State and Reminders
- Storage interface
src/storage/base.py - Redis state
src/storage/redis.py - Telegram messaging
src/services/telegram_service.py - Payment reminders
src/services/payment_reminder_service.py - Multi-seat reminders
src/services/multi_reservation_reminder_service.py
Other components
- Telegram user
- Telegram Bot API
- Korail service
Connections 30
- Telegram user → Telegram Bot API: sends updates
README.md - Telegram Bot API → Webhook routes: posts updates
README.md - Flask app → Webhook routes: registers routes
src/app.py - Webhook routes → Bot commands: dispatches commands
src/api/telegram_webhook.py - Webhook routes → Reservation dialogue: dispatches messages
src/api/telegram_webhook.py - Reservation dialogue → Input validation: validates input
src/handlers/conversation_handler.py - Reservation dialogue → Reservation orchestration: starts booking
src/handlers/conversation_handler.py - Bot commands → Redis state: reads/writes state
src/handlers/command_handler.py - Reservation dialogue → Redis state: reads/writes sessions
src/handlers/conversation_handler.py - Reservation dialogue → Message templates: uses templates
src/handlers/conversation_handler.py - Bot commands → Message templates: uses templates
src/handlers/command_handler.py - Reservation orchestration → Korail search and booking: searches and reserves
src/services/reservation_service.py - Korail search and booking → Korail service: calls Korail API
README.md - Reservation orchestration → Reservation worker: starts worker
- Reservation worker → Webhook routes: reports results
- Webhook routes → Payment reminders: starts reminders
src/api/telegram_webhook.py - Webhook routes → Multi-seat reminders: tracks multi-seat payment
src/api/telegram_webhook.py - Payment reminders → Redis state: stores payment state
src/services/payment_reminder_service.py - Multi-seat reminders → Redis state: stores reminder state
src/services/multi_reservation_reminder_service.py - Payment reminders → Telegram messaging: sends reminders
src/services/payment_reminder_service.py - Multi-seat reminders → Telegram messaging: sends reminders
src/services/multi_reservation_reminder_service.py - Webhook routes → Telegram messaging: sends responses
src/api/telegram_webhook.py - Flask app → Redis state: configures storage
src/app.py - Flask app → Configuration: loads configuration
src/app.py - Payment check → Redis state: checks payment state
src/api/payment_check.py - Storage interface → Reservation models: defines stored types
src/storage/base.py - Redis state → Storage interface: implements interface
src/storage/redis.py - Korail search and booking → Configuration: reads settings
src/services/korail_service.py - Webhook routes → Logging: logs events
src/api/telegram_webhook.py - Korail search and booking → Logging: logs activity
src/services/korail_service.py