How abdkrn/pp_statistics works
PP Statistics Bot tracks manager assignments made explicitly by administrators in one Telegram work chat. Its main workflow filters incoming messages by chat and administrator, parses an assignment, resolves the manager, and saves a deduplicated record; commands then calculate and present monthly, all-time, and per-month statistics. Separate branches handle manager administration, manual statistical corrections, and idempotent historical-chat import. The README documents backups and JSON storage; excerpts show storage and backup setup, but do not expose all backup internals or every command implementation detail.
Main entry points: storage.py JSON storage and backups · bot.py Bot startup and routing · messages.py Assignment message handler · commands.py Commands and statistics views
Components 16
Bot runtime
- Bot startup and routing
bot.py - Configuration
config.py
Assignment tracking
- Assignment message handler
handlers/messages.py - Assignment parser
services/assignment_parser.py - History importer
import_history.py
Manager administration
- Admin commands
handlers/admin.py - Manager operations
services/managers.py
Statistics and history
- Commands and statistics views
handlers/commands.py - Statistics calculations
services/statistics.py - Statistics navigation
keyboards/statistics.py
Persistence
- JSON storage and backups
services/storage.py - Managers, assignments, corrections, settings
Other components
- Administrator
- Manager
- Telegram
- Telegram history export
Connections 25
- Administrator → Telegram: sends commands
README.md - Manager → Telegram: sends messages
README.md - Telegram → Bot startup and routing: delivers updates
bot.py - Bot startup and routing → Configuration: loads settings
bot.py - Bot startup and routing → Assignment message handler: routes updates
bot.py - Bot startup and routing → Admin commands: registers router
bot.py - Bot startup and routing → Commands and statistics views: registers router
bot.py - Bot startup and routing → JSON storage and backups: initializes and backs up
bot.py - Assignment message handler → Configuration: checks chat and admin
handlers/messages.py - Assignment message handler → Assignment parser: parses assignment text
handlers/messages.py - Assignment message handler → Manager operations: resolves manager
handlers/messages.py - Assignment message handler → JSON storage and backups: saves assignment
handlers/messages.py - Admin commands → Manager operations: manages managers
handlers/admin.py - Admin commands → JSON storage and backups: saves corrections
handlers/admin.py - Manager operations → JSON storage and backups: reads and updates
services/managers.py - Commands and statistics views → JSON storage and backups: loads records
handlers/commands.py - Commands and statistics views → Statistics calculations: calculates views
handlers/commands.py - Commands and statistics views → Statistics navigation: builds navigation
handlers/commands.py - JSON storage and backups → Managers, assignments, corrections, settings: reads and writes
services/storage.py - History importer → Telegram history export: reads export
README.md - History importer → Assignment parser: parses exported messages
import_history.py - History importer → JSON storage and backups: bulk saves assignments
import_history.py - History importer → Statistics calculations: uses statistics service
import_history.py - Administrator → Admin commands: runs admin commands
README.md - Manager → Commands and statistics views: requests statistics
README.md