#### 问题现象(AI总结) - 在通过 Web 面板或配置变更热重载 Discord 平台时,适配器的 terminate() 方法会被调用,但经常出现“卡死”或长时间无响应,导致 Discord 平台无法优雅重载。 - 日志显示停留在“正在清理已注册的斜杠指令...”等步骤,甚至出现超时或异常。 #### 2. 原因分析 - 适配器的 terminate() 方法中,涉及多个异步操作(如取消 polling 任务、清理斜杠指令、关闭客户端)。 - 某些 await 操作(如 await self.client.sync_commands() 或 await self.client.close())在网络异常、事件循环被取消等情况下,可能会阻塞或抛出 CancelledError,导致整个重载流程卡住。 - 之前的实现没有对这些 await 操作加超时保护,也没有分步日志,难以定位具体卡点。 #### 3. 修复措施 - 分步日志:在 terminate() 的每个关键步骤前后都加了详细日志,便于定位卡点。 - 超时保护:对所有关键 await 操作(如 polling 任务取消、指令清理、客户端关闭)都加了 asyncio.wait_for(..., timeout=10),防止无限阻塞。 - 健壮性提升:先 cancel polling 任务,再清理指令,最后关闭客户端。每一步都捕获异常并输出日志,保证即使某一步失败也能继续后续清理。 - 避免重复终止:移除了 run() 方法中的 finally: await self.terminate(),只允许外部统一调度,防止重复调用导致资源冲突或日志重复。 #### 4. 修复效果 - 现在 Discord 平台适配器在热重载或终止时,能优雅地依次完成所有清理步骤,不会因某一步阻塞导致整个流程卡死。
AstrBot is a loosely coupled, asynchronous chatbot and development framework that supports multi-platform deployment, featuring an easy-to-use plugin system and comprehensive Large Language Model (LLM) integration capabilities.
✨ Key Features
- LLM Conversations - Supports various LLMs including OpenAI API, Google Gemini, Llama, Deepseek, ChatGLM, etc. Enables local model deployment via Ollama/LLMTuner. Features multi-turn dialogues, personality contexts, multimodal capabilities (image understanding), and speech-to-text (Whisper).
- Multi-platform Integration - Supports QQ (OneBot), QQ Channels, WeChat (Gewechat), Feishu, and Telegram. Planned support for DingTalk, Discord, WhatsApp, and Xiaomi Smart Speakers. Includes rate limiting, whitelisting, keyword filtering, and Baidu content moderation.
- Agent Capabilities - Native support for code execution, natural language TODO lists, web search. Integrates with Dify Platform for easy access to Dify assistants/knowledge bases/workflows.
- Plugin System - Optimized plugin mechanism with minimal development effort. Supports multiple installed plugins.
- Web Dashboard - Visual configuration management, plugin controls, logging, and WebChat interface for direct LLM interaction.
- High Stability & Modularity - Event bus and pipeline architecture ensures high modularization and loose coupling.
Tip
Dashboard Demo: https://demo.astrbot.app/
Username:astrbot, Password:astrbot(LLM not configured for chat page)
✨ Deployment
Docker Deployment
See docs: Deploy with Docker
Windows Installer
Requires Python (>3.10). See docs: Windows Installer Guide
Replit Deployment
CasaOS Deployment
Community-contributed method.
See docs: CasaOS Deployment
Manual Deployment
See docs: Source Code Deployment
⚡ Platform Support
| Platform | Status | Details | Message Types |
|---|---|---|---|
| QQ (Official Bot) | ✔ | Private/Group chats | Text, Images |
| QQ (OneBot) | ✔ | Private/Group chats | Text, Images, Voice |
| WeChat (Personal) | ✔ | Private/Group chats | Text, Images, Voice |
| Telegram | ✔ | Private/Group chats | Text, Images |
| WeChat Work | ✔ | Private chats | Text, Images, Voice |
| Feishu | ✔ | Group chats | Text, Images |
| WeChat Open Platform | 🚧 | Planned | - |
| Discord | 🚧 | Planned | - |
| 🚧 | Planned | - | |
| Xiaomi Speakers | 🚧 | Planned | - |
Provider Support Status
| Name | Support | Type | Notes |
|---|---|---|---|
| OpenAI API | ✔ | Text Generation | Supports all OpenAI API-compatible services including DeepSeek, Google Gemini, GLM, Moonshot, Alibaba Cloud Bailian, Silicon Flow, xAI, etc. |
| Claude API | ✔ | Text Generation | |
| Google Gemini API | ✔ | Text Generation | |
| Dify | ✔ | LLMOps | |
| DashScope (Alibaba Cloud) | ✔ | LLMOps | |
| Ollama | ✔ | Model Loader | Local deployment for open-source LLMs (DeepSeek, Llama, etc.) |
| LM Studio | ✔ | Model Loader | Local deployment for open-source LLMs (DeepSeek, Llama, etc.) |
| LLMTuner | ✔ | Model Loader | Local loading of fine-tuned models (e.g. LoRA) |
| OneAPI | ✔ | LLM Distribution | |
| Whisper | ✔ | Speech-to-Text | Supports API and local deployment |
| SenseVoice | ✔ | Speech-to-Text | Local deployment |
| OpenAI TTS API | ✔ | Text-to-Speech | |
| Fishaudio | ✔ | Text-to-Speech | Project involving GPT-Sovits author |
🦌 Roadmap
Tip
Suggestions welcome via Issues <3
- Ensure feature parity across all platform adapters
- Optimize plugin APIs
- Add default TTS services (e.g., GPT-Sovits)
- Enhance chat features with persistent memory
- i18n Planning
❤️ Contributions
All Issues/PRs welcome! Simply submit your changes to this project :)
For major features, please discuss via Issues first.
🌟 Support
✨ Demos
Note
Code executor file I/O currently tested with Napcat(QQ)/Lagrange(QQ)
✨ Docker-based Sandboxed Code Executor (Beta) ✨
✨ Multimodal Input, Web Search, Text-to-Image ✨
✨ Natural Language TODO Lists ✨
✨ Plugin System Showcase ✨
✨ Web Dashboard ✨
✨ Built-in Web Chat Interface ✨
⭐ Star History
Tip
If this project helps you, please give it a star <3
Disclaimer
- Licensed under
AGPL-v3. - WeChat integration uses Gewechat. Use at your own risk with non-critical accounts.
- Users must comply with local laws and regulations.
私は、高性能ですから!
