Skip to content

Commit

Permalink
Merge pull request #282 from AmiyaBot/V6-dev
Browse files Browse the repository at this point in the history
update 支持内网穿透
  • Loading branch information
vivien8261 authored Aug 17, 2024
2 parents 91945ca + 2b2cb8d commit 3aed4e3
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/publish.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v6.5.3
v6.5.4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

config/cos.yaml
config/remote.yaml
config/penetration.yaml
main*.py

*.pyc
Expand Down
1 change: 1 addition & 0 deletions core/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .cos import cos_config
from .remote import remote_config
from .penetration import penetration_config
14 changes: 14 additions & 0 deletions core/config/penetration.py
Original file line number Diff line number Diff line change
@@ -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')
28 changes: 18 additions & 10 deletions core/database/bot.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -103,21 +103,29 @@ 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,
default_chain_builder=COSQQGroupChainBuilder(opt),
**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)
Expand Down
2 changes: 1 addition & 1 deletion pluginsDev

0 comments on commit 3aed4e3

Please sign in to comment.