mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-12 06:55:58 +08:00
✨ 添加at_list
和reply
支持
This commit is contained in:
parent
3254ac2d09
commit
192f880a6d
@ -45,6 +45,13 @@ async def get_gs_msg(ev):
|
||||
else:
|
||||
bot_id = 'onebot'
|
||||
|
||||
try:
|
||||
if ev.sender['role'] == 'owner' or ev.sender['role'] == 'admin':
|
||||
pm = 2
|
||||
except Exception as e:
|
||||
logger.warning(e)
|
||||
pm = 3
|
||||
|
||||
# 处理消息
|
||||
for _msg in messages:
|
||||
if _msg.type == 'text':
|
||||
@ -60,6 +67,8 @@ async def get_gs_msg(ev):
|
||||
message.append(Message('image', _msg.data['url']))
|
||||
elif _msg.type == 'at':
|
||||
message.append(Message('at', _msg.data['qq']))
|
||||
elif _msg.type == 'reply':
|
||||
message.append(Message('reply', _msg.data['id']))
|
||||
if not message:
|
||||
return
|
||||
|
||||
|
@ -25,7 +25,9 @@ class GsClient:
|
||||
cls.is_alive = True
|
||||
cls.ws_url = f'ws://{IP}:{PORT}/ws/{BOT_ID}'
|
||||
logger.info(f'Bot_ID: {BOT_ID}连接至[gsuid-core]: {self.ws_url}...')
|
||||
cls.ws = await websockets.client.connect(cls.ws_url, max_size=2**26)
|
||||
cls.ws = await websockets.client.connect(
|
||||
cls.ws_url, max_size=2**26, open_timeout=60, ping_timeout=60
|
||||
)
|
||||
logger.info(f'与[gsuid-core]成功连接! Bot_ID: {BOT_ID}')
|
||||
cls.msg_list = asyncio.queues.Queue()
|
||||
return self
|
||||
@ -43,6 +45,11 @@ class GsClient:
|
||||
)
|
||||
# 解析消息
|
||||
if msg.bot_id == 'NoneBot2':
|
||||
if msg.content:
|
||||
_data = msg.content[0]
|
||||
if _data.type and _data.type.startswith('log'):
|
||||
_type = _data.type.split('_')[-1].lower()
|
||||
getattr(logger, _type)(_data.data)
|
||||
continue
|
||||
|
||||
bot = hoshino_bot
|
||||
@ -51,6 +58,7 @@ class GsClient:
|
||||
image: Optional[str] = None
|
||||
node = []
|
||||
file = ''
|
||||
at_list = []
|
||||
if msg.content:
|
||||
for _c in msg.content:
|
||||
if _c.data:
|
||||
@ -58,13 +66,12 @@ class GsClient:
|
||||
content += _c.data
|
||||
elif _c.type == 'image':
|
||||
image = _c.data
|
||||
elif _c.type and _c.type.startswith('log'):
|
||||
_type = _c.type.split('_')[-1].lower()
|
||||
getattr(logger, _type)(_c.data)
|
||||
elif _c.type == 'node':
|
||||
node = _c.data
|
||||
elif _c.type == 'file':
|
||||
file = _c.data
|
||||
elif _c.type == 'at':
|
||||
at_list.append(_c.data)
|
||||
else:
|
||||
pass
|
||||
|
||||
@ -84,6 +91,7 @@ class GsClient:
|
||||
node,
|
||||
file,
|
||||
ids,
|
||||
at_list,
|
||||
msg.target_id,
|
||||
msg.target_type,
|
||||
)
|
||||
@ -140,6 +148,7 @@ async def onebot_send(
|
||||
node: Optional[List[Dict]],
|
||||
file: Optional[str],
|
||||
bot_self_id: Optional[str],
|
||||
at_list: Optional[List[str]],
|
||||
target_id: Optional[str],
|
||||
target_type: Optional[str],
|
||||
):
|
||||
@ -147,6 +156,9 @@ async def onebot_send(
|
||||
result_image = f'[CQ:image,file={image}]' if image else ''
|
||||
content = content if content else ''
|
||||
result_msg = content + result_image
|
||||
if at_list and target_type == 'group':
|
||||
for at in at_list:
|
||||
result_msg += f'[CQ:at,qq={at}]'
|
||||
|
||||
if file:
|
||||
file_name, file_content = file.split('|')
|
||||
|
20
poetry.lock
generated
20
poetry.lock
generated
@ -89,14 +89,14 @@ files = [
|
||||
|
||||
[[package]]
|
||||
name = "filelock"
|
||||
version = "3.10.6"
|
||||
version = "3.10.7"
|
||||
description = "A platform independent file lock."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "filelock-3.10.6-py3-none-any.whl", hash = "sha256:52f119747b2b9c4730dac715a7b1ab34b8ee70fd9259cba158ee53da566387ff"},
|
||||
{file = "filelock-3.10.6.tar.gz", hash = "sha256:409105becd604d6b176a483f855e7e8903c5cb2873e47f2c64f66a370c046aaf"},
|
||||
{file = "filelock-3.10.7-py3-none-any.whl", hash = "sha256:bde48477b15fde2c7e5a0713cbe72721cb5a5ad32ee0b8f419907960b9d75536"},
|
||||
{file = "filelock-3.10.7.tar.gz", hash = "sha256:892be14aa8efc01673b5ed6589dbccb95f9a8596f0507e232626155495c18105"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
@ -549,14 +549,14 @@ files = [
|
||||
|
||||
[[package]]
|
||||
name = "setuptools"
|
||||
version = "67.6.0"
|
||||
version = "67.6.1"
|
||||
description = "Easily download, build, install, upgrade, and uninstall Python packages"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "setuptools-67.6.0-py3-none-any.whl", hash = "sha256:b78aaa36f6b90a074c1fa651168723acbf45d14cb1196b6f02c0fd07f17623b2"},
|
||||
{file = "setuptools-67.6.0.tar.gz", hash = "sha256:2ee892cd5f29f3373097f5a814697e397cf3ce313616df0af11231e2ad118077"},
|
||||
{file = "setuptools-67.6.1-py3-none-any.whl", hash = "sha256:e728ca814a823bf7bf60162daf9db95b93d532948c4c0bea762ce62f60189078"},
|
||||
{file = "setuptools-67.6.1.tar.gz", hash = "sha256:257de92a9d50a60b8e22abfcbb771571fde0dbf3ec234463212027a4eeecbe9a"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
@ -590,14 +590,14 @@ files = [
|
||||
|
||||
[[package]]
|
||||
name = "tomlkit"
|
||||
version = "0.11.6"
|
||||
version = "0.11.7"
|
||||
description = "Style preserving TOML library"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "tomlkit-0.11.6-py3-none-any.whl", hash = "sha256:07de26b0d8cfc18f871aec595fda24d95b08fef89d147caa861939f37230bf4b"},
|
||||
{file = "tomlkit-0.11.6.tar.gz", hash = "sha256:71b952e5721688937fb02cf9d354dbcf0785066149d2855e44531ebdd2b65d73"},
|
||||
{file = "tomlkit-0.11.7-py3-none-any.whl", hash = "sha256:5325463a7da2ef0c6bbfefb62a3dc883aebe679984709aee32a317907d0a8d3c"},
|
||||
{file = "tomlkit-0.11.7.tar.gz", hash = "sha256:f392ef70ad87a672f02519f99967d28a4d3047133e2d1df936511465fbb3791d"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
Loading…
x
Reference in New Issue
Block a user