refactor code

This commit is contained in:
hibiki
2021-07-30 21:21:51 +08:00
parent 2ad891aa1e
commit cc24822dca
165 changed files with 7815 additions and 8174 deletions
@@ -1,19 +1,17 @@
from .qiu_translation import qiu_qiu_word_translation, qiu_qiu_phrase_translation
from nonebot.adapters.cqhttp import Bot, MessageEvent
from nonebot.adapters.cqhttp import Bot, MessageEvent, GroupMessageEvent
from nonebot.typing import T_State
from nonebot import on_command
from utils.utils import get_message_text
from services.log import logger
__plugin_name__ = '丘丘语翻译'
__plugin_name__ = "丘丘语翻译"
__plugin_usage__ = '用法:丘丘翻译 [消息]'
__plugin_usage__ = "用法:丘丘翻译 [消息]"
qiuqiu = on_command("丘丘语翻译", aliases={"丘丘一下", "丘丘翻译"}, priority=5, block=True)
suffix = "\n※ 只能从丘丘语翻译为中文,不能反向翻译\n" \
"※ 注意空格,不要加入任何标点符号\n" \
"※ 翻译数据来源于 米游社论坛"
suffix = "\n※ 只能从丘丘语翻译为中文,不能反向翻译\n" "※ 注意空格,不要加入任何标点符号\n" "※ 翻译数据来源于 米游社论坛"
@qiuqiu.handle()
@@ -28,13 +26,6 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
# print(mes)
await qiuqiu.send(mes, at_sender=True)
logger.info(
f"(USER {event.user_id}, GROUP {event.group_id if event.message_type != 'private' else 'private'})"
f" 发送丘丘翻译:" + txt)
f"(USER {event.user_id}, GROUP {event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
f" 发送丘丘翻译:" + txt
)
@@ -6,7 +6,9 @@ FILE_PATH = os.path.dirname(__file__)
QIU_QIU_WORD = {}
QIU_QIU_PHRASE = {}
with open(os.path.join(FILE_PATH, 'qiu_qiu_dictionary.json'), 'r', encoding='UTF-8') as f:
with open(
os.path.join(FILE_PATH, "qiu_qiu_dictionary.json"), "r", encoding="UTF-8"
) as f:
data = json.load(f)
QIU_QIU_WORD = data["word"]
QIU_QIU_PHRASE = data["phrase"]