How rimuwu/dinogochi works
Purpose and Entry Points
DinoGochi is a Python Telegram RPG/tamagotchi bot: users own dinosaurs, manage needs and activities, travel, craft, trade, fight, and participate in social/game systems. Process startup is main.py, with bot construction/runtime wiring in bot/bot_instance.py and executable/bootstrap logic in bot/exec.py. Configuration is generated/read through bot/config.py.
Telegram Request Pipeline
Telegram updates are routed into the extensive handler layer, organized by product domain: live activities, menus, combat, market, quests, crafting, arena, and inline interactions. Authorization, chat/type/state gating occur before handlers via filters; middleware provides cross-cutting antiflood, callback antiflood, logging, and worker-pass behavior.
• bot/handlers/actions_live/
• bot/handlers/main_menu/
• bot/filters/
• bot/middlewares/
Persistent Game State
MongoDB is the primary required datastore, accessed through dedicated database management code. Domain models represent persisted users, dinosaurs, groups, activities, items, market listings, arena, tavern, and tracking data. Redis is also materially present through a separate manager and Redis-backed user/tavern facilities, likely supporting cache or ephemeral coordination boundaries.
• bot/dbmanager.py
• bot/redismanager.py
• bot/models/user.py
• bot/models/dinosaur.py
• bot/models/activity/
Game Domain and Content Definition
The game’s durable rules/data boundary combines Python item/activity dataclasses and static JSON catalogs. Item classes encode behavior/categories; models represent active timed work such as collecting, crafting, journey, sleep, games, and training. JSON supplies dinosaurs, eggs, mobs, quests, shops, journey configuration, recipes, and item definitions, enabling content changes independently of much handler code.
• bot/dataclasess/items/
• bot/models/activity/
• bot/json/items/
• bot/json/dinosaurs.json
Domain Services and Gameplay Modules
Handlers delegate core operations to reusable modules for dinosaur state, inventory/items/crafting, combat strategy, market flows, quests, groups, dialogs, notifications, localization, and user features. This layer is the key boundary between Telegram-facing interaction code and database/content-backed game mutations.
• bot/modules/dinosaur/
• bot/modules/items/
• bot/modules/combat/
• bot/modules/market/
• bot/modules/quests.py
Timed Processing and Background Control Flow
A task subsystem advances time-dependent simulation independently of user messages: dinosaur states, incubation, journeys, sleep, collecting, crafting, games, market expiration, arena, events, notifications, subscriptions, backups, and reporting. Task orchestration/queue abstractions sit alongside these scheduled job implementations.
• bot/taskmanager.py
• bot/modules/task_queue.py
• bot/tasks/
• bot/tasks/dino_states.py
Integrations, Delivery, and Assets
The bot integrates Telegram as its primary external platform, MongoDB and Redis for state, plus payment/advertising-related modules (CryptoBot, Telegram Stars/invoices, donations, ads). Docker Compose packages the runtime; Nginx configuration and a webhook server module indicate deployment may support reverse-proxied webhook delivery rather than only polling. Localized UI strings and image/font assets support multilingual, media-rich responses.
• docker-compose.yml
• nginx/nginx.conf.template
• bot/modules/webhook_server.py
• bot/modules/cryptobot.py
• bot/localization/
Main entry points: exec.py Bot bootstrap · user.py Game models · bot_instance.py Bot instance · dbmanager.py Mongo manager
Components 22
Runtime
- Process entry
main.py - Bot bootstrap
bot/exec.py - Bot instance
bot/bot_instance.py - Configuration
bot/config.py
Telegram Interface
- Domain handlers · Routes menus, activities, combat, market, quests, crafting, arena, and inline actions.
- Filters
- Middleware · Provides antiflood, callback protection, logging, and worker-pass behavior.
Game Domain
- Gameplay modules · Mutate game state for dinosaurs, items, combat, market, quests, groups, and dialogs.
- Item rules
State & Content
- Game models · Includes users, dinosaurs, groups, listings, and active timed activities.
bot/models/user.py - Activity models · Represents collecting, crafting, journeys, sleep, games, and training.
- Content catalogs · Defines items, dinosaurs, eggs, mobs, quests, shops, journeys, and recipes.
- Mongo manager
bot/dbmanager.py - Redis manager
bot/redismanager.py
Background Processing
- Task manager
bot/taskmanager.py - Task queue
bot/modules/task_queue.py - Scheduled game tasks · Advances states, incubation, journeys, activities, markets, arena, events, notifications, backups, and reporting.
External Services
- Telegram
- MongoDB
- Redis
- Webhook delivery
bot/modules/webhook_server.py - Payments and ads · Supports CryptoBot, Telegram Stars/invoices, donations, and advertising.
bot/modules/cryptobot.py
Connections 24
- Process entry → Bot bootstrap: starts
- Bot bootstrap → Bot instance: constructs
- Bot bootstrap → Configuration: loads
- Bot instance → Middleware: processes through
- Middleware → Filters: applies
- Filters → Domain handlers: permits updates to
- Telegram → Bot instance: delivers updates
- Webhook delivery → Bot instance: forwards webhook updates
- Domain handlers → Gameplay modules: delegates gameplay to
- Domain handlers → Payments and ads: initiates purchases and ads
- Gameplay modules → Item rules: uses
- Gameplay modules → Content catalogs: reads rules and catalogs
- Gameplay modules → Game models: reads and mutates
- Game models → Activity models: includes active work
- Game models → Mongo manager: persists through
- Mongo manager → MongoDB: accesses
- Gameplay modules → Redis manager: uses ephemeral facilities
- Redis manager → Redis: accesses
- Bot bootstrap → Task manager: starts
- Task manager → Task queue: orchestrates
- Task queue → Scheduled game tasks: dispatches
- Scheduled game tasks → Gameplay modules: advances game state via
- Scheduled game tasks → Game models: updates
- Scheduled game tasks → Mongo manager: persists state