Skip to content

The agent that grows with you

fix(qqbot): setup status reads .env like the old core wizard row

Teknium7ada20f7ad64
diff --git a/plugins/platforms/qqbot/register.py b/plugins/platforms/qqbot/register.py
index 63ea214d6eb..819f0dbdce2 100644
--- a/plugins/platforms/qqbot/register.py
+++ b/plugins/platforms/qqbot/register.py
@@ -7,27 +7,20 @@ connection.
from __future__ import annotations
-from typing import Optional
-
-from gateway.platforms._shared import get_scoped_secret
+from gateway.platforms._shared import env_is_connected
from .adapter import QQAdapter, check_qq_requirements
-def _scoped(name: str) -> str:
- return str(get_scoped_secret(name, "") or "").strip()
-
-
-def _credentials_configured(extra: Optional[dict] = None) -> bool:
- extra = extra or {}
- app_id = str(extra.get("app_id") or "").strip() or _scoped("QQ_APP_ID")
- secret = str(extra.get("client_secret") or "").strip() or _scoped("QQ_CLIENT_SECRET")
- return bool(app_id and secret)
+_env_configured = env_is_connected("QQ_APP_ID", "QQ_CLIENT_SECRET")
def is_connected(pconfig) -> bool:
+ """Both credentials from ``extra`` (config.yaml) or the profile env / ``.env``."""
extra = getattr(pconfig, "extra", None) or {}
- return _credentials_configured(extra)
+ if str(extra.get("app_id") or "").strip() and str(extra.get("client_secret") or "").strip():
+ return True
+ return _env_configured(pconfig)
async def standalone_send(pconfig, chat_id, message, *, thread_id=None, media_files=None,
diff --git a/tests/plugins/platforms/test_qqbot_plugin.py b/tests/plugins/platforms/test_qqbot_plugin.py
index d2e68890b38..ea48c1fd6a0 100644
--- a/tests/plugins/platforms/test_qqbot_plugin.py
+++ b/tests/plugins/platforms/test_qqbot_plugin.py
@@ -40,11 +40,16 @@ def test_register_shape():
def test_is_connected_needs_both_credentials(monkeypatch):
_clear_qq(monkeypatch)
+ import hermes_cli.gateway as gateway_mod
+ monkeypatch.setattr(gateway_mod, "get_env_value", lambda name: None)
from gateway.config import PlatformConfig
from plugins.platforms.qqbot.register import is_connected
assert is_connected(PlatformConfig(enabled=True, extra={"app_id": "a"})) is False
assert is_connected(PlatformConfig(enabled=True, extra={"app_id": "a", "client_secret": "s"})) is True
+ env = {"QQ_APP_ID": "a", "QQ_CLIENT_SECRET": "s"}
+ monkeypatch.setattr(gateway_mod, "get_env_value", env.get)
+ assert is_connected(PlatformConfig(enabled=True)) is True
def test_qqbot_platform_hint_comes_from_the_builtin_table():