mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-12 06:55:58 +08:00
🐛 修复循环seq的bug
This commit is contained in:
parent
0f3249ca83
commit
ff9f50ced2
@ -5,8 +5,9 @@ import uuid
|
|||||||
import base64
|
import base64
|
||||||
import asyncio
|
import asyncio
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, List, Union, Optional
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from typing import Any, Dict, List, Union, Optional
|
||||||
|
|
||||||
import websockets.client
|
import websockets.client
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.adapters import Bot
|
from nonebot.adapters import Bot
|
||||||
@ -826,7 +827,9 @@ async def group_send(
|
|||||||
assert isinstance(bot, qqbot)
|
assert isinstance(bot, qqbot)
|
||||||
assert isinstance(target_id, str)
|
assert isinstance(target_id, str)
|
||||||
|
|
||||||
async def _send(text: Optional[str], img: Optional[str], msg_seq: int):
|
async def _send(
|
||||||
|
text: Optional[str], img: Optional[str], mid: Optional[str]
|
||||||
|
):
|
||||||
message = Message()
|
message = Message()
|
||||||
if img:
|
if img:
|
||||||
if img.startswith('link://'):
|
if img.startswith('link://'):
|
||||||
@ -851,6 +854,11 @@ async def group_send(
|
|||||||
if buttons:
|
if buttons:
|
||||||
message.append(MessageSegment.keyboard(_kb(buttons)))
|
message.append(MessageSegment.keyboard(_kb(buttons)))
|
||||||
|
|
||||||
|
if mid is None:
|
||||||
|
msg_seq = None
|
||||||
|
else:
|
||||||
|
msg_seq = msg_id_seq[mid]
|
||||||
|
|
||||||
if target_type == 'group':
|
if target_type == 'group':
|
||||||
await bot.send_to_group(
|
await bot.send_to_group(
|
||||||
group_openid=target_id,
|
group_openid=target_id,
|
||||||
@ -868,7 +876,10 @@ async def group_send(
|
|||||||
msg_seq=msg_seq,
|
msg_seq=msg_seq,
|
||||||
)
|
)
|
||||||
|
|
||||||
msg_id_seq[msg_id] = 1
|
msg_id_seq[mid] += 1
|
||||||
|
|
||||||
|
if msg_id not in msg_id_seq:
|
||||||
|
msg_id_seq[msg_id] = 1
|
||||||
|
|
||||||
if len(msg_id_seq) >= 30:
|
if len(msg_id_seq) >= 30:
|
||||||
oldest_key = next(iter(msg_id_seq))
|
oldest_key = next(iter(msg_id_seq))
|
||||||
@ -877,13 +888,11 @@ async def group_send(
|
|||||||
if node:
|
if node:
|
||||||
for _msg in node:
|
for _msg in node:
|
||||||
if _msg['type'] == 'image':
|
if _msg['type'] == 'image':
|
||||||
await _send(None, _msg['data'], msg_id_seq[msg_id])
|
await _send(None, _msg['data'], msg_id)
|
||||||
msg_id_seq[msg_id] += 1
|
|
||||||
elif _msg['type'] == 'text':
|
elif _msg['type'] == 'text':
|
||||||
await _send(_msg['data'], None, msg_id_seq[msg_id])
|
await _send(_msg['data'], None, msg_id)
|
||||||
msg_id_seq[msg_id] += 1
|
|
||||||
else:
|
else:
|
||||||
await _send(content, image, msg_id_seq[msg_id])
|
await _send(content, image, msg_id)
|
||||||
|
|
||||||
|
|
||||||
async def ntchat_send(
|
async def ntchat_send(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user