From 10f6e3ae1d09944e9d7617abd077726d7062ae68 Mon Sep 17 00:00:00 2001 From: Li Chuangbo Date: Fri, 9 Sep 2022 14:09:11 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E6=B2=A1=E6=9C=89=20`quiz`=20=E6=97=B6?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E6=8A=A5=E9=94=99=20`wrong=20number=20of=20a?= =?UTF-8?q?rguments=20for=20'lpush'=20command`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` 在安装插件 "plugins.system.auth.GroupJoiningVerification" 的过程中遇到了错误 ResponseError: wrong number of arguments for 'lpush' command ``` 因为 Redis lpush 需要至少一个参数。 --- core/quiz/cache.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/quiz/cache.py b/core/quiz/cache.py index e4cddf1..61cd209 100644 --- a/core/quiz/cache.py +++ b/core/quiz/cache.py @@ -39,7 +39,9 @@ class QuizCache: json_data = str(data, encoding="utf-8") return Answer.de_json(ujson.loads(json_data)) - async def add_question(self, question_list: List[Question] = None): + async def add_question(self, question_list: List[Question] = None) -> int: + if not question_list: + return 0 for question in question_list: await self.client.set(f"{self.question_qname}:{question.question_id}", ujson.dumps(question.to_dict())) question_id_list = [question.question_id for question in question_list] @@ -58,7 +60,9 @@ class QuizCache: for key in keys: await self.client.delete(key) - async def add_answer(self, answer_list: List[Answer] = None): + async def add_answer(self, answer_list: List[Answer] = None) -> int: + if not answer_list: + return 0 for answer in answer_list: await self.client.set(f"{self.answer_qname}:{answer.answer_id}", ujson.dumps(answer.to_dict())) answer_id_list = [answer.answer_id for answer in answer_list]