diff --git a/core/bots/aiogram/bot.py b/core/bots/aiogram/bot.py index a1ee8f9a..fda3ab6a 100644 --- a/core/bots/aiogram/bot.py +++ b/core/bots/aiogram/bot.py @@ -14,15 +14,11 @@ from core.bots.aiogram.tasks import MessageTaskManager, FinishedTasks async def msg_handler(message: types.Message): all_tsk = MessageTaskManager.get() user_id = message.from_user.id - print(all_tsk) - print(user_id) if user_id in all_tsk: - if message.text in confirm_command: - FinishedTasks.add_task(user_id, True) - else: - FinishedTasks.add_task(user_id, False) + FinishedTasks.add_task(user_id, message) all_tsk[user_id].set() MessageTaskManager.del_task(user_id) + return msg = MessageSession(MsgInfo(targetId=f'Telegram|{message.chat.type}|{message.chat.id}', senderId=f'Telegram|User|{message.from_user.id}', targetFrom='Telegram', senderFrom='Telegram', senderName=message.from_user.username), @@ -30,4 +26,4 @@ async def msg_handler(message: types.Message): await parser(msg) if dp: - executor.start_polling(dp, skip_updates=True) \ No newline at end of file + executor.start_polling(dp, skip_updates=True) diff --git a/core/bots/aiogram/message.py b/core/bots/aiogram/message.py index 6c2bae7e..9d6544ee 100644 --- a/core/bots/aiogram/message.py +++ b/core/bots/aiogram/message.py @@ -16,7 +16,7 @@ class MessageSession(MS): async def sendMessage(self, msgchain, quote=True): if isinstance(msgchain, str): - send = await self.session.message.answer(msgchain, reply=True if quote else False) + send = await self.session.message.answer(msgchain, reply=quote) return MessageSession(target=MsgInfo(targetId=0, senderId=0, senderName='', targetFrom='Telegram|Bot', senderFrom='Telegram|Bot'), session=Session(message=send, target=send.chat.id, sender=send.from_user.id)) @@ -25,12 +25,12 @@ class MessageSession(MS): send_list = [] for x in msgchain: if isinstance(x, Plain): - send = await self.session.message.answer(x.text) + send = await self.session.message.answer(x.text, reply=quote) send_list.append(send) count += 1 if isinstance(x, Image): with open(await x.get(), 'rb') as image: - send = await self.session.message.reply_photo(image) + send = await self.session.message.reply_photo(image, reply=quote) send_list.append(send) count += 1 return MessageSession(target=MsgInfo(targetId=0, senderId=0, senderName='', targetFrom='Telegram|Bot', @@ -41,7 +41,9 @@ class MessageSession(MS): flag = asyncio.Event() MessageTaskManager.add_task(self.session.sender.id, flag) await flag.wait() - return FinishedTasks.get()[self.session.sender.id] + if FinishedTasks.get()[self.session.sender.id].text in confirm_command: + return True + return False async def checkPermission(self): diff --git a/core/bots/aiogram/tasks.py b/core/bots/aiogram/tasks.py index 441433c7..29642d44 100644 --- a/core/bots/aiogram/tasks.py +++ b/core/bots/aiogram/tasks.py @@ -18,7 +18,7 @@ class FinishedTasks: _list = {} @staticmethod - def add_task(uid, result: bool): + def add_task(uid, result): FinishedTasks._list.update({uid: result}) @staticmethod