From 56736354412adeee85045a308ce727ee6a909028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Tue, 11 Oct 2022 13:46:06 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20`quiz`=20=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E5=AF=B9=E7=A7=81=E8=81=8A=E4=BF=A1=E6=81=AF=E4=B8=8D=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E8=87=AA=E5=8A=A8=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/genshin/quiz.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/genshin/quiz.py b/plugins/genshin/quiz.py index 6e4694cc..13598144 100644 --- a/plugins/genshin/quiz.py +++ b/plugins/genshin/quiz.py @@ -8,6 +8,7 @@ from core.admin import BotAdminService from core.baseplugin import BasePlugin from core.plugin import Plugin, handler from core.quiz import QuizService +from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.log import logger from utils.random import MT19937Random @@ -24,13 +25,14 @@ class QuizPlugin(Plugin, BasePlugin): @handler(CommandHandler, command="quiz", block=False) @restricts(restricts_time_of_groups=20) + @error_callable async def command_start(self, update: Update, context: CallbackContext) -> None: user = update.effective_user message = update.effective_message chat = message.chat await message.reply_chat_action(ChatAction.TYPING) question_id_list = await self.quiz_service.get_question_id_list() - if filters.ChatType.GROUPS.filter(update.message): + if filters.ChatType.GROUPS.filter(message): logger.info(f"用户 {user.full_name}[{user.id}] 在群 {chat.title}[{chat.id}] 发送挑战问题命令请求") if len(question_id_list) == 0: return None @@ -58,5 +60,6 @@ class QuizPlugin(Plugin, BasePlugin): open_period=self.time_out, type=Poll.QUIZ, ) - self._add_delete_message_job(context, update.message.chat_id, update.message.message_id, 300) - self._add_delete_message_job(context, poll_message.chat_id, poll_message.message_id, 300) + if filters.ChatType.GROUPS.filter(message): + self._add_delete_message_job(context, update.message.chat_id, update.message.message_id, 300) + self._add_delete_message_job(context, poll_message.chat_id, poll_message.message_id, 300)