update
This commit is contained in:
parent
48eeb0c11a
commit
13794d293f
3 changed files with 27 additions and 2 deletions
|
@ -28,6 +28,21 @@ class MessageSession(MessageSession):
|
|||
else:
|
||||
raise WaitCancelException
|
||||
|
||||
async def waitNextMessage(self, msgchain=None, quote=True, delete=False) -> MessageSession:
|
||||
send = None
|
||||
ExecutionLockList.remove(self)
|
||||
if msgchain is not None:
|
||||
msgchain = MessageChain(msgchain)
|
||||
await self.sendMessage(msgchain, quote)
|
||||
flag = asyncio.Event()
|
||||
MessageTaskManager.add_task(self, flag)
|
||||
await flag.wait()
|
||||
result = MessageTaskManager.get_result(self)
|
||||
if result:
|
||||
return result
|
||||
else:
|
||||
raise WaitCancelException
|
||||
|
||||
async def waitReply(self, msgchain, quote=True) -> MessageSession:
|
||||
ExecutionLockList.remove(self)
|
||||
msgchain = MessageChain(msgchain)
|
||||
|
|
|
@ -124,7 +124,7 @@ class MessageSession:
|
|||
"""
|
||||
await self.sendMessage(msgchain, disable_secret_check=disable_secret_check, quote=False)
|
||||
|
||||
async def waitConfirm(self, msgchain=None, quote=True, delete=True) -> bool:
|
||||
async def waitConfirm(self, msgchain=None, quote=True, delete=True):
|
||||
"""
|
||||
一次性模板,用于等待触发对象确认。
|
||||
:param msgchain: 需要发送的确认消息,可不填
|
||||
|
@ -134,6 +134,16 @@ class MessageSession:
|
|||
"""
|
||||
...
|
||||
|
||||
async def waitNextMessage(self, msgchain=None, quote=True, delete=False):
|
||||
"""
|
||||
一次性模板,用于等待对象的下一条消息。
|
||||
:param msgchain: 需要发送的确认消息,可不填
|
||||
:param quote: 是否引用传入dict中的消息(默认为True)
|
||||
:param delete: 是否在触发后删除消息
|
||||
:return: 若对象发送confirm_command中的其一文本时返回True,反之则返回False
|
||||
"""
|
||||
...
|
||||
|
||||
async def waitReply(self, msgchain, quote=True):
|
||||
"""
|
||||
一次性模板,用于等待触发对象回复消息。
|
||||
|
|
|
@ -151,7 +151,7 @@ async def chemical_code(msg: MessageSession, id=None, captcha_mode=False): #
|
|||
|
||||
await asyncio.gather(ans(msg, csr['name']), timer(time_start)) # 同时启动回答函数和计时器函数
|
||||
else:
|
||||
result = await msg.waitReply([Image(newpath), Plain('请发送正确答案。(请使用字母表顺序,如:CHBrClF)')])
|
||||
result = await msg.waitNextMessage([Image(newpath), Plain('请发送正确答案。(请使用字母表顺序,如:CHBrClF)')])
|
||||
if play_state[msg.target.targetId]['active']: # 检查对象是否为活跃状态
|
||||
if result.asDisplay() == csr['name']:
|
||||
await result.sendMessage('回答正确。')
|
||||
|
|
Reference in a new issue