How armen-devops/telegram_bot works
Telegram Rate Bot serves current AMD exchange rates and guided currency conversions. A user interacts with Telegram commands or inline buttons; tbot.py formats responses and, when rates are needed, reads the scraper’s in-memory cache. scraper.py refreshes that cache from rate.am in a background thread, retrying after failures. The converter tracks a short-lived chat state and converts through AMD using buy and sell rates. The graph reflects documented capabilities and relationships visible in the excerpts; README-documented details are included where implementation is not separated into its own source file.
Main entry points: tbot.py Bot runtime · scraper.py Refresh lifecycle
Components 17
Telegram Bot
- Bot runtime
tbot.py - Welcome and help
tbot.py - Rates replies
tbot.py - Currency buttons
tbot.py - Chat clearing
tbot.py - Rate and time formatting
tbot.py
Conversion
- Converter prompts
tbot.py - Chat flow state
tbot.py - Amount parsing
tbot.py - AMD conversion
tbot.py
Rate Collection
- Refresh lifecycle
scraper.py - Browser scrape
scraper.py - In-memory rates
scraper.py
Other components
- Telegram user
- Telegram API
- rate.am
- Headless Chrome
Connections 26
- Telegram user → Telegram API: sends commands
README.md - Telegram API → Bot runtime: delivers updates
README.md - Bot runtime → Telegram API: polls and replies
tbot.py - Bot runtime → Welcome and help: dispatches commands
tbot.py - Bot runtime → Rates replies: dispatches commands
tbot.py - Bot runtime → Converter prompts: dispatches commands
tbot.py - Bot runtime → Chat clearing: dispatches commands
tbot.py - Welcome and help → Telegram API: sends welcome and help
tbot.py - Welcome and help → Currency buttons: includes buttons
tbot.py - Currency buttons → Rates replies: requests currency rate
tbot.py - Rates replies → In-memory rates: reads rows and timestamp
tbot.py - Rates replies → Rate and time formatting: formats rate response
tbot.py - Rate and time formatting → Telegram API: sends formatted reply
tbot.py - Converter prompts → Chat flow state: updates flow state
tbot.py - Converter prompts → Amount parsing: parses entered amount
tbot.py - Converter prompts → In-memory rates: reads conversion rates
tbot.py - Converter prompts → AMD conversion: converts amount
tbot.py - AMD conversion → Rate and time formatting: provides result
tbot.py - Converter prompts → Telegram API: prompts and sends result
tbot.py - Chat clearing → Chat flow state: resets unfinished flow
tbot.py - Chat clearing → Telegram API: deletes messages
tbot.py - Bot runtime → Refresh lifecycle: starts and closes
tbot.py - Refresh lifecycle → Browser scrape: runs refresh scrape
scraper.py - Browser scrape → Headless Chrome: loads and reads page
scraper.py - Browser scrape → rate.am: fetches rate rows
scraper.py - Refresh lifecycle → In-memory rates: stores refreshed rows
scraper.py