Skip to content

Conversation

a490077
Copy link

@a490077 a490077 commented Oct 18, 2025

fixes #3076

Motivation / 动机

QQ官方机器人增加沙盒模式选项,让本地部署能跳过IP白名单验证

Modifications / 改动点

修改qq官方机器人适配器服务 qo_webhook_server.py : QQOfficialWebhook 类中的 BotHttp 实例化传入参数
增加默认适配器中的配置选项 default.py : "is_sandbox": False

Compatibility & Breaking Changes / 兼容性与破坏性变更

  • 这不是一个破坏性变更。/ This is NOT a breaking change.

Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。/ If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。/ My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。/ My changes do not introduce malicious code.

@auto-assign auto-assign bot requested review from Fridemn and advent259141 October 18, 2025 07:57
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗨,您好!我已审阅了您的更改,它们看起来很棒!

给AI代理的提示
请处理此代码审查中的评论:

## 独立评论

### 评论 1
<location> `astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_server.py:18` </location>
<code_context>
         self.appid = config["appid"]
         self.secret = config["secret"]
         self.port = config.get("port", 6196)
+        self.is_sandbox = config.get("is_sandbox", False)
         self.callback_server_host = config.get("callback_server_host", "0.0.0.0")

</code_context>

<issue_to_address>
**建议:** 考虑验证配置中 'is_sandbox' 的类型。

明确地将 'is_sandbox' 转换为布尔值或进行验证,以防止其值从配置源以字符串形式出现时引发问题。

```suggestion
        is_sandbox_raw = config.get("is_sandbox", False)
        if isinstance(is_sandbox_raw, str):
            self.is_sandbox = is_sandbox_raw.lower() in ("true", "1", "yes", "on")
        else:
            self.is_sandbox = bool(is_sandbox_raw)
```
</issue_to_address>

### 评论 2
<location> `astrbot/core/config/default.py:163-166` </location>
<code_context>
                         "enable": False,
                         "appid": "",
                         "secret": "",
+                        "is_sandbox": False,
                         "callback_server_host": "0.0.0.0",
                         "port": 6196,
</code_context>

<issue_to_address>
**建议:** 考虑在配置中记录 'is_sandbox' 的用途。

阐明 'is_sandbox' 如何影响配置将帮助维护人员避免混淆并确保正确使用。

```suggestion
                        "appid": "",
                        "secret": "",
                        # If True, enables sandbox mode for API requests (use for testing/development).
                        # When set to False, production endpoints and credentials are used.
                        "is_sandbox": False,
                        "callback_server_host": "0.0.0.0",
```
</issue_to_address>

Sourcery 对开源项目免费 - 如果您喜欢我们的评论,请考虑分享它们 ✨
帮助我更有用!请点击每个评论旁边的👍或👎,我将使用这些反馈来改进您的评论。
Original comment in English

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_server.py:18` </location>
<code_context>
         self.appid = config["appid"]
         self.secret = config["secret"]
         self.port = config.get("port", 6196)
+        self.is_sandbox = config.get("is_sandbox", False)
         self.callback_server_host = config.get("callback_server_host", "0.0.0.0")

</code_context>

<issue_to_address>
**suggestion:** Consider validating the type of 'is_sandbox' from config.

Explicitly cast or validate 'is_sandbox' as a boolean to prevent issues if its value comes as a string from config sources.

```suggestion
        is_sandbox_raw = config.get("is_sandbox", False)
        if isinstance(is_sandbox_raw, str):
            self.is_sandbox = is_sandbox_raw.lower() in ("true", "1", "yes", "on")
        else:
            self.is_sandbox = bool(is_sandbox_raw)
```
</issue_to_address>

### Comment 2
<location> `astrbot/core/config/default.py:163-166` </location>
<code_context>
                         "enable": False,
                         "appid": "",
                         "secret": "",
+                        "is_sandbox": False,
                         "callback_server_host": "0.0.0.0",
                         "port": 6196,
</code_context>

<issue_to_address>
**suggestion:** Consider documenting the purpose of 'is_sandbox' in config.

Clarifying how 'is_sandbox' affects configuration will help maintainers avoid confusion and ensure correct usage.

```suggestion
                        "appid": "",
                        "secret": "",
                        # If True, enables sandbox mode for API requests (use for testing/development).
                        # When set to False, production endpoints and credentials are used.
                        "is_sandbox": False,
                        "callback_server_host": "0.0.0.0",
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]QQ官方机器人增加沙箱模式选项

1 participant