Userbot Deployer
Runs many Pyrogram user clients concurrently in one process from sessions in MongoDB, with a dependency-free AST checker that fails CI on un-awaited async database calls.
- Project
- Multi-tenant orchestrator
- Language
- Python
- Started
- 2024-04
The story
A manager that provisions, updates and runs client userbots on demand. Source is private; the part worth describing is the tooling around it.
Forgetting await on an async Mongo call is invisible: nothing raises, nothing logs, the write just never lands. So check_await.py walks the syntax tree in CI and fails the build on it. No dependency, roughly a screen of code, and it has caught the bug more than once.
That is the pattern I keep returning to — when a mistake is cheap to make and expensive to find, encode the rule where it runs automatically instead of trusting review.
Under the hood
The decisions that make it work.
- In-process concurrency
- A manager provisions and runs individual user clients in one event loop from session strings held in MongoDB.
- Static policy check
- check_await.py walks the AST and fails CI on un-awaited AsyncMongoClient calls — the class of bug that passes review and silently drops writes.
- Payments
- Razorpay UPI QR flow with OpenCV-side QR decoding, alongside Telegram Stars.