How hmhung1/zalo-bot works
This is a Zalo chat bot: it authenticates, loads command and event plugins, then turns incoming Zalo events into message objects and dispatches them to handlers. Commands can respond through the bot API; the bot also maintains user, group, and currency records, while the checktt command separately records group interaction statistics in JSON files. The excerpts show the main startup and listener wiring, but not every handler or plugin implementation, so those subsystems are represented at directory level where appropriate.
Main entry points: Client.js Client setup · listen.js Event listener · checktt.js Group interaction stats · commands Command plugins
Components 25
Bot runtime
- Startup entry
index.js - Client setup
core/Client.js - Bot configuration
config.js - Environment loader
core/util/Env.js - Logging
core/util/log.js
Message dispatch
- Event listener
core/listen.js - Command handler
core/handle/handleCommand.js - Reply handler
core/handle/handleReply.js - Message handler
core/handle/handleMessage.js - Event handler
core/handle/handleEvent.js - Record initialization
core/handle/handleCreateDatabase.js
Persistence
- Database connection
core/database/data/index.js - User model
core/database/data/models/users.js - Group model
core/database/data/models/groups.js - Currency model
core/database/data/models/currencies.js - User data access
core/database/users.js - Group data access
core/database/groups.js - Currency data access
core/database/currencies.js - Interaction statistics files
core/data/checktt
Commands and integrations
- Command plugins
plugins/commands - Group interaction stats
plugins/commands/checktt.js - Event plugins
plugins/events - Media API helpers
core/util/api.js
Other components
- Bot operator
- Zalo platform
Connections 28
- Bot operator → Startup entry: starts bot
README.md - Startup entry → Client setup: starts client
index.js - Client setup → Bot configuration: reads settings
core/Client.js - Client setup → Environment loader: loads environment
core/Client.js - Client setup → Database connection: authenticates
core/Client.js - Client setup → User model: creates model
core/Client.js - Client setup → Group model: creates model
core/Client.js - Client setup → Currency model: creates model
core/Client.js - Client setup → Event listener: starts listener
core/Client.js - Client setup → Command plugins: loads plugins
core/Client.js - Client setup → Event plugins: loads plugins
core/Client.js - Client setup → Zalo platform: logs in
core/Client.js - Event listener → Zalo platform: registers listener
core/listen.js - Event listener → User data access: initializes access
core/listen.js - Event listener → Group data access: initializes access
core/listen.js - Event listener → Currency data access: initializes access
core/listen.js - Event listener → Command handler: dispatches messages
core/listen.js - Event listener → Reply handler: dispatches messages
core/listen.js - Event listener → Message handler: dispatches messages
core/listen.js - Event listener → Record initialization: dispatches messages
core/listen.js - Event listener → Event handler: dispatches events
core/listen.js - Reply handler → Command plugins: routes reply
core/handle/handleReply.js - Client setup → Logging: reports status
core/Client.js - Group interaction stats → Group data access: reads group data
plugins/commands/checktt.js - Group interaction stats → User data access: reads user info
plugins/commands/checktt.js - Group interaction stats → Zalo platform: sends responses
- Group interaction stats → Interaction statistics files: reads and writes
plugins/commands/checktt.js - Command plugins → Media API helpers: uses media helpers
plugins/commands/sing.js