mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-16 12:51:35 +00:00
Remove unnecessary f-string
This commit is contained in:
parent
026903208b
commit
34688cd914
@ -64,7 +64,7 @@ class Admin(BasePlugins):
|
||||
await message.reply_text("输入错误")
|
||||
return
|
||||
except ValueError as error:
|
||||
Log.error(f"获取 char_id 发生错误! 错误信息为 \n", error)
|
||||
Log.error("获取 char_id 发生错误! 错误信息为 \n", error)
|
||||
await message.reply_text("输入错误")
|
||||
return
|
||||
try:
|
||||
|
@ -93,7 +93,7 @@ class Auth:
|
||||
chat_id=chat.id,
|
||||
extra_user=[]
|
||||
):
|
||||
await callback_query.answer(text=f"你不是管理!\n"
|
||||
await callback_query.answer(text="你不是管理!\n"
|
||||
f"再瞎几把点我叫西风骑士团、千岩军和天领奉行了!", show_alert=True)
|
||||
return
|
||||
result, user_id = await admin_callback(callback_query.data)
|
||||
@ -141,7 +141,7 @@ class Auth:
|
||||
user_id, result, question, answer = await query_callback(callback_query.data)
|
||||
Log.info(f"用户 {user.full_name}[{user.id}] 在群 {chat.title}[{chat.id}] 点击Auth认证命令 ")
|
||||
if user.id != user_id:
|
||||
await callback_query.answer(text=f"这不是你的验证!\n"
|
||||
await callback_query.answer(text="这不是你的验证!\n"
|
||||
f"再瞎几把点再按我叫西风骑士团、千岩军和天领奉行了!", show_alert=True)
|
||||
return
|
||||
Log.info(f"用户 {user.full_name}[{user.id}] 在群 {chat.title}[{chat.id}] 认证结果为 {'通过' if result else '失败'}")
|
||||
@ -200,7 +200,7 @@ class Auth:
|
||||
raise err
|
||||
question_id_list = await self.service.quiz_service.get_question_id_list()
|
||||
if len(question_id_list) == 0:
|
||||
await message.reply_text(f"旅行者!!!派蒙的问题清单你还没给我!!快去私聊我给我问题!")
|
||||
await message.reply_text("旅行者!!!派蒙的问题清单你还没给我!!快去私聊我给我问题!")
|
||||
return
|
||||
index = self.random(0, len(question_id_list))
|
||||
question = await self.service.quiz_service.get_question(question_id_list[index])
|
||||
|
@ -62,7 +62,7 @@ async def error_handler(update: object, context: CallbackContext) -> None:
|
||||
await context.bot.send_message(notice_chat_id, text, parse_mode=ParseMode.HTML)
|
||||
except BadRequest:
|
||||
text = (
|
||||
f'<b>处理函数时发生异常,traceback太长导致无法发送,但已写入日志</b> \n')
|
||||
'<b>处理函数时发生异常,traceback太长导致无法发送,但已写入日志</b> \n')
|
||||
try:
|
||||
await context.bot.send_message(notice_chat_id, text, parse_mode=ParseMode.HTML)
|
||||
except BadRequest as exc:
|
||||
|
@ -137,7 +137,7 @@ class GetUser(BasePlugins):
|
||||
if len(args) >= 2:
|
||||
uid = int(args[1])
|
||||
except ValueError as error:
|
||||
Log.error(f"获取 char_id 发生错误! 错误信息为 \n", error)
|
||||
Log.error("获取 char_id 发生错误! 错误信息为 \n", error)
|
||||
await message.reply_text("输入错误")
|
||||
return ConversationHandler.END
|
||||
if user_info.service == ServiceEnum.NULL:
|
||||
|
@ -66,7 +66,7 @@ class Inline:
|
||||
InlineQueryResultArticle(
|
||||
id=str(uuid4()),
|
||||
title="警告!问题数量过度可能无法完全展示",
|
||||
description=f"请在命令后添加空格输入要搜索的题目即可指定搜索",
|
||||
description="请在命令后添加空格输入要搜索的题目即可指定搜索",
|
||||
input_message_content=InputTextMessageContent("警告!问题数量过度可能无法完全展示\n"
|
||||
"请在命令后添加空格输入要搜索的题目即可指定搜索")
|
||||
))
|
||||
@ -115,8 +115,8 @@ class Inline:
|
||||
results_list.append(
|
||||
InlineQueryResultArticle(
|
||||
id=str(uuid4()),
|
||||
title=f"好像找不到问题呢",
|
||||
description=f"这个问题我也不知道,因为我就是个应急食品。",
|
||||
title="好像找不到问题呢",
|
||||
description="这个问题我也不知道,因为我就是个应急食品。",
|
||||
input_message_content=InputTextMessageContent("这个问题我也不知道,因为我就是个应急食品。"),
|
||||
))
|
||||
try:
|
||||
|
@ -55,7 +55,7 @@ class Post(BasePlugins):
|
||||
|
||||
post_id = self.bbs.extract_post_id(update.message.text)
|
||||
if post_id == -1:
|
||||
await message.reply_text(f"获取作品ID错误,请检查连接是否合法", reply_markup=ReplyKeyboardRemove())
|
||||
await message.reply_text("获取作品ID错误,请检查连接是否合法", reply_markup=ReplyKeyboardRemove())
|
||||
return ConversationHandler.END
|
||||
post_full_info = await self.bbs.get_post_full_info(2, post_id)
|
||||
post_images = await self.bbs.get_images_by_post_id(2, post_id)
|
||||
|
@ -50,7 +50,7 @@ class Quiz(BasePlugins):
|
||||
if filters.ChatType.GROUPS.filter(update.message):
|
||||
Log.info(f"用户 {user.full_name}[{user.id}] 在群 {chat.title}[{chat.id}] 发送挑战问题命令请求")
|
||||
if len(question_id_list) == 0:
|
||||
await update.message.reply_text(f"旅行者!!!派蒙的问题清单你还没给我!!快去私聊我给我问题!")
|
||||
await update.message.reply_text("旅行者!!!派蒙的问题清单你还没给我!!快去私聊我给我问题!")
|
||||
if len(question_id_list) == 0:
|
||||
return None
|
||||
index = self.random(0, len(question_id_list))
|
||||
|
@ -57,7 +57,7 @@ class RedisCache:
|
||||
await self.rdb.set(qname + f":{question.question_id}", json_dumps(question))
|
||||
|
||||
question_id_list = [question.question_id for question in question_list]
|
||||
await self.rdb.lpush(qname + f":id_list", *question_id_list)
|
||||
await self.rdb.lpush(qname + ":id_list", *question_id_list)
|
||||
return await self.rdb.llen(qname + ":id_list")
|
||||
|
||||
async def del_all_question(self, answer_list: List[AnswerData] = None):
|
||||
|
@ -56,13 +56,13 @@ class AsyncRepository:
|
||||
|
||||
async def update_cookie(self, user_id: int, cookie: str, service: ServiceEnum):
|
||||
if service == ServiceEnum.MIHOYOBBS:
|
||||
query = f"""
|
||||
query = """
|
||||
UPDATE `mihoyo_cookie`
|
||||
SET cookie=%s
|
||||
WHERE user_id=%s;
|
||||
"""
|
||||
elif service == ServiceEnum.HOYOLAB:
|
||||
query = f"""
|
||||
query = """
|
||||
UPDATE `hoyoverse_cookie`
|
||||
SET cookie=%s
|
||||
WHERE user_id=%s;
|
||||
@ -74,7 +74,7 @@ class AsyncRepository:
|
||||
|
||||
async def set_cookie(self, user_id: int, cookie: str, service: ServiceEnum):
|
||||
if service == ServiceEnum.MIHOYOBBS:
|
||||
query = f"""
|
||||
query = """
|
||||
INSERT INTO `mihoyo_cookie`
|
||||
(user_id,cookie)
|
||||
VALUES
|
||||
@ -83,7 +83,7 @@ class AsyncRepository:
|
||||
cookie=VALUES(cookie);
|
||||
"""
|
||||
elif service == ServiceEnum.HOYOLAB:
|
||||
query = f"""
|
||||
query = """
|
||||
INSERT INTO `hoyoverse_cookie`
|
||||
(user_id,cookie)
|
||||
VALUES
|
||||
@ -97,7 +97,7 @@ class AsyncRepository:
|
||||
await self._execute_and_fetchall(query, query_args)
|
||||
|
||||
async def set_user_info(self, user_id: int, mihoyo_game_uid: int, hoyoverse_game_uid: int, service: int):
|
||||
query = f"""
|
||||
query = """
|
||||
INSERT INTO `user`
|
||||
(user_id,mihoyo_game_uid,hoyoverse_game_uid,service)
|
||||
VALUES
|
||||
@ -111,7 +111,7 @@ class AsyncRepository:
|
||||
await self._execute_and_fetchall(query, query_args)
|
||||
|
||||
async def read_mihoyo_cookie(self, user_id) -> dict:
|
||||
query = f"""
|
||||
query = """
|
||||
SELECT cookie
|
||||
FROM `mihoyo_cookie`
|
||||
WHERE user_id=%s;
|
||||
@ -123,7 +123,7 @@ class AsyncRepository:
|
||||
return CreatCookieDictFromSQLData(data[0])
|
||||
|
||||
async def read_hoyoverse_cookie(self, user_id) -> dict:
|
||||
query = f"""
|
||||
query = """
|
||||
SELECT cookie
|
||||
FROM `hoyoverse_cookie`
|
||||
WHERE user_id=%s;
|
||||
@ -135,7 +135,7 @@ class AsyncRepository:
|
||||
return CreatCookieDictFromSQLData(data[0])
|
||||
|
||||
async def read_user_info(self, user_id) -> UserInfoData:
|
||||
query = f"""
|
||||
query = """
|
||||
SELECT user_id,mihoyo_game_uid,hoyoverse_game_uid,service
|
||||
FROM `user`
|
||||
WHERE user_id=%s;
|
||||
@ -147,7 +147,7 @@ class AsyncRepository:
|
||||
return CreateUserInfoDBDataFromSQLData(data[0])
|
||||
|
||||
async def read_question_list(self) -> List[QuestionData]:
|
||||
query = f"""
|
||||
query = """
|
||||
SELECT id,question
|
||||
FROM `question`
|
||||
"""
|
||||
@ -156,7 +156,7 @@ class AsyncRepository:
|
||||
return CreatQuestionFromSQLData(data)
|
||||
|
||||
async def read_answer_form_question_id(self, question_id: int) -> List[AnswerData]:
|
||||
query = f"""
|
||||
query = """
|
||||
SELECT id,question_id,is_correct,answer
|
||||
FROM `answer`
|
||||
WHERE question_id=%s;
|
||||
@ -166,7 +166,7 @@ class AsyncRepository:
|
||||
return CreatAnswerFromSQLData(data)
|
||||
|
||||
async def save_question(self, question: str):
|
||||
query = f"""
|
||||
query = """
|
||||
INSERT INTO `question`
|
||||
(question)
|
||||
VALUES
|
||||
@ -176,7 +176,7 @@ class AsyncRepository:
|
||||
await self._execute_and_fetchall(query, query_args)
|
||||
|
||||
async def read_question(self, question: str) -> QuestionData:
|
||||
query = f"""
|
||||
query = """
|
||||
SELECT id,question
|
||||
FROM `question`
|
||||
WHERE question=%s;
|
||||
@ -186,7 +186,7 @@ class AsyncRepository:
|
||||
return CreatQuestionFromSQLData(data)[0]
|
||||
|
||||
async def save_answer(self, question_id: int, is_correct: int, answer: str):
|
||||
query = f"""
|
||||
query = """
|
||||
INSERT INTO `answer`
|
||||
(question_id,is_correct,answer)
|
||||
VALUES
|
||||
@ -196,7 +196,7 @@ class AsyncRepository:
|
||||
await self._execute_and_fetchall(query, query_args)
|
||||
|
||||
async def delete_question(self, question_id: int):
|
||||
query = f"""
|
||||
query = """
|
||||
DELETE FROM `question`
|
||||
WHERE id=%s;
|
||||
"""
|
||||
@ -204,7 +204,7 @@ class AsyncRepository:
|
||||
await self._execute_and_fetchall(query, query_args)
|
||||
|
||||
async def delete_answer(self, answer_id: int):
|
||||
query = f"""
|
||||
query = """
|
||||
DELETE FROM `answer`
|
||||
WHERE id=%s;
|
||||
"""
|
||||
@ -212,7 +212,7 @@ class AsyncRepository:
|
||||
await self._execute_and_fetchall(query, query_args)
|
||||
|
||||
async def delete_admin(self, user_id: int):
|
||||
query = f"""
|
||||
query = """
|
||||
DELETE FROM `admin`
|
||||
WHERE user_id=%s;
|
||||
"""
|
||||
@ -220,7 +220,7 @@ class AsyncRepository:
|
||||
await self._execute_and_fetchall(query, query_args)
|
||||
|
||||
async def add_admin(self, user_id: int):
|
||||
query = f"""
|
||||
query = """
|
||||
INSERT INTO `admin`
|
||||
(user_id)
|
||||
VALUES
|
||||
@ -230,7 +230,7 @@ class AsyncRepository:
|
||||
await self._execute_and_fetchall(query, query_args)
|
||||
|
||||
async def get_admin(self) -> List[int]:
|
||||
query = f"""
|
||||
query = """
|
||||
SELECT user_id
|
||||
FROM `admin`
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user