Files
chatrebot_aireply_plug/test.py
Claw 8c4c5074f2 重构为 openclaw_bridge 模板插件
- 将 process.py 替换为 OpenClaw Gateway QQ AI Reply 插件
- 新增 config/openclawbridge/config.toml(SDK 标准路径)
- 遵循 SDK 官方配置方式,移除硬编码默认值
- 内置高危词检测、管理员白名单、MC指令过滤
- 完善的 README.md 文档(使用说明+架构图+安全特性)
- packup.sh 增加『必须在目标主机打包』警告
- 保留 SDK 框架文件(plugin_modules.py, file_store_api.py 等)
- 更新 test.py 适配 openclaw_bridge 测试

注意:打包必须在目标主机执行,避免 C 扩展兼容性问题
2026-05-04 16:14:42 +08:00

61 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
测试框架 — 模拟 qqrebot 环境测试 openclaw_bridge 插件
"""
import os
import sys
import logging
from pathlib import Path
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
)
# 模拟 qqrebot 插件加载路径
sys.path.insert(0, str(Path(__file__).parent))
from src.modules.plugin_modules import MessageContext
from src.process import OpenClawBridge
class OpenclawBridgeTest:
def __init__(self):
self.test_simulate_chat()
def test_simulate_chat(self):
"""模拟接收到 QQ 消息"""
print("=" * 60)
print("OpenClawBridge 插件测试")
print("=" * 60)
# 模拟群聊消息上下文
mock_ctx = MessageContext(
uid="2198972886",
gid="12345678",
raw_message="你好",
id="123456789",
)
# 实例化插件(会加载配置并尝试连接 Gateway)
plugin = OpenClawBridge(mock_ctx)
print(f"\n配置状态:")
print(f" gateway_url: {plugin.gateway_url}")
print(f" allowed_sender: {plugin.allowed_sender}")
print(f" model: {plugin.model}")
print(f" agent_id: {plugin.agent_id}")
if not plugin.gateway_token or plugin.gateway_token == "your_gateway_token_here":
print("\n⚠️ 配置未修改,请先编辑 config/openclawbridge/config.toml")
print(" 填入正确的 gateway_token 后再运行测试\n")
print("\n执行 after_save...")
result = plugin.after_save()
print(f"返回: {result}")
print("=" * 60)
if __name__ == "__main__":
OpenclawBridgeTest()