How tencent-connect/botpy works
botpy is an asynchronous Python SDK for QQ bot platform APIs. The primary workflow is: an application configures event intents and starts Client; the client establishes gateway sessions, incoming events are parsed into domain objects and dispatched to application handlers, which can invoke BotAPI methods that issue authenticated HTTP requests. The SDK also exposes channel, guild, forum, interaction, audio, user, reaction, and management capabilities. The source excerpts establish the main gateway and HTTP calls; some subsystem links are README-backed or omitted where their caller was not sampled.
Main entry points: connection.py Event Parsing · client.py Client Lifecycle · api.py Bot API · http.py HTTP Client
Components 21
Client Runtime
- Client Lifecycle
botpy/client.py - Event Intents
botpy/flags.py - Shard Session
botpy/types/session.py
Gateway Events
- Gateway Transport
botpy/gateway.py - Event Parsing
botpy/connection.py
Platform API
- Bot API
botpy/api.py - HTTP Client
botpy/http.py
Domain Models
- Message Events
botpy/message.py - Guild Events
botpy/guild.py - Channel Events
botpy/channel.py - Forum Events
botpy/forum.py - Interaction Events
botpy/interaction.py - Audio Events
botpy/audio.py - Reaction Events
botpy/reaction.py - Management Events
botpy/manage.py - API Payload Types
botpy/types
Runtime Support
- Token Auth
botpy/robot.py - Logging
botpy/logging.py - SDK Extensions
botpy/ext
Other components
- Bot Application
- QQ Bot Platform
Connections 27
- Bot Application → Client Lifecycle: starts
README.md - Bot Application → Event Intents: configures
README.md - Client Lifecycle → Event Intents: uses
botpy/client.py - Client Lifecycle → Bot API: creates
botpy/client.py - Client Lifecycle → Gateway Transport: starts sessions
botpy/client.py - Client Lifecycle → Shard Session: builds shards
botpy/client.py - Gateway Transport → Event Parsing: delivers events
botpy/gateway.py - Event Parsing → Message Events: constructs messages
botpy/connection.py - Event Parsing → Guild Events: constructs events
botpy/connection.py - Event Parsing → Channel Events: constructs events
botpy/connection.py - Event Parsing → Forum Events: constructs events
botpy/connection.py - Event Parsing → Interaction Events: constructs events
botpy/connection.py - Event Parsing → Audio Events: constructs events
botpy/connection.py - Event Parsing → Reaction Events: constructs events
botpy/connection.py - Event Parsing → Management Events: constructs events
botpy/connection.py - Event Parsing → Client Lifecycle: dispatches handlers
botpy/connection.py - Client Lifecycle → Bot Application: dispatches callbacks
botpy/client.py - Bot Application → Bot API: invokes endpoints
README.md - Message Events → Bot API: replies via
botpy/message.py - Bot API → HTTP Client: sends requests
botpy/api.py - HTTP Client → QQ Bot Platform: HTTP requests
botpy/http.py - HTTP Client → Token Auth: uses credentials
botpy/http.py - Token Auth → QQ Bot Platform: fetches access token
botpy/robot.py - Bot API → API Payload Types: uses schemas
botpy/api.py - Client Lifecycle → Logging: configures
botpy/client.py - HTTP Client → Logging: logs requests
botpy/http.py - Bot Application → SDK Extensions: may use