diff --git a/.github/publish.txt b/.github/publish.txt index d0ca9ece..67262286 100644 --- a/.github/publish.txt +++ b/.github/publish.txt @@ -1 +1 @@ -v6.5.3 +v6.5.4 diff --git a/.gitignore b/.gitignore index c0fc8210..a4eebd4b 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ config/cos.yaml config/remote.yaml +config/penetration.yaml main*.py *.pyc diff --git a/core/config/__init__.py b/core/config/__init__.py index b819af45..c9c43f0d 100644 --- a/core/config/__init__.py +++ b/core/config/__init__.py @@ -1,2 +1,3 @@ from .cos import cos_config from .remote import remote_config +from .penetration import penetration_config diff --git a/core/config/penetration.py b/core/config/penetration.py new file mode 100644 index 00000000..a6f7fc17 --- /dev/null +++ b/core/config/penetration.py @@ -0,0 +1,14 @@ +from dataclasses import dataclass, field +from core.util import init_config_file + + +@dataclass +class Penetration: + ports: dict = field(default_factory=dict) + + +def init(file: str) -> Penetration: + return init_config_file(file, Penetration) + + +penetration_config = init('config/penetration.yaml') diff --git a/core/database/bot.py b/core/database/bot.py index 1f0b0738..786a4901 100644 --- a/core/database/bot.py +++ b/core/database/bot.py @@ -1,13 +1,13 @@ from amiyabot import AmiyaBot, KOOKBotInstance from amiyabot.database import * -from core.config import cos_config +from core.config import cos_config, penetration_config from core.database import config, is_mysql from core.cosChainBuilder import COSQQGroupChainBuilder from typing import Union from amiyabot.adapters.tencent.qqGuild import qq_guild_shards from amiyabot.adapters.tencent.qqGlobal import qq_global -from amiyabot.adapters.tencent.qqGroup import qq_group, QQGroupChainBuilderOptions +from amiyabot.adapters.tencent.qqGroup import qq_group, QQGroupChainBuilder, QQGroupChainBuilderOptions from amiyabot.adapters.cqhttp import cq_http from amiyabot.adapters.mirai import mirai_api_http from amiyabot.adapters.onebot.v11 import onebot11 @@ -103,9 +103,9 @@ def build_conf(cls, item): if item.adapter == 'qq_guild': conf['adapter'] = adapter(**shards, sandbox=bool(item.sandbox)) else: - opt = QQGroupChainBuilderOptions( - item.host or '0.0.0.0', item.http_port or 8086, './resource/group_temp' - ) + port = item.http_port or 8086 + opt = QQGroupChainBuilderOptions(item.host or '0.0.0.0', port, './resource/group_temp') + if cos_config.activate: conf['adapter'] = adapter( item.client_secret, @@ -113,11 +113,19 @@ def build_conf(cls, item): **shards, ) else: - conf['adapter'] = adapter( - item.client_secret, - default_chain_builder_options=opt, - **shards, - ) + + class PenetrationChainBuilder(QQGroupChainBuilder): + @property + def domain(self): + return ( + penetration_config.ports[port] + '/resource' + if port in penetration_config.ports + else super().domain + ) + + cb = PenetrationChainBuilder(opt) + + conf['adapter'] = adapter(item.client_secret, default_chain_builder=cb, **shards) if item.adapter == 'websocket': conf['adapter'] = test_instance(item.host, item.ws_port) diff --git a/pluginsDev b/pluginsDev index 65ccaaca..ad3c72c5 160000 --- a/pluginsDev +++ b/pluginsDev @@ -1 +1 @@ -Subproject commit 65ccaaca88267b31f49c3c1094b67b652887b929 +Subproject commit ad3c72c5b546570d52b31a4dc8fce2a8129c02b8