mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-05-12 06:55:49 +08:00
🐛 修复BUG, 添加依赖
This commit is contained in:
parent
f530ecc29c
commit
dca0704890
@ -88,6 +88,7 @@ class Bot:
|
||||
self.bot_id = ev.bot_id
|
||||
self.bot_self_id = ev.bot_self_id
|
||||
self.resp: List[Event] = []
|
||||
self.receive_tag = False
|
||||
self.mutiply_tag = False
|
||||
self.mutiply_resp: List[Event] = []
|
||||
|
||||
@ -105,7 +106,7 @@ class Bot:
|
||||
|
||||
async def wait_for_key(self, timeout: float) -> Optional[Event]:
|
||||
await asyncio.wait_for(self.event.wait(), timeout=timeout)
|
||||
|
||||
self.receive_tag = False
|
||||
if self.resp:
|
||||
reply = self.resp[-1]
|
||||
self.resp.clear()
|
||||
@ -224,20 +225,22 @@ class Bot:
|
||||
|
||||
if is_mutiply:
|
||||
# 标注uuid
|
||||
self.mutiply_tag = True
|
||||
if self.uuid not in self.mutiply_instances:
|
||||
self.mutiply_instances[self.uuid] = self
|
||||
# 标注群
|
||||
if self.gid not in self.mutiply_map:
|
||||
self.mutiply_map[self.gid] = self.uuid
|
||||
self.mutiply_tag = True
|
||||
self.mutiply_event = asyncio.Event()
|
||||
|
||||
while self.mutiply_resp == []:
|
||||
await asyncio.wait_for(self.mutiply_event.wait(), timeout)
|
||||
|
||||
self.mutiply_tag = False
|
||||
self.mutiply_event = asyncio.Event()
|
||||
return self.mutiply_resp.pop(0)
|
||||
elif is_recive:
|
||||
self.receive_tag = True
|
||||
self.instances[self.uuid] = self
|
||||
self.event = asyncio.Event()
|
||||
return await self.wait_for_key(timeout)
|
||||
|
@ -42,12 +42,13 @@ class GsClient:
|
||||
intent = await self._input()
|
||||
content = Message(type='text', data=intent)
|
||||
group_id = random.choice(['555', '666', '777'])
|
||||
user_id = random.choice(['1', '2'])
|
||||
msg = MessageReceive(
|
||||
bot_id='console',
|
||||
user_type='group',
|
||||
user_pm=0,
|
||||
group_id=group_id,
|
||||
user_id='511',
|
||||
user_id=user_id,
|
||||
content=[content],
|
||||
)
|
||||
msg_send = msgjson.encode(msg)
|
||||
|
@ -184,6 +184,7 @@ def main():
|
||||
await asyncio.sleep(180)
|
||||
image_path.unlink()
|
||||
|
||||
@app.head('/genshinuid/image/{image_id}.jpg')
|
||||
@app.get('/genshinuid/image/{image_id}.jpg')
|
||||
async def get_image(image_id: str, background_tasks: BackgroundTasks):
|
||||
path = image_res / f'{image_id}.jpg'
|
||||
|
@ -83,21 +83,22 @@ async def handle_event(ws: _Bot, msg: MessageReceive):
|
||||
mutiply_instances = Bot.get_mutiply_instances()
|
||||
mutiply_map = Bot.get_mutiply_map()
|
||||
|
||||
if uuid in instances and instances[uuid].receive_tag:
|
||||
instances[uuid].resp.append(event)
|
||||
instances[uuid].set_event()
|
||||
return
|
||||
|
||||
if (
|
||||
gid in mutiply_map
|
||||
and event.user_type != 'direct'
|
||||
and mutiply_map[gid] in mutiply_instances
|
||||
and mutiply_instances[mutiply_map[gid]].mutiply_tag
|
||||
):
|
||||
mutiply_instances[mutiply_map[gid]].mutiply_resp.append(event)
|
||||
mutiply_instances[mutiply_map[gid]].set_mutiply_event()
|
||||
if uuid == mutiply_instances[mutiply_map[gid]].uuid:
|
||||
return
|
||||
|
||||
if uuid in instances:
|
||||
instances[uuid].resp.append(event)
|
||||
instances[uuid].set_event()
|
||||
return
|
||||
|
||||
is_start = False
|
||||
if command_start and event.raw_text:
|
||||
for start in command_start:
|
||||
|
@ -41,9 +41,10 @@ async def get_time_limit_resp_msg(bot: Bot, ev: Event):
|
||||
try:
|
||||
async with timeout(60): # 限制时长60秒
|
||||
while True:
|
||||
resp = await bot.receive_mutiply_resp()
|
||||
resp = await bot.receive_mutiply_resp('输入文字!')
|
||||
if resp is not None:
|
||||
await bot.send(f'你说的是 {resp.text} 吧?')
|
||||
await asyncio.sleep(3)
|
||||
except asyncio.TimeoutError:
|
||||
await bot.send('时间到!!现在开始计算每个人的分数...')
|
||||
|
||||
@ -53,12 +54,13 @@ async def get_resp_msg(bot: Bot, ev: Event):
|
||||
await bot.send('正在进行[开始游戏测试]')
|
||||
await asyncio.sleep(2)
|
||||
await bot.send('[开始游戏测试]校验成功!')
|
||||
resp = await bot.receive_resp(
|
||||
'请选择一个选项!',
|
||||
['🎨可爱的丛林', '🚀遥远的星空', '📝不如在家写作业', '✨或者看星星', '🚧这里是维护选项'],
|
||||
)
|
||||
if resp is not None:
|
||||
await bot.send(f'你输入的是{resp.text}')
|
||||
while True:
|
||||
resp = await bot.receive_resp(
|
||||
'请选择一个选项!',
|
||||
['🎨可爱的丛林', '🚀遥远的星空', '📝不如在家写作业', '✨或者看星星', '🚧这里是维护选项'],
|
||||
)
|
||||
if resp is not None:
|
||||
await bot.send(f'你输入的是{resp.text}')
|
||||
|
||||
|
||||
@sv_switch.on_prefix('前缀测试')
|
||||
|
@ -42,6 +42,9 @@ if IS_UPLOAD:
|
||||
pclient = S3()
|
||||
|
||||
|
||||
URL_MAP = {}
|
||||
|
||||
|
||||
class MessageSegment:
|
||||
def __add__(self, other):
|
||||
return [self, other]
|
||||
@ -255,8 +258,13 @@ async def _convert_message_to_image(
|
||||
image_bytes = b64decode(img[9:])
|
||||
elif isinstance(img, str) and img.startswith('link://'):
|
||||
if send_type == 'base64':
|
||||
resp = await sget(img.replace('link://', ''))
|
||||
image_b64 = b64encode(resp.content).decode('utf-8')
|
||||
url = img.replace('link://', '')
|
||||
if url in URL_MAP:
|
||||
image_b64 = URL_MAP[url]
|
||||
else:
|
||||
resp = await sget(url)
|
||||
image_b64 = b64encode(resp.content).decode('utf-8')
|
||||
URL_MAP[url] = image_b64
|
||||
return [Message(type='image', data=image_b64)]
|
||||
else:
|
||||
return [Message(type='image', data=img)]
|
||||
|
@ -129,7 +129,7 @@ class SV:
|
||||
|
||||
if name == '测试开关':
|
||||
self.pm = 6
|
||||
self.enabled = False
|
||||
self.enabled = True
|
||||
|
||||
def set(self, **kwargs):
|
||||
for var in kwargs:
|
||||
|
Loading…
x
Reference in New Issue
Block a user