diff --git a/src/constant/jx3/skilldatalib.py b/src/constant/jx3/skilldatalib.py index b83ddd88a..2f052a50f 100644 --- a/src/constant/jx3/skilldatalib.py +++ b/src/constant/jx3/skilldatalib.py @@ -3,8 +3,8 @@ from nonebot.adapters.onebot.v11 import MessageSegment as ms -from src.tools.utils import get_url, get_status, get_content -from src.tools.file import read, write +from src.tools.utils.request import get_url, get_status, get_content +from src.tools.utils.file import read, write from src.tools.utils.path import CONSTANT, ASSETS import json diff --git a/src/plugins/ban/__init__.py b/src/plugins/ban/__init__.py index 1c83daa23..170e12f2d 100644 --- a/src/plugins/ban/__init__.py +++ b/src/plugins/ban/__init__.py @@ -7,10 +7,10 @@ from nonebot.params import CommandArg, Arg from src.tools.config import Config -from src.tools.utils import checknumber +from src.tools.utils.num import checknumber from src.tools.permission import checker, error -from src.tools.data import group_db, BannedList, GroupSettings -from src.tools.basic.message_process import preprocess +from src.tools.database import group_db, BannedList, GroupSettings +from src.tools.basic.process import preprocess leave_msg = f"{Config.bot_basic.bot_name}要离开这里啦,{Config.bot_basic.bot_name}还没有学会人类的告别语,但是数据库中有一句话似乎很适合现在使用——如果还想来找我的话,我一直在这里(650495414)。" diff --git a/src/plugins/banword/__init__.py b/src/plugins/banword/__init__.py index d33c7de0b..0dda43fa1 100644 --- a/src/plugins/banword/__init__.py +++ b/src/plugins/banword/__init__.py @@ -6,7 +6,7 @@ from nonebot.params import CommandArg from src.tools.permission import checker, error -from src.tools.data import group_db, BannedWordList +from src.tools.database import group_db, BannedWordList banword = on_command("banword", force_whitespace=True, priority=5) diff --git a/src/plugins/blacklist/__init__.py b/src/plugins/blacklist/__init__.py index fbf08a820..deb64ce76 100644 --- a/src/plugins/blacklist/__init__.py +++ b/src/plugins/blacklist/__init__.py @@ -7,8 +7,8 @@ from nonebot.params import CommandArg from src.tools.permission import checker -from src.tools.data import group_db, GroupSettings -from src.tools.utils import read, write +from src.tools.database import group_db, GroupSettings +from src.tools.utils.file import read, write from src.tools.utils.path import ASSETS, CACHE, VIEWS from src.tools.generate import get_uuid, generate diff --git a/src/plugins/developer_tools/application.py b/src/plugins/developer_tools/application.py index 6153e3e77..c88cde397 100644 --- a/src/plugins/developer_tools/application.py +++ b/src/plugins/developer_tools/application.py @@ -6,8 +6,9 @@ from nonebot.adapters import Message from src.tools.permission import checker, error -from src.tools.data import group_db, ApplicationsList -from src.tools.utils.common import convert_time, checknumber +from src.tools.database import group_db, ApplicationsList +from src.tools.utils.time import convert_time +from src.tools.utils.num import checknumber current_application = on_command("邀请列表", force_whitespace=True, priority=5) diff --git a/src/plugins/developer_tools/classic.py b/src/plugins/developer_tools/classic.py index b25791647..453d5d800 100644 --- a/src/plugins/developer_tools/classic.py +++ b/src/plugins/developer_tools/classic.py @@ -3,10 +3,11 @@ from nonebot.params import CommandArg from nonebot.adapters import Message -from src.tools.utils.common import convert_time, getCurrentTime, checknumber +from src.tools.utils.time import convert_time, get_current_time +from src.tools.utils.num import checknumber from src.tools.permission import checker, error from src.tools.utils.path import CACHE -from src.tools.basic.group_opeator import getAllGroups +from src.tools.basic.group import getAllGroups from src.tools.config import Config import os @@ -47,7 +48,7 @@ async def _(bot: Bot, event: MessageEvent, args: Message = CommandArg()): return permission = checker(str(event.user_id), 1) if not permission: - await ping.finish(f"咕咕咕,音卡来啦!\n当前时间为:{convert_time(getCurrentTime())}\n欢迎使用Inkar-Suki!") + await ping.finish(f"咕咕咕,音卡来啦!\n当前时间为:{convert_time(get_current_time())}\n欢迎使用Inkar-Suki!") else: groups = await bot.call_api("get_group_list") group_count = len(groups) @@ -57,7 +58,7 @@ async def _(bot: Bot, event: MessageEvent, args: Message = CommandArg()): if not isinstance(registers, list): return register_count = len(registers) - msg = f"咕咕咕,音卡来啦!\n现在是:{convert_time(getCurrentTime())}\n{group_count} | {register_count} | {friend_count}\n您拥有机器人的管理员权限!" + msg = f"咕咕咕,音卡来啦!\n现在是:{convert_time(get_current_time())}\n{group_count} | {register_count} | {friend_count}\n您拥有机器人的管理员权限!" await ping.finish(msg) post = on_command("post", force_whitespace=True, priority=5) # 发送全域公告至每一个机器人加入的QQ群。 diff --git a/src/plugins/developer_tools/feedback.py b/src/plugins/developer_tools/feedback.py index e2bd65ac0..34822c76e 100644 --- a/src/plugins/developer_tools/feedback.py +++ b/src/plugins/developer_tools/feedback.py @@ -6,10 +6,10 @@ from nonebot.adapters import Message from src.tools.config import Config -from src.tools.utils.common import convert_time, getCurrentTime +from src.tools.utils.time import convert_time, get_current_time from src.tools.utils.request import post_url from src.tools.permission import checker, error -from src.tools.data import group_db, Population +from src.tools.database import group_db, Population from .stastic import generate_bar_chart @@ -17,7 +17,7 @@ async def createIssue(uin: str, comment: str): title = "【反馈】Inkar Suki · 使用反馈" - date = convert_time(getCurrentTime()) + date = convert_time(get_current_time()) msg = f"日期:{date}\n用户:{uin}\n留言:{comment}" url = f"https://api.github.com/repos/{Config.bot_basic.bot_repo}/issues" headers = { diff --git a/src/plugins/event_notice/__init__.py b/src/plugins/event_notice/__init__.py index f9224a1ff..c3a235749 100644 --- a/src/plugins/event_notice/__init__.py +++ b/src/plugins/event_notice/__init__.py @@ -16,8 +16,8 @@ from src.tools.config import Config from src.tools.permission import checker, error -from src.tools.data import group_db, BannedList, ApplicationsList, GroupSettings -from src.tools.basic.group_opeator import getGroupSettings, setGroupSettings +from src.tools.database import group_db, BannedList, ApplicationsList, GroupSettings +from src.tools.basic.group import getGroupSettings, setGroupSettings from src.plugins.ban import banned diff --git a/src/plugins/github/__init__.py b/src/plugins/github/__init__.py index 321450b5c..3e476a9cb 100644 --- a/src/plugins/github/__init__.py +++ b/src/plugins/github/__init__.py @@ -10,8 +10,8 @@ from src.tools.config import Config from src.tools.utils.request import get_status, get_content from src.tools.permission import checker, error -from src.tools.data import group_db, GroupSettings -from src.tools.basic.group_opeator import getGroupSettings, setGroupSettings, getAllGroups +from src.tools.database import group_db, GroupSettings +from src.tools.basic.group import getGroupSettings, setGroupSettings, getAllGroups import nonebot diff --git a/src/plugins/grab/bmi.py b/src/plugins/grab/bmi.py index 32e436360..fae3b2235 100644 --- a/src/plugins/grab/bmi.py +++ b/src/plugins/grab/bmi.py @@ -3,7 +3,7 @@ from nonebot.adapters import Message from nonebot.params import CommandArg -from src.tools.utils.common import checknumber +from src.tools.utils.num import checknumber bmi = on_command("bmi", aliases={"BMI", "身体质量指数"}, force_whitespace=True, priority=5) diff --git a/src/plugins/grab/check_pass.py b/src/plugins/grab/check_pass.py index 1731ed0fc..4d7aecc1e 100644 --- a/src/plugins/grab/check_pass.py +++ b/src/plugins/grab/check_pass.py @@ -1,7 +1,7 @@ from typing import Tuple from nonebot import get_driver -from src.tools.utils.common import getCurrentTime +from src.tools.utils.time import get_current_time from .config import Config as eat_Config @@ -12,7 +12,7 @@ def check_cd(last_time: int) -> Tuple[bool, int, int]: # 检查cd - current_time = getCurrentTime() + current_time = get_current_time() delta_time = current_time - last_time if not isinstance(cd, int): return True, 0, current_time diff --git a/src/plugins/grab/rdimg.py b/src/plugins/grab/rdimg.py index 2464bc6da..187d560ac 100644 --- a/src/plugins/grab/rdimg.py +++ b/src/plugins/grab/rdimg.py @@ -6,7 +6,7 @@ from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment as ms from src.tools.utils.request import get_content, get_api -from src.tools.file import get_content_local +from src.tools.utils.file import get_content_local from src.tools.utils.path import PLUGINS import random diff --git a/src/plugins/jx3/achievement/__init__.py b/src/plugins/jx3/achievement/__init__.py index 102dc6f70..5213c6874 100644 --- a/src/plugins/jx3/achievement/__init__.py +++ b/src/plugins/jx3/achievement/__init__.py @@ -4,10 +4,10 @@ from nonebot.params import CommandArg, Arg from nonebot.typing import T_State -from src.tools.basic.msg import PROMPT -from src.tools.utils.common import checknumber -from src.tools.file import get_content_local -from src.tools.basic.data_server import getGroupServer +from src.tools.basic.prompts import PROMPT +from src.tools.utils.num import checknumber +from src.tools.utils.file import get_content_local +from src.tools.basic.server import getGroupServer from src.plugins.jx3.dungeon.api import mode_mapping from .box import * diff --git a/src/plugins/jx3/achievement/v1_v2.py b/src/plugins/jx3/achievement/v1_v2.py index 078a66445..fe281a147 100644 --- a/src/plugins/jx3/achievement/v1_v2.py +++ b/src/plugins/jx3/achievement/v1_v2.py @@ -1,12 +1,12 @@ from pathlib import Path from typing import Optional, Union, Literal -from src.tools.basic.data_server import server_mapping +from src.tools.basic.server import server_mapping from src.tools.config import Config -from src.tools.basic.msg import PROMPT +from src.tools.basic.prompts import PROMPT from src.tools.utils.request import get_api, post_url from src.tools.utils.path import ASSETS, CACHE, VIEWS -from src.tools.file import read, write +from src.tools.utils.file import read, write from src.tools.generate import generate, get_uuid from src.tools.basic.jx3 import gen_ts, format_body, gen_xsk diff --git a/src/plugins/jx3/affection/__init__.py b/src/plugins/jx3/affection/__init__.py index 2ddbe285c..96b3b81e9 100644 --- a/src/plugins/jx3/affection/__init__.py +++ b/src/plugins/jx3/affection/__init__.py @@ -5,8 +5,8 @@ from nonebot.adapters.onebot.v11 import GroupMessageEvent, MessageSegment as ms from nonebot.params import CommandArg -from src.tools.utils.common import checknumber -from src.tools.file import get_content_local +from src.tools.utils.num import checknumber +from src.tools.utils.file import get_content_local from .app import * @@ -23,7 +23,7 @@ async def _(event: GroupMessageEvent, args: Message = CommandArg()): self_qq = event.user_id other_name = arg[1] other_qq = int(arg[2]) - custom_time = arg[3] if len(arg) == 4 else convert_time(getCurrentTime(), "%Y-%m-%d") + custom_time = arg[3] if len(arg) == 4 else convert_time(get_current_time(), "%Y-%m-%d") if not isinstance(custom_time, str): return timestamp = 0 diff --git a/src/plugins/jx3/affection/app.py b/src/plugins/jx3/affection/app.py index 512585068..ac0f81e26 100644 --- a/src/plugins/jx3/affection/app.py +++ b/src/plugins/jx3/affection/app.py @@ -3,14 +3,14 @@ from src.constant.jx3 import kungfu_to_school, colorList as colors -from src.tools.data import group_db, AffectionsList +from src.tools.database import group_db, AffectionsList from src.tools.utils.request import get_api -from src.tools.file import read, write +from src.tools.utils.file import read, write from src.tools.generate import get_uuid, generate -from src.tools.utils.common import convert_time, getRelateTime, getCurrentTime +from src.tools.utils.time import convert_time, get_relate_time, get_current_time from src.tools.config import Config -from src.tools.basic.msg import PROMPT -from src.tools.basic.data_server import getGroupServer +from src.tools.basic.prompts import PROMPT +from src.tools.basic.server import getGroupServer from src.tools.utils.path import ASSETS, CACHE, VIEWS from src.plugins.jx3.bind import get_player_local_data @@ -105,7 +105,7 @@ async def generateAffectionImage(uin: int): recognization = convert_time(i["time"], "%Y年%m月%d日") if not isinstance(recognization, str): return - relate = getRelateTime(getCurrentTime(), i["time"])[:-1] + relate = get_relate_time(get_current_time(), i["time"])[:-1] html = read(VIEWS + "/jx3/affections/affections.html") html = html.replace("$btxbfont", btxbfont).replace("$yozaifont", yozaifont).replace("$bg", bg).replace("$uin1", str(uin_1)).replace("$uin2", str(uin_2)).replace("$color1", color_1).replace("$color2", color_2).replace("$img1", img_1).replace("$img2", img_2).replace("$name1", name_1).replace("$name2", name_2).replace("$server", server).replace("$time", recognization).replace("$relate", relate) final_html = CACHE + "/" + get_uuid() + ".html" diff --git a/src/plugins/jx3/announce/__init__.py b/src/plugins/jx3/announce/__init__.py index 39c5f17da..9adb6c04b 100644 --- a/src/plugins/jx3/announce/__init__.py +++ b/src/plugins/jx3/announce/__init__.py @@ -5,7 +5,7 @@ from pathlib import Path -from src.tools.file import get_content_local +from src.tools.utils.file import get_content_local from src.tools.utils.path import ASSETS from src.tools.utils.request import get_api from src.tools.config import Config diff --git a/src/plugins/jx3/assistance/__init__.py b/src/plugins/jx3/assistance/__init__.py index 7be1357d9..c0417def9 100644 --- a/src/plugins/jx3/assistance/__init__.py +++ b/src/plugins/jx3/assistance/__init__.py @@ -3,9 +3,9 @@ from nonebot.adapters.onebot.v11 import GroupMessageEvent, MessageSegment as ms from nonebot.params import CommandArg -from src.tools.utils.common import checknumber -from src.tools.file import get_content_local -from src.tools.basic.group_opeator import getGroupSettings +from src.tools.utils.num import checknumber +from src.tools.utils.file import get_content_local +from src.tools.basic.group import getGroupSettings from .app import * diff --git a/src/plugins/jx3/assistance/app.py b/src/plugins/jx3/assistance/app.py index 68f8d6e47..aad227e07 100644 --- a/src/plugins/jx3/assistance/app.py +++ b/src/plugins/jx3/assistance/app.py @@ -3,12 +3,12 @@ from src.constant.jx3 import school_name_aliases, skill_icons, colorList -from src.tools.basic.group_opeator import getGroupSettings, setGroupSettings -from src.tools.utils.common import getCurrentTime +from src.tools.basic.group import getGroupSettings, setGroupSettings +from src.tools.utils.time import get_current_time from src.tools.utils.request import get_api from src.tools.generate import generate, get_uuid from src.tools.utils.path import ASSETS, CACHE, VIEWS -from src.tools.file import read, write +from src.tools.utils.file import read, write from src.tools.config import Config import random @@ -34,7 +34,7 @@ async def create_group(self, group: str, description: str, creator: str): "creator": creator, "applying": [], "member": [[], [], [], [], []], - "create_time": getCurrentTime(), + "create_time": get_current_time(), "description": description } opening = getGroupSettings(group, "opening") @@ -60,7 +60,7 @@ async def apply_for_place(self, group: str, description: str, id: str, job: str, "job": job_, "img": job_icon, "apply": applyer, - "time": getCurrentTime() + "time": get_current_time() } stg = await self.storge(group, description, new) if stg is False: diff --git a/src/plugins/jx3/attributes/__init__.py b/src/plugins/jx3/attributes/__init__.py index 5fa320fd6..c84c206f8 100644 --- a/src/plugins/jx3/attributes/__init__.py +++ b/src/plugins/jx3/attributes/__init__.py @@ -3,7 +3,7 @@ from nonebot.adapters.onebot.v11 import GroupMessageEvent, MessageSegment as ms from nonebot.params import CommandArg -from src.tools.file import get_content_local +from src.tools.utils.file import get_content_local from .api import * from .v4 import * diff --git a/src/plugins/jx3/attributes/api.py b/src/plugins/jx3/attributes/api.py index 7ca228734..3f8023349 100644 --- a/src/plugins/jx3/attributes/api.py +++ b/src/plugins/jx3/attributes/api.py @@ -4,12 +4,12 @@ from src.constant.jx3.skilldatalib import kungfu_to_school -from src.tools.basic.msg import PROMPT +from src.tools.basic.prompts import PROMPT from src.tools.generate import get_uuid from src.tools.config import Config from src.tools.utils.request import get_api, get_content, post_url -from src.tools.basic.data_server import server_mapping, Zone_mapping -from src.tools.file import read +from src.tools.basic.server import server_mapping, Zone_mapping +from src.tools.utils.file import read from src.tools.utils.path import ASSETS, CACHE, PLUGINS from src.tools.basic.jx3 import gen_ts, format_body, gen_xsk diff --git a/src/plugins/jx3/attributes/v4.py b/src/plugins/jx3/attributes/v4.py index 7426dccbc..f72b73cb5 100644 --- a/src/plugins/jx3/attributes/v4.py +++ b/src/plugins/jx3/attributes/v4.py @@ -5,9 +5,9 @@ from src.tools.utils.request import get_api from src.tools.config import Config -from src.tools.file import read, write -from src.tools.basic.data_server import server_mapping, Zone_mapping -from src.tools.basic.msg import PROMPT +from src.tools.utils.file import read, write +from src.tools.basic.server import server_mapping, Zone_mapping +from src.tools.basic.prompts import PROMPT from src.tools.basic.jx3 import gen_ts, format_body, gen_xsk from src.tools.utils.request import post_url from src.tools.generate import get_uuid, generate diff --git a/src/plugins/jx3/bind/__init__.py b/src/plugins/jx3/bind/__init__.py index 96c94a90e..7a55d8e3c 100644 --- a/src/plugins/jx3/bind/__init__.py +++ b/src/plugins/jx3/bind/__init__.py @@ -5,9 +5,9 @@ from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent from nonebot.params import CommandArg -from src.tools.basic.msg import PROMPT -from src.tools.basic.data_server import server_mapping -from src.tools.basic.group_opeator import setGroupSettings +from src.tools.basic.prompts import PROMPT +from src.tools.basic.server import server_mapping +from src.tools.basic.group import setGroupSettings from src.tools.permission import checker from .role import * diff --git a/src/plugins/jx3/bind/role.py b/src/plugins/jx3/bind/role.py index 57e2fc606..a3f11674f 100644 --- a/src/plugins/jx3/bind/role.py +++ b/src/plugins/jx3/bind/role.py @@ -3,8 +3,8 @@ from src.tools.config import Config from src.tools.utils.request import post_url from src.tools.basic.jx3 import gen_ts, gen_xsk, format_body -from src.tools.basic.data_server import server_mapping, Zone_mapping -from src.tools.data import group_db, RoleData +from src.tools.basic.server import server_mapping, Zone_mapping +from src.tools.database import group_db, RoleData try: from .uid import get_uid diff --git a/src/plugins/jx3/buff/__init__.py b/src/plugins/jx3/buff/__init__.py index 1036e19a4..8627852df 100644 --- a/src/plugins/jx3/buff/__init__.py +++ b/src/plugins/jx3/buff/__init__.py @@ -4,7 +4,7 @@ from nonebot.params import CommandArg, Arg from nonebot.typing import T_State -from src.tools.utils.common import checknumber +from src.tools.utils.time import checknumber from .api import * diff --git a/src/plugins/jx3/calendar/__init__.py b/src/plugins/jx3/calendar/__init__.py index 25e96725d..51ff735be 100644 --- a/src/plugins/jx3/calendar/__init__.py +++ b/src/plugins/jx3/calendar/__init__.py @@ -3,7 +3,7 @@ from nonebot.adapters.onebot.v11 import GroupMessageEvent, MessageSegment as ms from nonebot.params import CommandArg -from src.tools.file import get_content_local +from src.tools.utils.file import get_content_local from .api import getCalendar diff --git a/src/plugins/jx3/calendar/api.py b/src/plugins/jx3/calendar/api.py index 089d1777f..0859342bf 100644 --- a/src/plugins/jx3/calendar/api.py +++ b/src/plugins/jx3/calendar/api.py @@ -3,7 +3,7 @@ from src.tools.generate import get_uuid, generate from src.tools.config import Config from src.tools.utils.request import get_api -from src.tools.file import read, write +from src.tools.utils.file import read, write from src.tools.utils.path import ASSETS, CACHE, VIEWS def generate_weekday_list(start_day): diff --git a/src/plugins/jx3/daily/__init__.py b/src/plugins/jx3/daily/__init__.py index 63a344479..b1011ed9c 100644 --- a/src/plugins/jx3/daily/__init__.py +++ b/src/plugins/jx3/daily/__init__.py @@ -5,7 +5,7 @@ require("nonebot_plugin_apscheduler") from nonebot_plugin_apscheduler import scheduler -from src.tools.basic.group_opeator import send_subscribe +from src.tools.basic.group import send_subscribe from .api import * diff --git a/src/plugins/jx3/daily/api.py b/src/plugins/jx3/daily/api.py index 7fee9922c..35c0f95e9 100644 --- a/src/plugins/jx3/daily/api.py +++ b/src/plugins/jx3/daily/api.py @@ -1,6 +1,6 @@ from src.tools.config import Config from src.tools.utils.request import get_api -from src.tools.utils.common import convert_time +from src.tools.utils.time import convert_time import datetime diff --git a/src/plugins/jx3/detail/__init__.py b/src/plugins/jx3/detail/__init__.py index 5b1b70f9b..742295412 100644 --- a/src/plugins/jx3/detail/__init__.py +++ b/src/plugins/jx3/detail/__init__.py @@ -3,8 +3,8 @@ from nonebot.adapters.onebot.v11 import GroupMessageEvent, MessageSegment as ms from nonebot.params import CommandArg -from src.tools.basic.data_server import getGroupServer -from src.tools.file import get_content_local +from src.tools.basic.server import getGroupServer +from src.tools.utils.file import get_content_local from .detail import * diff --git a/src/plugins/jx3/detail/detail.py b/src/plugins/jx3/detail/detail.py index b7cc3fecb..dc32bf25c 100644 --- a/src/plugins/jx3/detail/detail.py +++ b/src/plugins/jx3/detail/detail.py @@ -4,12 +4,12 @@ from src.tools.basic.jx3 import gen_ts, gen_xsk, format_body from src.tools.config import Config from src.tools.utils.request import get_api, post_url -from src.tools.file import read, write +from src.tools.utils.file import read, write from src.tools.utils.path import ASSETS, CACHE, PLUGINS, VIEWS -from src.tools.utils.common import convert_time, getCurrentTime +from src.tools.utils.time import convert_time, get_current_time from src.tools.generate import get_uuid, generate -from src.tools.basic.msg import PROMPT -from src.tools.basic.data_server import server_mapping +from src.tools.basic.prompts import PROMPT +from src.tools.basic.server import server_mapping from src.plugins.jx3.bind import get_player_local_data @@ -162,7 +162,7 @@ async def generate_zd_image(server: Optional[str], id: str): font = ASSETS + "/font/custom.ttf" saohua = "严禁将蓉蓉机器人与音卡共存,一经发现永久封禁!蓉蓉是抄袭音卡的劣质机器人!" - appinfo_time = convert_time(getCurrentTime(), "%H:%M") + appinfo_time = convert_time(get_current_time(), "%H:%M") html = html.replace("$customfont", font).replace("$tablecontent", content).replace("$randomsaohua", saohua).replace("$appinfo", f" 副本总览 · {server} · {id} · {appinfo_time}") final_html = CACHE + "/" + get_uuid() + ".html" write(final_html, html) @@ -247,7 +247,7 @@ async def get_all_dungeon_image(server: Optional[str], id: str, group_id: str): html = read(VIEWS + "/jx3/achievement/global_dungeon.html") font = ASSETS + "/font/custom.ttf" saohua = "严禁将蓉蓉机器人与音卡共存,一经发现永久封禁!蓉蓉是抄袭音卡的劣质机器人!" - appinfo_time = convert_time(getCurrentTime(), "%H:%M") + appinfo_time = convert_time(get_current_time(), "%H:%M") html = html.replace("$customfont", font).replace("$tablecontent", "\n".join(table)).replace("$randomsaohua", saohua).replace("$appinfo", f"副本分览 · {server} · {id} · {appinfo_time}") final_html = CACHE + "/" + get_uuid() + ".html" write(final_html, html) diff --git a/src/plugins/jx3/dungeon/__init__.py b/src/plugins/jx3/dungeon/__init__.py index 464a2e435..1cf7d199b 100644 --- a/src/plugins/jx3/dungeon/__init__.py +++ b/src/plugins/jx3/dungeon/__init__.py @@ -3,8 +3,8 @@ from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent, MessageSegment as ms from nonebot.params import CommandArg -from src.tools.basic.data_server import getGroupServer -from src.tools.file import get_content_local +from src.tools.basic.server import getGroupServer +from src.tools.utils.file import get_content_local from src.tools.utils.request import get_content from .api import * diff --git a/src/plugins/jx3/dungeon/api.py b/src/plugins/jx3/dungeon/api.py index 274df97fd..f37ddabdf 100644 --- a/src/plugins/jx3/dungeon/api.py +++ b/src/plugins/jx3/dungeon/api.py @@ -3,13 +3,13 @@ from nonebot.log import logger from src.tools.generate import generate, get_uuid -from src.tools.basic.data_server import server_mapping +from src.tools.basic.server import server_mapping from src.tools.config import Config from src.tools.utils.request import get_api, post_url from src.tools.basic.jx3 import gen_ts, gen_xsk, format_body, dungeon_sign from src.tools.utils.path import ASSETS, CACHE, PLUGINS, VIEWS -from src.tools.utils.common import convert_time, getCurrentTime, getRelateTime -from src.tools.file import read, write +from src.tools.utils.time import convert_time, get_current_time, get_relate_time +from src.tools.utils.file import read, write from src.plugins.jx3.bind import get_player_local_data from src.plugins.jx3.attributes import Zone_mapping @@ -503,7 +503,7 @@ async def get_item_record(name: str): timeGet = convert_time(i["Tm"]) if not isinstance(timeGet, str): return - relateTime = getRelateTime(getCurrentTime(), i["Tm"]) + relateTime = get_relate_time(get_current_time(), i["Tm"]) server = i["Srv"] tablecontents.append(template_item.replace("$server", server).replace("$name", item_name).replace( "$map", zone).replace("$id", id).replace("$time", timeGet).replace("$relate", relateTime)) @@ -512,7 +512,7 @@ async def get_item_record(name: str): break # 不限?不限给你鲨了 saohua = "严禁将蓉蓉机器人与音卡共存,一经发现永久封禁!蓉蓉是抄袭音卡的劣质机器人!" - appinfo_time = convert_time(getCurrentTime(), "%H:%M:%S") + appinfo_time = convert_time(get_current_time(), "%H:%M:%S") appinfo = f"掉落统计 · {server} · {name} · {appinfo_time}" final_table = "\n".join(tablecontents) html = read(VIEWS + "/jx3/item/item.html") diff --git a/src/plugins/jx3/dungeon/monster.py b/src/plugins/jx3/dungeon/monster.py index 4f274c095..b715c2ac4 100644 --- a/src/plugins/jx3/dungeon/monster.py +++ b/src/plugins/jx3/dungeon/monster.py @@ -3,8 +3,8 @@ from src.tools.generate import generate, get_uuid from src.tools.utils.request import get_api from src.tools.utils.path import ASSETS, CACHE, VIEWS -from src.tools.utils.common import convert_time, getCurrentTime -from src.tools.file import read, write +from src.tools.utils.time import convert_time, get_current_time +from src.tools.utils.file import read, write import re @@ -74,7 +74,7 @@ async def get_monsters_map(): font = ASSETS + "/font/custom.ttf" saohua = "严禁将蓉蓉机器人与音卡共存,一经发现永久封禁!蓉蓉是抄袭音卡的劣质机器人!" - appinfo_time = convert_time(getCurrentTime(), "%H:%M:%S") + appinfo_time = convert_time(get_current_time(), "%H:%M:%S") appinfo = f"自{start}起7天 · 当前时间:{appinfo_time}
{saohua}" html = html.replace("$content", "\n".join(content)).replace( "$customfont", font).replace("$appinfo", appinfo) diff --git a/src/plugins/jx3/equip/__init__.py b/src/plugins/jx3/equip/__init__.py index 233b6343c..f55780a61 100644 --- a/src/plugins/jx3/equip/__init__.py +++ b/src/plugins/jx3/equip/__init__.py @@ -6,11 +6,11 @@ from nonebot.params import CommandArg, Arg from nonebot.typing import T_State -from src.tools.file import read, write, get_content_local +from src.tools.utils.file import read, write, get_content_local from src.tools.utils.path import ASSETS, CACHE, PLUGINS, VIEWS -from src.tools.utils.common import checknumber +from src.tools.utils.num import checknumber from src.tools.generate import generate, get_uuid -from src.tools.basic.msg import PROMPT +from src.tools.basic.prompts import PROMPT from src.constant.jx3 import school_name_aliases from .api import * diff --git a/src/plugins/jx3/events/__init__.py b/src/plugins/jx3/events/__init__.py index 4e6dfc8fa..5acc4e118 100644 --- a/src/plugins/jx3/events/__init__.py +++ b/src/plugins/jx3/events/__init__.py @@ -3,9 +3,9 @@ from nonebot.adapters.onebot.v11 import GroupMessageEvent, MessageSegment as ms from nonebot.params import CommandArg -from src.tools.basic.data_server import server_mapping -from src.tools.basic.msg import PROMPT -from src.tools.file import get_content_local +from src.tools.basic.server import server_mapping +from src.tools.basic.prompts import PROMPT +from src.tools.utils.file import get_content_local from .chutian import * from .yuncong import * diff --git a/src/plugins/jx3/events/chutian.py b/src/plugins/jx3/events/chutian.py index 8709b1c61..0c3e9ed9c 100644 --- a/src/plugins/jx3/events/chutian.py +++ b/src/plugins/jx3/events/chutian.py @@ -2,10 +2,10 @@ from src.tools.config import Config from src.tools.utils.request import get_api -from src.tools.file import read, write +from src.tools.utils.file import read, write from src.tools.generate import generate, get_uuid from src.tools.utils.path import ASSETS, CACHE, VIEWS -from src.tools.utils.common import getCurrentTime, convert_time +from src.tools.utils.time import get_current_time, convert_time template_chutian = """ @@ -33,7 +33,7 @@ async def getChutianImg(): font = ASSETS + "/font/custom.ttf" saohua = "严禁将蓉蓉机器人与音卡共存,一经发现永久封禁!蓉蓉是抄袭音卡的劣质机器人!" - current_time = convert_time(getCurrentTime(), "%H:%M:%S") + current_time = convert_time(get_current_time(), "%H:%M:%S") html = html.replace("$customfont", font).replace("$tablecontent", final_table).replace("$randomsaohua", saohua).replace("$appinfo", f"楚天社 · {current_time}") final_html = CACHE + "/" + get_uuid() + ".html" write(final_html, html) diff --git a/src/plugins/jx3/events/yuncong.py b/src/plugins/jx3/events/yuncong.py index ef0363947..f58567217 100644 --- a/src/plugins/jx3/events/yuncong.py +++ b/src/plugins/jx3/events/yuncong.py @@ -2,10 +2,10 @@ from src.tools.config import Config from src.tools.utils.request import get_api -from src.tools.file import read, write +from src.tools.utils.file import read, write from src.tools.generate import generate, get_uuid from src.tools.utils.path import ASSETS, CACHE, VIEWS -from src.tools.utils.common import getCurrentTime, convert_time +from src.tools.utils.time import get_current_time, convert_time from .chutian import template_chutian @@ -32,7 +32,7 @@ async def getYuncongImg(): font = ASSETS + "/font/custom.ttf" saohua = "严禁将蓉蓉机器人与音卡共存,一经发现永久封禁!蓉蓉是抄袭音卡的劣质机器人!" - current_time = convert_time(getCurrentTime(), "%H:%M:%S") + current_time = convert_time(get_current_time(), "%H:%M:%S") html = html.replace("$customfont", font).replace("$tablecontent", final_table).replace("$randomsaohua", saohua).replace("$appinfo", f"楚天社 · {current_time}") final_html = CACHE + "/" + get_uuid() + ".html" write(final_html, html) diff --git a/src/plugins/jx3/events/zhue.py b/src/plugins/jx3/events/zhue.py index 8565d7d01..a1f8c2017 100644 --- a/src/plugins/jx3/events/zhue.py +++ b/src/plugins/jx3/events/zhue.py @@ -2,11 +2,11 @@ from src.tools.config import Config from src.tools.utils.request import get_api -from src.tools.file import read, write +from src.tools.utils.file import read, write from src.tools.generate import generate, get_uuid from src.tools.utils.path import ASSETS, CACHE, VIEWS -from src.tools.utils.common import getCurrentTime, convert_time, getRelateTime -from src.tools.basic.data_server import Zone_mapping +from src.tools.utils.time import get_current_time, convert_time, get_relate_time +from src.tools.basic.server import Zone_mapping import json import time @@ -56,10 +56,10 @@ async def getZhueRecord(server: str): data = data["rows"] tables = [] for i in data: - relateTime = getRelateTime(getCurrentTime(), i["Tm"]) + relateTime = get_relate_time(get_current_time(), i["Tm"]) tables.append(template_zhue.replace("$time", str(convert_time(i["Tm"]))).replace("$map", i["Content"]).replace("$relate", relateTime)) saohua = "严禁将蓉蓉机器人与音卡共存,一经发现永久封禁!蓉蓉是抄袭音卡的劣质机器人!" - appinfo_time = convert_time(getCurrentTime(), "%H:%M:%S") + appinfo_time = convert_time(get_current_time(), "%H:%M:%S") appinfo = f" · 诛恶记录 · {server} · {appinfo_time}" final_table = "\n".join(tables) html = read(VIEWS + "/jx3/celebrations/zhue.html") diff --git a/src/plugins/jx3/gold/__init__.py b/src/plugins/jx3/gold/__init__.py index b1df19836..d0d48066f 100644 --- a/src/plugins/jx3/gold/__init__.py +++ b/src/plugins/jx3/gold/__init__.py @@ -3,7 +3,7 @@ from nonebot.params import CommandArg from nonebot.adapters.onebot.v11 import GroupMessageEvent, MessageSegment as ms -from src.tools.file import get_content_local +from src.tools.utils.file import get_content_local from .api import * diff --git a/src/plugins/jx3/gold/api.py b/src/plugins/jx3/gold/api.py index b0d174b75..bb2b9001e 100644 --- a/src/plugins/jx3/gold/api.py +++ b/src/plugins/jx3/gold/api.py @@ -2,12 +2,12 @@ from pathlib import Path from src.tools.config import Config -from src.tools.basic.msg import PROMPT -from src.tools.basic.data_server import server_mapping +from src.tools.basic.prompts import PROMPT +from src.tools.basic.server import server_mapping from src.tools.utils.request import get_api from src.tools.utils.path import ASSETS, CACHE, VIEWS -from src.tools.utils.common import getCurrentTime, convert_time -from src.tools.file import read, write +from src.tools.utils.time import get_current_time, convert_time +from src.tools.utils.file import read, write from src.tools.generate import get_uuid, generate import json @@ -74,7 +74,7 @@ async def demon_(server: str = "", group_id: str = ""): # 金价 <服务器> "custom_font": ASSETS + "/font/custom.ttf", "tablecontent": "\n".join(tables), "server": goal_server, - "app_time": convert_time(getCurrentTime(), "%H:%M:%S"), + "app_time": convert_time(get_current_time(), "%H:%M:%S"), "saohua": "严禁将蓉蓉机器人与音卡共存,一经发现永久封禁!蓉蓉是抄袭音卡的劣质机器人!", "platforms": json.dumps(list(types), ensure_ascii=False).replace("WBL", "万宝楼"), "dates": json.dumps(dates, ensure_ascii=False), diff --git a/src/plugins/jx3/horse/api.py b/src/plugins/jx3/horse/api.py index dd3b6f675..2b5d3f8fb 100644 --- a/src/plugins/jx3/horse/api.py +++ b/src/plugins/jx3/horse/api.py @@ -1,8 +1,8 @@ -from src.tools.utils.common import convert_time -from src.tools.basic.msg import PROMPT -from src.tools.basic.data_server import server_mapping +from src.tools.utils.time import convert_time +from src.tools.basic.prompts import PROMPT +from src.tools.basic.server import server_mapping from src.tools.utils.request import get_api -from src.tools.basic.msg import PROMPT +from src.tools.basic.prompts import PROMPT from datetime import datetime, timedelta diff --git a/src/plugins/jx3/horse/dilu.py b/src/plugins/jx3/horse/dilu.py index 41f7536ff..f2fcc5602 100644 --- a/src/plugins/jx3/horse/dilu.py +++ b/src/plugins/jx3/horse/dilu.py @@ -4,9 +4,9 @@ from src.constant.jx3 import brickl, goldl -from src.tools.file import read, write +from src.tools.utils.file import read, write from src.tools.utils.request import get_api -from src.tools.utils.common import convert_time, getCurrentTime +from src.tools.utils.time import convert_time, get_current_time from src.tools.utils.path import ASSETS, CACHE, TOOLS, VIEWS from src.tools.generate import get_uuid, generate @@ -154,7 +154,7 @@ async def get_dilu_data(): html = read(VIEWS + "/jx3/dilu/dilu.html") font = ASSETS + "/font/custom.ttf" saohua = "严禁将蓉蓉机器人与音卡共存,一经发现永久封禁!蓉蓉是抄袭音卡的劣质机器人!" - appinfo_time = convert_time(getCurrentTime(), "%H:%M:%S") + appinfo_time = convert_time(get_current_time(), "%H:%M:%S") html = html.replace("$customfont", font).replace("$tablecontent", content).replace( "$randomsaohua", saohua).replace("$appinfo", f"的卢统计 · {appinfo_time}") final_html = CACHE + "/" + get_uuid() + ".html" diff --git a/src/plugins/jx3/joy/__init__.py b/src/plugins/jx3/joy/__init__.py index 2ad5e5d48..272050f26 100644 --- a/src/plugins/jx3/joy/__init__.py +++ b/src/plugins/jx3/joy/__init__.py @@ -5,7 +5,7 @@ from nonebot.rule import to_me from src.tools.config import Config -from src.tools.utils.common import checknumber +from src.tools.utils.num import checknumber from src.tools.utils.request import get_api, post_url from .api import * diff --git a/src/plugins/jx3/parse.py b/src/plugins/jx3/parse.py index c261a6b65..745f67598 100644 --- a/src/plugins/jx3/parse.py +++ b/src/plugins/jx3/parse.py @@ -3,7 +3,7 @@ from typing import Literal, Callable, Type, Dict, Tuple from dataclasses import dataclass -from src.tools.utils.common import getCurrentTime, convert_time +from src.tools.utils.time import get_current_time, convert_time handler: Dict[int, Callable[[dict], JX3APIPushEvent]] = {} @@ -30,7 +30,7 @@ class JX3APIServerEvent(JX3APIPushEvent): def msg(self) -> JX3APIOutputMsg: status_str = "开服" if self.status else "维护" - current_time = convert_time(getCurrentTime(), "%H:%M") + current_time = convert_time(get_current_time(), "%H:%M") return JX3APIOutputMsg(msg=f"{self.server} {status_str}啦! 在{current_time}", server=self.server, name="开服") @handle_event(2002) diff --git a/src/plugins/jx3/penzai/__init__.py b/src/plugins/jx3/penzai/__init__.py index 11d34d59b..36577024b 100644 --- a/src/plugins/jx3/penzai/__init__.py +++ b/src/plugins/jx3/penzai/__init__.py @@ -4,8 +4,8 @@ from nonebot.typing import T_State from nonebot.adapters.onebot.v11 import GroupMessageEvent, MessageSegment as ms -from src.tools.utils.common import checknumber -from src.tools.basic.msg import PROMPT +from src.tools.utils.num import checknumber +from src.tools.basic.prompts import PROMPT from .api import * @@ -68,7 +68,7 @@ async def _(event: GroupMessageEvent, state: T_State, args: Message = CommandArg if len(details) < 1: await wg_.finish("您没有输入条件哦,请检查后重试~\n条件以空格分割哦~") final_details = ",".join(details) - data = await get_wg(final_details) + data = await get_wg(final_details) # type: ignore if isinstance(data, list): image = data[0] state["links"] = data[1] diff --git a/src/plugins/jx3/penzai/dh.py b/src/plugins/jx3/penzai/dh.py index bceaaa79d..e6b15dcff 100644 --- a/src/plugins/jx3/penzai/dh.py +++ b/src/plugins/jx3/penzai/dh.py @@ -2,9 +2,9 @@ from src.tools.utils.request import get_api from src.tools.utils.path import ASSETS, CACHE, VIEWS -from src.tools.file import read, write +from src.tools.utils.file import read, write from src.tools.generate import get_uuid, generate -from src.tools.utils.common import convert_time +from src.tools.utils.time import convert_time import datetime diff --git a/src/plugins/jx3/penzai/wg.py b/src/plugins/jx3/penzai/wg.py index 6cd260ad3..e76a4eb56 100644 --- a/src/plugins/jx3/penzai/wg.py +++ b/src/plugins/jx3/penzai/wg.py @@ -3,9 +3,9 @@ from src.tools.utils.request import get_api, get_url from src.tools.utils.path import ASSETS, CACHE, VIEWS -from src.tools.file import read, write +from src.tools.utils.file import read, write from src.tools.generate import get_uuid, generate -from src.tools.utils.common import convert_time +from src.tools.utils.time import convert_time import datetime import re diff --git a/src/plugins/jx3/pvp/__init__.py b/src/plugins/jx3/pvp/__init__.py index 1dfd9f026..c9bdb412e 100644 --- a/src/plugins/jx3/pvp/__init__.py +++ b/src/plugins/jx3/pvp/__init__.py @@ -3,8 +3,8 @@ from nonebot.params import CommandArg from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent, MessageSegment as ms -from src.tools.basic.msg import PROMPT -from src.tools.file import get_content_local +from src.tools.basic.prompts import PROMPT +from src.tools.utils.file import get_content_local from .api import * diff --git a/src/plugins/jx3/pvp/api.py b/src/plugins/jx3/pvp/api.py index 658db9013..1bbab3123 100644 --- a/src/plugins/jx3/pvp/api.py +++ b/src/plugins/jx3/pvp/api.py @@ -3,12 +3,12 @@ from jinja2 import Template from src.tools.config import Config -from src.tools.basic.msg import PROMPT -from src.tools.file import read, write +from src.tools.basic.prompts import PROMPT +from src.tools.utils.file import read, write from src.tools.generate import generate, get_uuid -from src.tools.basic.data_server import server_mapping, Zone_mapping +from src.tools.basic.server import server_mapping, Zone_mapping from src.tools.utils.request import post_url -from src.tools.utils.common import convert_time, getRelateTime, getCurrentTime +from src.tools.utils.time import convert_time, get_relate_time, get_current_time from src.tools.basic.jx3 import gen_ts, gen_xsk, format_body from src.tools.utils.path import ASSETS, CACHE, VIEWS @@ -187,7 +187,7 @@ async def arena_record(server: Optional[str] = "", name: str = "", group_id: str "rank": str(i["avg_grade"]), "mode": str(i["pvp_type"]) + "v" + str(i["pvp_type"]), "time": convert_time(i["start_time"], "%m月%d日 %H:%M:%S"), - "relate": getRelateTime(getCurrentTime(), i["end_time"]), + "relate": get_relate_time(get_current_time(), i["end_time"]), "length": "共" + str(i["end_time"] - i["start_time"]) + "秒", "score": str(i["total_mmr"]), "delta": str(i["mmr"]), diff --git a/src/plugins/jx3/serendipity/__init__.py b/src/plugins/jx3/serendipity/__init__.py index f77c51d5d..caa252351 100644 --- a/src/plugins/jx3/serendipity/__init__.py +++ b/src/plugins/jx3/serendipity/__init__.py @@ -3,7 +3,7 @@ from nonebot.params import CommandArg from nonebot.adapters.onebot.v11 import GroupMessageEvent, MessageSegment as ms -from src.tools.file import get_content_local +from src.tools.utils.file import get_content_local from src.tools.utils.request import get_content from .v1 import * diff --git a/src/plugins/jx3/serendipity/v1.py b/src/plugins/jx3/serendipity/v1.py index 4b19fa74e..fbb164d51 100644 --- a/src/plugins/jx3/serendipity/v1.py +++ b/src/plugins/jx3/serendipity/v1.py @@ -2,8 +2,8 @@ from src.tools.config import Config from src.tools.utils.request import get_api -from src.tools.basic.msg import PROMPT -from src.tools.basic.data_server import server_mapping +from src.tools.basic.prompts import PROMPT +from src.tools.basic.server import server_mapping token = Config.jx3.api.token ticket = Config.jx3.api.ticket diff --git a/src/plugins/jx3/serendipity/v2.py b/src/plugins/jx3/serendipity/v2.py index 5f830d356..6d49904e0 100644 --- a/src/plugins/jx3/serendipity/v2.py +++ b/src/plugins/jx3/serendipity/v2.py @@ -4,12 +4,12 @@ from src.tools.config import Config from src.tools.utils.request import get_api -from src.tools.basic.msg import PROMPT -from src.tools.basic.data_server import server_mapping +from src.tools.basic.prompts import PROMPT +from src.tools.basic.server import server_mapping from src.tools.utils.path import ASSETS, CACHE, VIEWS from src.tools.generate import get_uuid, generate -from src.tools.utils.common import convert_time -from src.tools.file import read, write +from src.tools.utils.time import convert_time +from src.tools.utils.file import read, write from src.plugins.jx3.bind import get_player_local_data diff --git a/src/plugins/jx3/server/__init__.py b/src/plugins/jx3/server/__init__.py index ebe4ef37e..369a4f4b6 100644 --- a/src/plugins/jx3/server/__init__.py +++ b/src/plugins/jx3/server/__init__.py @@ -3,8 +3,8 @@ from nonebot.params import CommandArg from nonebot.adapters.onebot.v11 import GroupMessageEvent -from src.tools.basic.data_server import server_mapping -from src.tools.basic.msg import PROMPT +from src.tools.basic.server import server_mapping +from src.tools.basic.prompts import PROMPT from .api import * diff --git a/src/plugins/jx3/skill/__init__.py b/src/plugins/jx3/skill/__init__.py index 23ab67453..44ad1761d 100644 --- a/src/plugins/jx3/skill/__init__.py +++ b/src/plugins/jx3/skill/__init__.py @@ -6,7 +6,7 @@ from src.constant.jx3 import getSingleSkill, school_name_aliases from src.tools.utils.request import get_api -from src.tools.file import read, write +from src.tools.utils.file import read, write from src.tools.utils.path import ASSETS from .macro import * diff --git a/src/plugins/jx3/subscribe/__init__.py b/src/plugins/jx3/subscribe/__init__.py index f1a8886ba..4c951351a 100644 --- a/src/plugins/jx3/subscribe/__init__.py +++ b/src/plugins/jx3/subscribe/__init__.py @@ -3,9 +3,9 @@ from nonebot.params import CommandArg from nonebot.adapters.onebot.v11 import GroupMessageEvent, Bot, MessageSegment as ms -from src.tools.file import read +from src.tools.utils.file import read from src.tools.utils.path import PLUGINS -from src.tools.basic.group_opeator import getGroupSettings, setGroupSettings +from src.tools.basic.group import getGroupSettings, setGroupSettings from .about import * diff --git a/src/plugins/jx3/subscribe/about.py b/src/plugins/jx3/subscribe/about.py index b68768484..64691210f 100644 --- a/src/plugins/jx3/subscribe/about.py +++ b/src/plugins/jx3/subscribe/about.py @@ -2,9 +2,9 @@ from nonebot.adapters.onebot.v11 import Bot from src.tools.utils.path import ASSETS, CACHE, PLUGINS, VIEWS -from src.tools.basic.group_opeator import getGroupSettings +from src.tools.basic.group import getGroupSettings from src.tools.generate import get_uuid, generate -from src.tools.file import read, write +from src.tools.utils.file import read, write import json diff --git a/src/plugins/jx3/task/__init__.py b/src/plugins/jx3/task/__init__.py index 1808e33b2..04f5926c2 100644 --- a/src/plugins/jx3/task/__init__.py +++ b/src/plugins/jx3/task/__init__.py @@ -3,8 +3,8 @@ from nonebot.params import CommandArg, Arg from nonebot.typing import T_State -from src.tools.utils.common import checknumber -from src.tools.basic.msg import PROMPT +from src.tools.utils.num import checknumber +from src.tools.basic.prompts import PROMPT from .api import * diff --git a/src/plugins/jx3/trade/__init__.py b/src/plugins/jx3/trade/__init__.py index 48ef14097..13a221fb7 100644 --- a/src/plugins/jx3/trade/__init__.py +++ b/src/plugins/jx3/trade/__init__.py @@ -3,7 +3,7 @@ from nonebot.params import CommandArg from nonebot.adapters.onebot.v11 import GroupMessageEvent, MessageSegment as ms -from src.tools.file import get_content_local +from src.tools.utils.file import get_content_local from src.tools.utils.request import get_content from src.tools.permission import checker, error diff --git a/src/plugins/jx3/trade/api.py b/src/plugins/jx3/trade/api.py index f05f4fb74..154c0854e 100644 --- a/src/plugins/jx3/trade/api.py +++ b/src/plugins/jx3/trade/api.py @@ -3,12 +3,13 @@ from src.constant.jx3 import brickl, goldl, silverl, copperl from src.tools.utils.request import get_api -from src.tools.basic.msg import PROMPT -from src.tools.basic.data_server import server_mapping -from src.tools.utils.common import checknumber, convert_time, getCurrentTime +from src.tools.basic.prompts import PROMPT +from src.tools.basic.server import server_mapping +from src.tools.utils.num import checknumber +from src.tools.utils.time import convert_time, get_current_time from src.tools.generate import generate, get_uuid from src.tools.utils.path import ASSETS, CACHE, TOOLS, VIEWS -from src.tools.file import read, write +from src.tools.utils.file import read, write import datetime import json @@ -45,8 +46,8 @@ async def getImg(server: str, name: str, group: str, itemList: list = []): if server == "全服": data = await getSingleImg(name) return data - server = server_mapping(server, group) - if not server: + server_ = server_mapping(server, group) + if not server_: return [PROMPT.ServerNotExist] for i in filters: if name.find(i) != -1: @@ -74,7 +75,7 @@ async def getImg(server: str, name: str, group: str, itemList: list = []): if i["BindType"] not in [0, 1, 2, None]: continue id = i["id"] - itemAPIData = await get_api(f"https://next2.jx3box.com/api/item-price/{id}/logs?server={server}&limit=20") + itemAPIData = await get_api(f"https://next2.jx3box.com/api/item-price/{id}/logs?server={server_}&limit=20") if itemAPIData["data"]["logs"] == None: continue else: @@ -96,7 +97,7 @@ async def getImg(server: str, name: str, group: str, itemList: list = []): currentStatus = 1 current = itemList_searchable[0]["data"]["yesterday"] if currentStatus: - toReplace = [["$low", toCoinImage(convert(current["LowestPrice"]))], ["$equal", toCoinImage(convert(current["AvgPrice"]))], ["$high", toCoinImage(convert(current["HighestPrice"]))]] + toReplace = [["$low", toCoinImage(str(convert(current["LowestPrice"])))], ["$equal", toCoinImage(str(convert(current["AvgPrice"])))], ["$high", toCoinImage(str(convert(current["HighestPrice"])))]] msgbox = template_msgbox for toReplace_word in toReplace: msgbox = msgbox.replace(toReplace_word[0], toReplace_word[1]) @@ -104,7 +105,7 @@ async def getImg(server: str, name: str, group: str, itemList: list = []): msgbox = "" color = ["(167, 167, 167)", "(255, 255, 255)", "(0, 210, 75)", "(0, 126, 255)", "(254, 45, 254)", "(255, 165, 0)"][itemList_searchable[0]["quality"]] itemId = itemList_searchable[0]["id"] - detailData = await get_api(f"https://next2.jx3box.com/api/item-price/{itemId}/detail?server={server}&limit=20") + detailData = await get_api(f"https://next2.jx3box.com/api/item-price/{itemId}/detail?server={server_}&limit=20") if (not currentStatus or yesterdayFlag) and detailData["data"]["prices"] == None: if not yesterdayFlag: return ["唔……该物品目前交易行没有数据。"] @@ -116,7 +117,7 @@ async def getImg(server: str, name: str, group: str, itemList: list = []): table = [] for each_price in detailData["data"]["prices"]: table_content = template_table - toReplace_word = [["$icon", itemList_searchable[0]["icon"]], ["$color", color], ["$name", itemList_searchable[0]["name"]], ["$time", convert_time(each_price["created"], "%m月%d日 %H:%M:%S")], ["$limit", str(each_price["n_count"])], ["$price", toCoinImage(convert(each_price["unit_price"]))]] + toReplace_word = [["$icon", itemList_searchable[0]["icon"]], ["$color", color], ["$name", itemList_searchable[0]["name"]], ["$time", convert_time(each_price["created"], "%m月%d日 %H:%M:%S")], ["$limit", str(each_price["n_count"])], ["$price", toCoinImage(str(convert(each_price["unit_price"])))]] for word in toReplace_word: table_content = table_content.replace(word[0], word[1]) table.append(table_content) @@ -128,10 +129,12 @@ async def getImg(server: str, name: str, group: str, itemList: list = []): saohua = "严禁将蓉蓉机器人与音卡共存,一经发现永久封禁!蓉蓉是抄袭音卡的劣质机器人!" final_name = itemList_searchable[0]["name"] if itemList == [] else "+".join(itemList) - html = html.replace("$customfont", font).replace("$tablecontent", final_table).replace("$randomsaohua", saohua).replace("$appinfo", f"交易行 · {server} · {final_name}").replace("$msgbox", msgbox) + html = html.replace("$customfont", font).replace("$tablecontent", final_table).replace("$randomsaohua", saohua).replace("$appinfo", f"交易行 · {server_} · {final_name}").replace("$msgbox", msgbox) final_html = CACHE + "/" + get_uuid() + ".html" write(final_html, html) final_path = await generate(final_html, False, ".total", False) + if not isinstance(final_path, str): + return return Path(final_path).as_uri() else: # 如果有多个,则分别显示近期价格,只显示最新一条 @@ -140,31 +143,33 @@ async def getImg(server: str, name: str, group: str, itemList: list = []): color = ["(167, 167, 167)", "(255, 255, 255)", "(0, 210, 75)", "(0, 126, 255)", "(254, 45, 254)", "(255, 165, 0)"][each_item["quality"]] itemId = each_item["id"] final_name = each_item["name"] - itemData = await get_api(f"https://next2.jx3box.com/api/item-price/{itemId}/detail?server={server}&limit=20") + itemData = await get_api(f"https://next2.jx3box.com/api/item-price/{itemId}/detail?server={server_}&limit=20") table_content = template_table if itemData["data"]["prices"] == None: # 转用已存储的Log进行处理 itemData = each_item["data"]["logs"][-1] time_that = itemData["CreatedAt"] timestamp = datetime.datetime.strptime(time_that, "%Y-%m-%dT%H:%M:%S+08:00") - final_time = convert_time(int(timestamp.timestamp()), "%m月%d日 %H:%M:%S") + final_time = str(convert_time(int(timestamp.timestamp()), "%m月%d日 %H:%M:%S")) count = str(itemData["SampleSize"]) - table.append(table_content.replace("$icon", each_item["icon"]).replace("$color", color).replace("$name", final_name).replace("$time", final_time).replace("$limit", count).replace("$price", toCoinImage(convert(itemData["AvgPrice"])))) + table.append(table_content.replace("$icon", each_item["icon"]).replace("$color", color).replace("$name", final_name).replace("$time", final_time).replace("$limit", count).replace("$price", toCoinImage(str(convert(itemData["AvgPrice"]))))) else: # 使用最新一条数据 itemData = itemData["data"]["prices"][0] - final_time = convert_time(itemData["created"], "%m月%d日 %H:%M:%S") + final_time = str(convert_time(itemData["created"], "%m月%d日 %H:%M:%S")) count = str(itemData["n_count"]) - table.append(table_content.replace("$icon", each_item["icon"]).replace("$color", color).replace("$name", final_name).replace("$time", final_time).replace("$limit", count).replace("$price", toCoinImage(convert(itemData["unit_price"])))) + table.append(table_content.replace("$icon", each_item["icon"]).replace("$color", color).replace("$name", final_name).replace("$time", final_time).replace("$limit", count).replace("$price", toCoinImage(str(convert(itemData["unit_price"]))))) final_table = "\n".join(table) html = read(VIEWS + "/jx3/trade/trade.html") font = ASSETS + "/font/custom.ttf" saohua = "严禁将蓉蓉机器人与音卡共存,一经发现永久封禁!蓉蓉是抄袭音卡的劣质机器人!" - html = html.replace("$customfont", font).replace("$tablecontent", final_table).replace("$randomsaohua", saohua).replace("$appinfo", f"交易行 · {server} · {name}").replace("$msgbox", "") + html = html.replace("$customfont", font).replace("$tablecontent", final_table).replace("$randomsaohua", saohua).replace("$appinfo", f"交易行 · {server_} · {name}").replace("$msgbox", "") final_html = CACHE + "/" + get_uuid() + ".html" write(final_html, html) final_path = await generate(final_html, False, ".total", False) + if not isinstance(final_path, str): + return return Path(final_path).as_uri() async def getSingleImg(name: str): @@ -226,15 +231,15 @@ async def getSingleImg(name: str): detailData = await get_api(f"https://next2.jx3box.com/api/item-price/{itemId}/detail?server={server}&limit=20") if (not currentStatus or yesterdayFlag) and detailData["data"]["prices"] == None: if not yesterdayFlag: - toReplace_word = [["$icon", icon], ["$color", color], ["$name", name + f"({server})"], ["$time", convert_time(getCurrentTime(), "%m月%d日 %H:%M:%S")], ["$limit", "N/A"], ["$price", "没有数据"]] + toReplace_word = [["$icon", icon], ["$color", color], ["$name", name + f"({server})"], ["$time", convert_time(get_current_time(), "%m月%d日 %H:%M:%S")], ["$limit", "N/A"], ["$price", "没有数据"]] table_content = template_table for word in toReplace_word: table_content = table_content.replace(word[0], word[1]) table.append(table_content) continue else: - avg = convert(current["AvgPrice"]) - toReplace_word = [["$icon", icon], ["$color", color], ["$name", name + f"({server})"], ["$time", convert_time(getCurrentTime(), "%m月%d日 %H:%M:%S")], ["$limit", "N/A"], ["$price", toCoinImage(avg)]] + avg = str(convert(current["AvgPrice"])) + toReplace_word = [["$icon", icon], ["$color", color], ["$name", name + f"({server})"], ["$time", convert_time(get_current_time(), "%m月%d日 %H:%M:%S")], ["$limit", "N/A"], ["$price", toCoinImage(avg)]] table_content = template_table for word in toReplace_word: table_content = table_content.replace(word[0], word[1]) @@ -242,7 +247,7 @@ async def getSingleImg(name: str): continue each_price = detailData["data"]["prices"][0] table_content = template_table - toReplace_word = [["$icon", itemList_searchable[0]["icon"]], ["$color", color], ["$name", itemList_searchable[0]["name"] + f"({server})"], ["$time", convert_time(each_price["created"], "%m月%d日 %H:%M:%S")], ["$limit", str(each_price["n_count"])], ["$price", toCoinImage(convert(each_price["unit_price"]))]] + toReplace_word = [["$icon", itemList_searchable[0]["icon"]], ["$color", color], ["$name", itemList_searchable[0]["name"] + f"({server})"], ["$time", convert_time(each_price["created"], "%m月%d日 %H:%M:%S")], ["$limit", str(each_price["n_count"])], ["$price", toCoinImage(str(convert(each_price["unit_price"])))]] for word in toReplace_word: table_content = table_content.replace(word[0], word[1]) table.append(table_content) @@ -257,7 +262,7 @@ async def getSingleImg(name: str): final_lowest = int(sum(flows) / len(flows)) except: return ["唔……该物品全服均没有数据!"] - toReplace = [["$low", toCoinImage(convert(final_lowest))], ["$equal", toCoinImage(convert(final_avg))], ["$high", toCoinImage(convert(final_highest))]] + toReplace = [["$low", toCoinImage(str(convert(final_lowest)))], ["$equal", toCoinImage(str(convert(final_avg)))], ["$high", toCoinImage(str(convert(final_highest)))]] msgbox = template_msgbox.replace("当日", "全服") for toReplace_word in toReplace: msgbox = msgbox.replace(toReplace_word[0], toReplace_word[1]) @@ -271,6 +276,8 @@ async def getSingleImg(name: str): final_html = CACHE + "/" + get_uuid() + ".html" write(final_html, html) final_path = await generate(final_html, False, ".total", False) + if not isinstance(final_path, str): + return return Path(final_path).as_uri() def toCoinImage(rawString: str): diff --git a/src/plugins/jx3/trade/item.py b/src/plugins/jx3/trade/item.py index b704f8e40..f0bca8e1f 100644 --- a/src/plugins/jx3/trade/item.py +++ b/src/plugins/jx3/trade/item.py @@ -1,5 +1,5 @@ from src.tools.utils.request import get_api -from src.tools.basic.msg import PROMPT +from src.tools.basic.prompts import PROMPT from src.tools.config import Config token = Config.jx3.api.token diff --git a/src/plugins/jx3/trade/item_v2.py b/src/plugins/jx3/trade/item_v2.py index 92e9bcacc..a6db1a783 100644 --- a/src/plugins/jx3/trade/item_v2.py +++ b/src/plugins/jx3/trade/item_v2.py @@ -2,11 +2,11 @@ from pathlib import Path from src.tools.utils.request import get_api, post_url -from src.tools.utils.common import convert_time, getCurrentTime +from src.tools.utils.time import convert_time, get_current_time from src.tools.generate import generate, get_uuid from src.tools.utils.path import ASSETS, CACHE, TOOLS, VIEWS -from src.tools.file import read, write -from src.tools.basic.data_server import Zone_mapping +from src.tools.utils.file import read, write +from src.tools.basic.server import Zone_mapping import datetime import json @@ -60,8 +60,8 @@ async def getRawName(alias_name: str): return False async def getItemHistory(standard_name: str) -> Tuple[List[int], List[str]]: - current_timestamp = getCurrentTime() - start_timestamp = getCurrentTime() - 3*30*24*60*60 # 3个月前 + current_timestamp = get_current_time() + start_timestamp = get_current_time() - 3*30*24*60*60 # 3个月前 data = await queryWj("https://www.aijx3.cn/api/wj/goods/getAvgGoodsPriceRecord", params={"goodsName":standard_name,"belongQf3":"", "endTime": convert_time(current_timestamp, "%Y-%m-%d"), "startTime": convert_time(start_timestamp, "%Y-%m-%d")}) data = data["data"] dates = [] @@ -95,7 +95,7 @@ async def queryWBLInfo(item_standard_name: str): wbl_data = [] for each_data in data["data"]["list"][0:6]: server = each_data["server_name"] - end_time = convert_time(getCurrentTime() + each_data["remaining_time"], "%Y-%m-%d") + end_time = convert_time(get_current_time() + each_data["remaining_time"], "%Y-%m-%d") price = str(each_data["single_unit_price"] / 100) + "元" wbl_data.append(template_wujia.replace("$date", end_time).replace("$server", server).replace("$price", price)) return "\n".join(wbl_data) diff --git a/src/plugins/jx3/trade/sl.py b/src/plugins/jx3/trade/sl.py index 5ca3352c3..bd2fda849 100644 --- a/src/plugins/jx3/trade/sl.py +++ b/src/plugins/jx3/trade/sl.py @@ -2,7 +2,7 @@ from src.tools.utils.request import post_url from src.tools.utils.path import ASSETS, CACHE, VIEWS -from src.tools.file import read, write +from src.tools.utils.file import read, write from src.tools.generate import get_uuid, generate import json diff --git a/src/plugins/jx3/trade/wufeng.py b/src/plugins/jx3/trade/wufeng.py index 638462a3d..4993083f7 100644 --- a/src/plugins/jx3/trade/wufeng.py +++ b/src/plugins/jx3/trade/wufeng.py @@ -3,12 +3,12 @@ from nonebot.adapters.onebot.v11 import MessageSegment as ms from src.tools.utils.request import get_api, get_content -from src.tools.utils.common import convert_time, getCurrentTime +from src.tools.utils.time import convert_time, get_current_time from src.tools.generate import generate, get_uuid from src.tools.utils.path import ASSETS, CACHE, TOOLS, VIEWS -from src.tools.file import read, write -from src.tools.basic.data_server import server_mapping -from src.tools.basic.msg import PROMPT +from src.tools.utils.file import read, write +from src.tools.basic.server import server_mapping +from src.tools.basic.prompts import PROMPT from .sl import convertAttrs from .api import toCoinImage, convert, template_msgbox, template_table @@ -161,7 +161,7 @@ async def getAllServerWufengImg(raw: str): name = data["Name"] if (not currentStatus or yesterdayFlag) and detailData["data"]["prices"] == None: if not yesterdayFlag: - toReplace_word = [["$icon", icon], ["$color", color], ["$name", name + f"({server})
" + " ".join(getAttrs(data["attributes"])) + ""], ["$time", convert_time(getCurrentTime(), "%m月%d日 %H:%M:%S")], ["$limit", "N/A"], ["$price", "没有数据"]] + toReplace_word = [["$icon", icon], ["$color", color], ["$name", name + f"({server})
" + " ".join(getAttrs(data["attributes"])) + ""], ["$time", convert_time(get_current_time(), "%m月%d日 %H:%M:%S")], ["$limit", "N/A"], ["$price", "没有数据"]] table_content = template_table for word in toReplace_word: table_content = table_content.replace(word[0], word[1]) @@ -169,7 +169,7 @@ async def getAllServerWufengImg(raw: str): continue else: avg = convert(current["AvgPrice"]) - toReplace_word = [["$icon", icon], ["$color", color], ["$name", name + f"({server})
" + " ".join(getAttrs(data["attributes"])) + ""], ["$time", convert_time(getCurrentTime(), "%m月%d日 %H:%M:%S")], ["$limit", "N/A"], ["$price", toCoinImage(avg)]] + toReplace_word = [["$icon", icon], ["$color", color], ["$name", name + f"({server})
" + " ".join(getAttrs(data["attributes"])) + ""], ["$time", convert_time(get_current_time(), "%m月%d日 %H:%M:%S")], ["$limit", "N/A"], ["$price", toCoinImage(avg)]] table_content = template_table for word in toReplace_word: table_content = table_content.replace(word[0], word[1]) diff --git a/src/plugins/majsoul/__init__.py b/src/plugins/majsoul/__init__.py index 67a29947b..1f125a82f 100644 --- a/src/plugins/majsoul/__init__.py +++ b/src/plugins/majsoul/__init__.py @@ -3,7 +3,7 @@ from nonebot.params import CommandArg from nonebot.adapters.onebot.v11 import GroupMessageEvent, MessageSegment as ms -from src.tools.file import get_content_local +from src.tools.utils.file import get_content_local from .koromo import * diff --git a/src/plugins/majsoul/koromo.py b/src/plugins/majsoul/koromo.py index 0b57ef3ed..3edf37062 100644 --- a/src/plugins/majsoul/koromo.py +++ b/src/plugins/majsoul/koromo.py @@ -2,8 +2,8 @@ from typing import Optional, Union from src.tools.utils.request import get_api -from src.tools.utils.common import convert_time, getCurrentTime -from src.tools.file import read, write +from src.tools.utils.time import convert_time, get_current_time +from src.tools.utils.file import read, write from src.tools.utils.path import ASSETS, CACHE, VIEWS from src.tools.generate import get_uuid, generate @@ -124,7 +124,7 @@ async def player_pt(name: str = "", mode="16.12.9.15.11.8"): pid = await get_id_by_name(name) if type(pid) == type([]): return pid[0] - final_url = koromo_api_ps.format(player_id=pid, end_timestamp=str(getCurrentTime()*1000), start_timestamp="1262304000000", mode=mode) + final_url = koromo_api_ps.format(player_id=pid, end_timestamp=str(get_current_time()*1000), start_timestamp="1262304000000", mode=mode) data = await get_api(final_url) rank = getRank(data["level"]["id"]) level = max_points[rank] if rank[0] != "魂" else "20.0" @@ -140,7 +140,7 @@ async def get_records(name: str = "", mode: str = "16.12.9.15.11.8") -> Union[Op pid = await get_id_by_name(name) if type(pid) == type([]): return pid[0] - final_url = koromo_api_pr.format(player_id=pid, end_timestamp=str(getCurrentTime()*1000), start_timestamp="1262304000000", mode=mode) + final_url = koromo_api_pr.format(player_id=pid, end_timestamp=str(get_current_time()*1000), start_timestamp="1262304000000", mode=mode) data = await get_api(final_url) if data == {}: return "PID输入错误,或该玩家没有任何记录!" diff --git a/src/plugins/music/__init__.py b/src/plugins/music/__init__.py index a04604c27..23bbad962 100644 --- a/src/plugins/music/__init__.py +++ b/src/plugins/music/__init__.py @@ -1,15 +1,11 @@ -from pathlib import Path - from nonebot import on_command from nonebot.adapters import Message from nonebot.params import CommandArg, Arg from nonebot.typing import T_State from nonebot.adapters.onebot.v11 import GroupMessageEvent, MessageSegment as ms -from nonebot.log import logger from src.tools.utils.path import CACHE -from src.tools.utils.common import checknumber -from src.tools.generate import get_uuid +from src.tools.utils.num import checknumber from src.plugins.sign import Sign diff --git a/src/plugins/op/__init__.py b/src/plugins/op/__init__.py index 54638ac63..cd5958b87 100644 --- a/src/plugins/op/__init__.py +++ b/src/plugins/op/__init__.py @@ -5,8 +5,8 @@ from src.tools.permission import checker, error, get_all_admin from src.tools.config import Config -from src.tools.utils.common import checknumber -from src.tools.data import group_db +from src.tools.utils.num import checknumber +from src.tools.database import group_db # 机器人管理员权限设置 op = on_command("setop", aliases={"admin", "setadmin"}, force_whitespace=True, priority=5) diff --git a/src/plugins/railway/__init__.py b/src/plugins/railway/__init__.py index 53a8f052a..293eb52b4 100644 --- a/src/plugins/railway/__init__.py +++ b/src/plugins/railway/__init__.py @@ -3,7 +3,7 @@ from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment as ms from nonebot.params import CommandArg -from src.tools.file import get_content_local +from src.tools.utils.file import get_content_local from .crt import * diff --git a/src/plugins/railway/crt.py b/src/plugins/railway/crt.py index aa4fb3072..690ac18ea 100644 --- a/src/plugins/railway/crt.py +++ b/src/plugins/railway/crt.py @@ -2,7 +2,7 @@ from urllib.parse import quote from src.tools.utils.request import get_api -from src.tools.file import read, write +from src.tools.utils.file import read, write from src.tools.generate import get_uuid, generate from src.tools.utils.path import ASSETS, CACHE, VIEWS diff --git a/src/plugins/sign/__init__.py b/src/plugins/sign/__init__.py index a0910b24e..966698fcb 100644 --- a/src/plugins/sign/__init__.py +++ b/src/plugins/sign/__init__.py @@ -3,8 +3,8 @@ from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment as ms from nonebot.params import CommandArg -from src.tools.file import write -from src.tools.utils.common import checknumber +from src.tools.utils.file import write +from src.tools.utils.num import checknumber from src.tools.permission import checker, error from src.tools.utils.path import CLOCK diff --git a/src/plugins/sign/manage.py b/src/plugins/sign/manage.py index 42e15b027..39f281eca 100644 --- a/src/plugins/sign/manage.py +++ b/src/plugins/sign/manage.py @@ -1,6 +1,6 @@ from nonebot.adapters.onebot.v11 import MessageSegment as ms -from src.tools.file import read, write +from src.tools.utils.file import read, write from src.tools.utils.path import CLOCK import random diff --git a/src/plugins/wiki/__init__.py b/src/plugins/wiki/__init__.py index 2020b4cd9..b1cc4b71c 100644 --- a/src/plugins/wiki/__init__.py +++ b/src/plugins/wiki/__init__.py @@ -4,11 +4,11 @@ from nonebot.params import CommandArg, Arg from nonebot.typing import T_State -from src.tools.file import read -from src.tools.utils import checknumber +from src.tools.utils.file import read +from src.tools.utils.num import checknumber from src.tools.permission import checker, error -from src.tools.basic.group_opeator import getGroupSettings, setGroupSettings -from src.tools.basic.msg import PROMPT +from src.tools.basic.group import getGroupSettings, setGroupSettings +from src.tools.basic.prompts import PROMPT from src.tools.utils.path import DATA from .wikilib import wiki as wiki_ diff --git a/src/plugins/wiki/wikilib.py b/src/plugins/wiki/wikilib.py index 125fac376..15a1d2f2d 100644 --- a/src/plugins/wiki/wikilib.py +++ b/src/plugins/wiki/wikilib.py @@ -1,7 +1,7 @@ from urllib import parse from bs4 import BeautifulSoup -from src.tools.utils import get_api, get_url +from src.tools.utils.request import get_api, get_url import json import re diff --git a/src/tools/__init__.py b/src/tools/__init__.py deleted file mode 100644 index afe16a423..000000000 --- a/src/tools/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .file import * -from .generate import * -from .permission import * \ No newline at end of file diff --git a/src/tools/basic/group_opeator.py b/src/tools/basic/group.py similarity index 97% rename from src/tools/basic/group_opeator.py rename to src/tools/basic/group.py index 14837244a..f4372c878 100644 --- a/src/tools/basic/group_opeator.py +++ b/src/tools/basic/group.py @@ -4,7 +4,7 @@ import os import pathlib2 -from ..data import group_db, GroupSettings +from src.tools.database import group_db, GroupSettings tools_path = f"{os.getcwd()}/src/tools" diff --git a/src/tools/basic/message_process.py b/src/tools/basic/process.py similarity index 97% rename from src/tools/basic/message_process.py rename to src/tools/basic/process.py index 9ece58b12..6f6bdb19f 100644 --- a/src/tools/basic/message_process.py +++ b/src/tools/basic/process.py @@ -7,8 +7,8 @@ from nonebot.message import run_preprocessor, run_postprocessor from nonebot.params import RawCommand -from .group_opeator import getGroupSettings -from ..data import group_db, Population, BannedWordList +from .group import getGroupSettings +from ..database import group_db, Population, BannedWordList from ..config import Config from ..utils import get_api diff --git a/src/tools/basic/msg.py b/src/tools/basic/prompts.py similarity index 100% rename from src/tools/basic/msg.py rename to src/tools/basic/prompts.py diff --git a/src/tools/basic/data_server.py b/src/tools/basic/server.py similarity index 97% rename from src/tools/basic/data_server.py rename to src/tools/basic/server.py index ee02433ce..f1a1820f2 100644 --- a/src/tools/basic/data_server.py +++ b/src/tools/basic/server.py @@ -2,7 +2,7 @@ from src.tools.utils.path import TOOLS -from .group_opeator import getGroupSettings +from .group import getGroupSettings import json diff --git a/src/tools/data.py b/src/tools/database.py similarity index 100% rename from src/tools/data.py rename to src/tools/database.py diff --git a/src/tools/permission.py b/src/tools/permission.py index 2e948e7f5..4d50a99ff 100644 --- a/src/tools/permission.py +++ b/src/tools/permission.py @@ -1,6 +1,6 @@ from typing import Union, Any -from src.tools.data import group_db, Permission +from src.tools.database import group_db, Permission def get_all_admin() -> Permission: data: Union[Permission, Any] = group_db.where_one(Permission(), default=Permission()) diff --git a/src/tools/utils/__init__.py b/src/tools/utils/__init__.py index 169d7106c..3f73b40d1 100644 --- a/src/tools/utils/__init__.py +++ b/src/tools/utils/__init__.py @@ -1,3 +1,3 @@ -from .common import * +from .time import * from .request import * from .path import * \ No newline at end of file diff --git a/src/tools/utils/common.py b/src/tools/utils/common.py deleted file mode 100644 index 2170bdce9..000000000 --- a/src/tools/utils/common.py +++ /dev/null @@ -1,119 +0,0 @@ -from typing import Union - -from src.tools.file import write, read - -import re -import time -import datetime -import pathlib2 -import os - -tools_path = f"{os.getcwd()}/src/tools" - -def get_path(path: str) -> str: - t = pathlib2.Path(tools_path) - return t.parent.joinpath(path).__str__() -CLOCK = get_path("clock") - -def get_number(number): - """ - 返回参数的数值,默认返回0 - """ - if not checknumber(number): - return 0 - return int(number) - - -def get_number_with_default(number) -> tuple[int, bool]: - """ - 返回参数的数值,默认返回0 - 如果是默认值,则返回True - """ - if isinstance(number, str): - number = number.strip() - if not checknumber(number): - return 0, True - return int(number), False - - -def checknumber(value): - """ - 检查参数是否是数值 - """ - if value is None: - return False - if isinstance(value, str): - pattern = r"^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$" - return bool(re.match(pattern, value)) - if isinstance(value, int): - return True - return value.isdecimal() - - -def convert_time(timestamp: int, format: str = "%Y年%m月%d日 %H:%M:%S") -> Union[str, bool]: - if checknumber(timestamp): - try: - timestamp = int(timestamp) - except: - return False - """ - 时间转换,自适应时间长度。 - """ - if len(str(timestamp)) == 13: - time_local = time.localtime(timestamp / 1000) - elif len(str(timestamp)) == 10: - time_local = time.localtime(timestamp) - else: - class TimeLengthError(OSError): - ... - raise TimeLengthError("Length of timestamp cannot be approved!") - dt = time.strftime(format, time_local) - return dt - - -def nodetemp(nickname: str, qqnumber: str, message: str) -> dict: - return {"type": "node", "data": {"name": nickname, "uin": qqnumber, "content": message}} - - -def prefix(event, prefix): - if str(event.raw_message)[0] != prefix: - return False - return True - -def getCurrentTime(): - return int(datetime.datetime.now().timestamp()) - -def getRelateTime(current, goal): - current_time = int(current) - timeGet_int = int(goal) - datetime_1 = datetime.datetime.fromtimestamp(current_time) - datetime_2 = datetime.datetime.fromtimestamp(timeGet_int) - timedelta = datetime_2 - datetime_1 - days = int(abs(timedelta.total_seconds()) // 86400) - hours = int((abs(timedelta.total_seconds()) - days*86400) // 3600) - minutes = int((abs(timedelta.total_seconds()) - days*86400 - hours*3600) // 60) - days = str(days) - hours = str(hours) - minutes = str(minutes) - if len(days) == 1: - days = "0" + days - if len(hours) == 1: - hours = "0" + hours - if len(minutes) == 1: - minutes = "0" + minutes - if current_time >= timeGet_int: - flag = "前" - msg = f"{days}天{hours}时{minutes}分" - else: - flag = "后" - msg = f"{days}天{hours}时{minutes}分"[1:] - relateTime = msg + flag - return relateTime - -def record_info(record_content: str): - msg = convert_time(getCurrentTime(), "[%Y-%m-%d %H:%M:%S] "+ record_content) - if not isinstance(msg, str): - return - raw = read(CLOCK + "/logs/InkarSuki.log") - msg = raw + "\n" + msg - write(CLOCK + "/logs/InkarSuki.log", msg) \ No newline at end of file diff --git a/src/tools/file.py b/src/tools/utils/file.py similarity index 100% rename from src/tools/file.py rename to src/tools/utils/file.py diff --git a/src/tools/utils/num.py b/src/tools/utils/num.py new file mode 100644 index 000000000..b657b688a --- /dev/null +++ b/src/tools/utils/num.py @@ -0,0 +1,14 @@ +import re + +def checknumber(value): + """ + 检查参数是否是数值 + """ + if value is None: + return False + if isinstance(value, str): + pattern = r"^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$" + return bool(re.match(pattern, value)) + if isinstance(value, int): + return True + return value.isdecimal() diff --git a/src/tools/utils/time.py b/src/tools/utils/time.py new file mode 100644 index 000000000..2fe16ea1e --- /dev/null +++ b/src/tools/utils/time.py @@ -0,0 +1,56 @@ +from typing import Union + +from src.tools.utils.num import checknumber + +import time +import datetime + +def convert_time(timestamp: int, format: str = "%Y年%m月%d日 %H:%M:%S") -> Union[str, bool]: + if checknumber(timestamp): + try: + timestamp = int(timestamp) + except: + return False + """ + 时间转换,自适应时间长度。 + """ + if len(str(timestamp)) == 13: + time_local = time.localtime(timestamp / 1000) + elif len(str(timestamp)) == 10: + time_local = time.localtime(timestamp) + else: + class TimeLengthError(OSError): + ... + raise TimeLengthError("Length of timestamp cannot be approved!") + dt = time.strftime(format, time_local) + return dt + +def get_current_time(): + return int(datetime.datetime.now().timestamp()) + +def get_relate_time(current, goal): + current_time = int(current) + timeGet_int = int(goal) + datetime_1 = datetime.datetime.fromtimestamp(current_time) + datetime_2 = datetime.datetime.fromtimestamp(timeGet_int) + timedelta = datetime_2 - datetime_1 + days = int(abs(timedelta.total_seconds()) // 86400) + hours = int((abs(timedelta.total_seconds()) - days*86400) // 3600) + minutes = int((abs(timedelta.total_seconds()) - days*86400 - hours*3600) // 60) + days = str(days) + hours = str(hours) + minutes = str(minutes) + if len(days) == 1: + days = "0" + days + if len(hours) == 1: + hours = "0" + hours + if len(minutes) == 1: + minutes = "0" + minutes + if current_time >= timeGet_int: + flag = "前" + msg = f"{days}天{hours}时{minutes}分" + else: + flag = "后" + msg = f"{days}天{hours}时{minutes}分"[1:] + relateTime = msg + flag + return relateTime \ No newline at end of file