mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-12 06:55:58 +08:00
✨ 适配频道被动消息带本地图
This commit is contained in:
parent
0e3aee4315
commit
36f2ba48ee
@ -29,16 +29,22 @@ async def send_char_adv(ev: Event):
|
|||||||
raw_data = ev.__dict__
|
raw_data = ev.__dict__
|
||||||
group_id = sessions[-2] if len(sessions) >= 2 else None
|
group_id = sessions[-2] if len(sessions) >= 2 else None
|
||||||
message: List[Message] = []
|
message: List[Message] = []
|
||||||
|
msg_id = ''
|
||||||
|
|
||||||
# ntchat
|
# qqguild
|
||||||
if '_message' in raw_data:
|
if '_message' in raw_data:
|
||||||
messages = raw_data['_message']
|
messages = raw_data['_message']
|
||||||
|
if 'direct_message' in raw_data and raw_data['direct_message']:
|
||||||
|
group_id = None
|
||||||
|
user_id = str(raw_data['guild_id'])
|
||||||
|
else:
|
||||||
group_id = str(raw_data['channel_id'])
|
group_id = str(raw_data['channel_id'])
|
||||||
# qqguild
|
msg_id = raw_data['id']
|
||||||
|
# ntchat
|
||||||
elif not messages and 'message' in raw_data:
|
elif not messages and 'message' in raw_data:
|
||||||
messages = raw_data['message']
|
messages = raw_data['message']
|
||||||
# ntchat
|
# ntchat
|
||||||
elif 'data' in raw_data:
|
if 'data' in raw_data:
|
||||||
if 'chatroom' in raw_data['data']['to_wxid']:
|
if 'chatroom' in raw_data['data']['to_wxid']:
|
||||||
group_id = raw_data['data']['to_wxid']
|
group_id = raw_data['data']['to_wxid']
|
||||||
if 'image' in raw_data['data']:
|
if 'image' in raw_data['data']:
|
||||||
@ -75,6 +81,7 @@ async def send_char_adv(ev: Event):
|
|||||||
group_id=group_id,
|
group_id=group_id,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
content=message,
|
content=message,
|
||||||
|
msg_id=msg_id,
|
||||||
)
|
)
|
||||||
logger.info(f'【发送】[gsuid-core]: {msg.bot_id}')
|
logger.info(f'【发送】[gsuid-core]: {msg.bot_id}')
|
||||||
await gsclient._input(msg)
|
await gsclient._input(msg)
|
||||||
@ -95,6 +102,7 @@ async def send_start_msg(matcher: Matcher):
|
|||||||
|
|
||||||
@driver.on_bot_connect
|
@driver.on_bot_connect
|
||||||
async def start_client():
|
async def start_client():
|
||||||
|
if gsclient is None:
|
||||||
await start()
|
await start()
|
||||||
await connect()
|
await connect()
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import base64
|
import base64
|
||||||
import asyncio
|
import asyncio
|
||||||
from typing import Dict, List, Union, Optional
|
from typing import Any, Dict, List, Union, Optional
|
||||||
|
|
||||||
import websockets.client
|
import websockets.client
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
@ -103,6 +103,7 @@ class GsClient:
|
|||||||
node,
|
node,
|
||||||
msg.target_id,
|
msg.target_id,
|
||||||
msg.target_type,
|
msg.target_type,
|
||||||
|
msg.msg_id,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
@ -199,9 +200,10 @@ async def guild_send(
|
|||||||
node: Optional[List[Dict]],
|
node: Optional[List[Dict]],
|
||||||
target_id: Optional[str],
|
target_id: Optional[str],
|
||||||
target_type: Optional[str],
|
target_type: Optional[str],
|
||||||
|
msg_id: Optional[str],
|
||||||
):
|
):
|
||||||
async def _send(content: Optional[str], image: Optional[str]):
|
async def _send(content: Optional[str], image: Optional[str]):
|
||||||
result = {}
|
result: Dict[str, Any] = {'msg_id': msg_id}
|
||||||
if image:
|
if image:
|
||||||
img_bytes = base64.b64decode(image.replace('base64://', ''))
|
img_bytes = base64.b64decode(image.replace('base64://', ''))
|
||||||
result['file_image'] = img_bytes
|
result['file_image'] = img_bytes
|
||||||
@ -213,6 +215,12 @@ async def guild_send(
|
|||||||
channel_id=int(target_id) if target_id else 0,
|
channel_id=int(target_id) if target_id else 0,
|
||||||
**result,
|
**result,
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
await bot.call_api(
|
||||||
|
'post_dms_messages',
|
||||||
|
guild_id=int(target_id) if target_id else 0,
|
||||||
|
**result,
|
||||||
|
)
|
||||||
|
|
||||||
if node:
|
if node:
|
||||||
for _msg in node:
|
for _msg in node:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from typing import Any, List, Optional
|
from typing import Any, List, Literal, Optional
|
||||||
|
|
||||||
from msgspec import Struct
|
from msgspec import Struct
|
||||||
|
|
||||||
@ -10,7 +10,8 @@ class Message(Struct):
|
|||||||
|
|
||||||
class MessageReceive(Struct):
|
class MessageReceive(Struct):
|
||||||
bot_id: str = 'Bot'
|
bot_id: str = 'Bot'
|
||||||
user_type: Optional[str] = None
|
msg_id: str = ''
|
||||||
|
user_type: Literal['group', 'direct', 'channel', 'sub_channel'] = 'group'
|
||||||
group_id: Optional[str] = None
|
group_id: Optional[str] = None
|
||||||
user_id: Optional[str] = None
|
user_id: Optional[str] = None
|
||||||
user_pm: int = 3
|
user_pm: int = 3
|
||||||
@ -30,6 +31,7 @@ class MessageContent(Struct):
|
|||||||
|
|
||||||
class MessageSend(Struct):
|
class MessageSend(Struct):
|
||||||
bot_id: str = 'Bot'
|
bot_id: str = 'Bot'
|
||||||
|
msg_id: str = ''
|
||||||
target_type: Optional[str] = None
|
target_type: Optional[str] = None
|
||||||
target_id: Optional[str] = None
|
target_id: Optional[str] = None
|
||||||
content: Optional[List[Message]] = None
|
content: Optional[List[Message]] = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user