mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-15 01:00:00 +08:00
Develop: 完全使用 ruff 替代 isort 与 black (#1757)
* 🚨 完全使用 ruff 替代 isort 与 black * 🚨 ruff lint&format
This commit is contained in:
@@ -1,20 +1,7 @@
|
||||
import os
|
||||
import time
|
||||
|
||||
from nonebot.rule import to_me
|
||||
from nonebot.utils import run_sync
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_session import EventSession
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot_plugin_alconna import Alconna, on_alconna
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.enum import PluginType
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
from zhenxun.configs.path_config import TEMP_PATH
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
from zhenxun.utils.utils import ResourceDirManager
|
||||
from zhenxun.utils.enum import PluginType
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="Bot管理",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from nonebot.adapters import Bot
|
||||
import nonebot_plugin_alconna as alc
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
# from nonebot.adapters.discord import Bot as DiscordBot
|
||||
# from nonebot.adapters.dodo import Bot as DodoBot
|
||||
@@ -8,11 +7,12 @@ from nonebot_plugin_session import EventSession
|
||||
# from nonebot.adapters.onebot.v11 import Bot as v11Bot
|
||||
# from nonebot.adapters.onebot.v12 import Bot as v12Bot
|
||||
from nonebot_plugin_alconna import Image, UniMsg
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.common_utils import CommonUtils
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
from zhenxun.utils.platform import PlatformUtils
|
||||
from zhenxun.utils.common_utils import CommonUtils
|
||||
|
||||
|
||||
class BroadcastManage:
|
||||
|
||||
@@ -47,10 +47,10 @@ async def _(session: EventSession):
|
||||
await MessageUtils.build_message("开始清理临时数据...").send()
|
||||
size = await _clear_data()
|
||||
await MessageUtils.build_message(
|
||||
"共清理了 {:.2f}MB 的数据...".format(size / 1024 / 1024)
|
||||
f"共清理了 {size / 1024 / 1024:.2f}MB 的数据..."
|
||||
).send()
|
||||
logger.info(
|
||||
"清理临时数据完成,共清理了 {:.2f}MB 的数据...".format(size / 1024 / 1024),
|
||||
f"清理临时数据完成,共清理了 {size / 1024 / 1024:.2f}MB 的数据...",
|
||||
session=session,
|
||||
)
|
||||
|
||||
@@ -79,9 +79,7 @@ def _clear_data() -> float:
|
||||
"清理临时数据",
|
||||
e=e,
|
||||
)
|
||||
logger.debug(
|
||||
"清理临时文件夹大小: {:.2f}MB".format(size / 1024 / 1024), "清理临时数据"
|
||||
)
|
||||
logger.debug(f"清理临时文件夹大小: {size / 1024 / 1024:.2f}MB", "清理临时数据")
|
||||
return float(size)
|
||||
|
||||
|
||||
@@ -93,6 +91,6 @@ def _clear_data() -> float:
|
||||
async def _():
|
||||
size = await _clear_data()
|
||||
logger.info(
|
||||
"自动清理临时数据完成,共清理了 {:.2f}MB 的数据...".format(size / 1024 / 1024),
|
||||
f"自动清理临时数据完成,共清理了 {size / 1024 / 1024:.2f}MB 的数据...",
|
||||
"定时任务",
|
||||
)
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
from tortoise import Tortoise
|
||||
from nonebot import on_command
|
||||
from nonebot.rule import to_me
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot.rule import to_me
|
||||
from nonebot_plugin_alconna import UniMsg
|
||||
from nonebot_plugin_session import EventSession
|
||||
from tortoise import Tortoise
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.enum import PluginType
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
from zhenxun.models.ban_console import BanConsole
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.enum import PluginType
|
||||
from zhenxun.utils.image_utils import ImageTemplate
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="数据库操作",
|
||||
@@ -57,7 +57,8 @@ SELECT name FROM sqlite_master WHERE type='table';
|
||||
SELECT_TABLE_PSQL_SQL = """
|
||||
select a.tablename as name,d.description as desc from pg_tables a
|
||||
left join pg_class c on relname=tablename
|
||||
left join pg_description d on oid=objoid and objsubid=0 where a.schemaname = 'public'
|
||||
left join pg_description d on oid=objoid and objsubid=0
|
||||
where a.schemaname = 'public'
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ from zhenxun.configs.utils import PluginExtraData
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.enum import PluginType
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
from zhenxun.utils.rules import admin_check, ensure_group
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="好友群组列表",
|
||||
@@ -72,7 +71,7 @@ async def _(
|
||||
msg = f"| UID | 昵称 | 共{len(fl)}个好友\n" + msg
|
||||
await MessageUtils.build_message(msg).send()
|
||||
logger.info("查看好友列表", "好友列表", session=session)
|
||||
except (ApiNotAvailable, AttributeError) as e:
|
||||
except (ApiNotAvailable, AttributeError):
|
||||
await MessageUtils.build_message("Api未实现...").send()
|
||||
except Exception as e:
|
||||
logger.error("好友列表发生错误", "好友列表", session=session, e=e)
|
||||
@@ -92,7 +91,7 @@ async def _(
|
||||
msg = f"| GID | 名称 | 共{len(gl)}个群组\n" + msg
|
||||
await MessageUtils.build_message(msg).send()
|
||||
logger.info("查看群组列表", "群组列表", session=session)
|
||||
except (ApiNotAvailable, AttributeError) as e:
|
||||
except (ApiNotAvailable, AttributeError):
|
||||
await MessageUtils.build_message("Api未实现...").send()
|
||||
except Exception as e:
|
||||
logger.error("查看群组列表发生错误", "群组列表", session=session, e=e)
|
||||
|
||||
@@ -204,8 +204,8 @@ async def _(bot: Bot, session: EventSession, arparma: Arparma, group_id: int):
|
||||
await MessageUtils.build_message(f"退出群组 {group_id} 成功!").send()
|
||||
await GroupConsole.filter(group_id=group_id).delete()
|
||||
except Exception as e:
|
||||
logger.error(f"退出群组失败", "退群", session=session, target=group_id, e=e)
|
||||
logger.error("退出群组失败", "退群", session=session, target=group_id, e=e)
|
||||
await MessageUtils.build_message(f"退出群组 {group_id} 失败...").send()
|
||||
else:
|
||||
# TODO: 其他平台的退群操作
|
||||
await MessageUtils.build_message(f"暂未支持退群操作...").send()
|
||||
await MessageUtils.build_message("暂未支持退群操作...").send()
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_session import EventSession, SessionLevel
|
||||
from nonebot_plugin_alconna import (
|
||||
At,
|
||||
Alconna,
|
||||
Args,
|
||||
Arparma,
|
||||
At,
|
||||
Match,
|
||||
Option,
|
||||
Alconna,
|
||||
Arparma,
|
||||
Subcommand,
|
||||
on_alconna,
|
||||
)
|
||||
from nonebot_plugin_session import EventSession, SessionLevel
|
||||
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
from zhenxun.models.level_user import LevelUser
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.enum import PluginType
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
from zhenxun.models.level_user import LevelUser
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="用户权限管理",
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_session import EventSession
|
||||
from nonebot_plugin_alconna import Alconna, Arparma, on_alconna
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.configs.config import Config
|
||||
from zhenxun.configs.utils import PluginExtraData, RegisterConfig
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.enum import PluginType
|
||||
from zhenxun.utils.exception import EmptyError
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
from zhenxun.configs.utils import RegisterConfig, PluginExtraData
|
||||
|
||||
from .normal_help import build_help
|
||||
from .config import SUPERUSER_HELP_IMAGE
|
||||
from .normal_help import build_help
|
||||
from .zhenxun_help import build_html_help
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from pydantic import BaseModel
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from pydantic import BaseModel
|
||||
|
||||
from zhenxun.models.plugin_info import PluginInfo
|
||||
from zhenxun.configs.path_config import IMAGE_PATH
|
||||
from zhenxun.models.plugin_info import PluginInfo
|
||||
|
||||
SUPERUSER_HELP_IMAGE = IMAGE_PATH / "SUPERUSER_HELP.png"
|
||||
if SUPERUSER_HELP_IMAGE.exists():
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
from PIL.ImageFont import FreeTypeFont
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from PIL.ImageFont import FreeTypeFont
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.models.task_info import TaskInfo
|
||||
from zhenxun.models.plugin_info import PluginInfo
|
||||
from zhenxun.models.task_info import TaskInfo
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils._build_image import BuildImage
|
||||
from zhenxun.utils.image_utils import text2image, group_image, build_sort_image
|
||||
from zhenxun.utils.image_utils import build_sort_image, group_image, text2image
|
||||
|
||||
from .utils import get_plugins
|
||||
from .config import SUPERUSER_HELP_IMAGE
|
||||
from .utils import get_plugins
|
||||
|
||||
|
||||
async def build_usage_des_image(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import nonebot
|
||||
|
||||
from zhenxun.models.plugin_info import PluginInfo
|
||||
from zhenxun.utils.enum import PluginType
|
||||
from zhenxun.utils.exception import EmptyError
|
||||
from zhenxun.models.plugin_info import PluginInfo
|
||||
|
||||
from .config import PluginData
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from nonebot_plugin_htmlrender import template_to_pic
|
||||
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.configs.path_config import TEMPLATE_PATH
|
||||
from zhenxun.models.task_info import TaskInfo
|
||||
from zhenxun.utils._build_image import BuildImage
|
||||
from zhenxun.configs.path_config import TEMPLATE_PATH
|
||||
|
||||
from .utils import get_plugins
|
||||
from .config import SUPERUSER_HELP_IMAGE
|
||||
from .utils import get_plugins
|
||||
|
||||
|
||||
async def get_task() -> dict[str, str] | None:
|
||||
|
||||
Reference in New Issue
Block a user