Dev (#43)
* 滚木 * feat: 重构核心架构,增强类型安全与插件管理 本次提交对核心模块进行了深度重构,引入 Pydantic 增强配置管理的类型安全性,并全面优化了插件管理系统。 主要变更详情: 1. 核心架构与配置 - 重构配置加载模块:引入 Pydantic 模型 (`core/config_models.py`),提供严格的配置项类型检查、验证及默认值管理。 - 统一模块结构:规范化模块导入路径,移除冗余的 `__init__.py` 文件,提升项目结构的清晰度。 - 性能优化:集成 Redis 缓存支持 (`RedisManager`),有效降低高频 API 调用开销,提升响应速度。 2. 插件系统升级 - 实现热重载机制:新增插件文件变更监听功能,支持开发过程中自动重载插件,提升开发效率。 - 优化生命周期管理:改进插件加载与卸载逻辑,支持精确卸载指定插件及其关联的命令、事件处理器和定时任务。 3. 功能特性增强 - 新增媒体 API:引入 `MediaAPI` 模块,封装图片、语音等富媒体资源的获取与处理接口。 - 完善权限体系:重构权限管理系统,实现管理员与操作员的分级控制,支持更细粒度的命令权限校验。 4. 代码质量与稳定性 - 全面类型修复:解决 `mypy` 静态类型检查发现的大量类型错误(包括 `CommandManager`、`EventFactory` 及 `Bot` API 签名不匹配问题)。 - 增强错误处理:优化消息处理管道的异常捕获机制,完善关键路径的日志记录,提升系统运行稳定性。 * feat: 添加测试用例并优化代码结构 refactor(permission_manager): 调整初始化顺序和逻辑 fix(admin_manager): 修复初始化逻辑和目录创建问题 feat(ws): 优化Bot实例初始化条件 feat(message): 增强MessageSegment功能并添加测试 feat(events): 支持字符串格式的消息解析 test: 添加核心功能测试用例 refactor(plugin_manager): 改进插件路径处理 style: 清理无用导入和代码 chore: 更新依赖项 * refactor(handler): 移除TYPE_CHECKING并直接导入Bot类 简化类型注解,直接导入Bot类而非使用TYPE_CHECKING条件导入,提高代码可读性和维护性 * fix(command_manager): 修复插件卸载时元信息移除不精确的问题 修复 CommandManager 中 unload_plugin 方法移除插件元信息时使用 startswith 导致可能误删其他插件的问题,改为精确匹配 同时调整相关测试用例验证精确匹配行为 * refactor: 清理未使用的导入和更新文档结构 docs: 添加config_models.py到项目结构文档 docs: 调整数据目录位置到core/data下 docs: 更新权限管理器文档描述 * 文档更新 * 更新thpic插件 支持一次返回多张图 * feat: 添加测试覆盖率并修复相关问题 refactor(redis_manager): 移除冗余的ConnectionError处理 refactor(event_handler): 优化Bot类型注解 refactor(factory): 移除未使用的GroupCardNoticeEvent test: 添加全面的单元测试覆盖 - 添加test_import.py测试模块导入 - 添加test_debug.py测试插件加载调试 - 添加test_plugin_error.py测试错误处理 - 添加test_config_loader.py测试配置加载 - 添加test_redis_manager.py测试Redis管理 - 添加test_bot.py测试Bot功能 - 扩展test_models.py测试消息模型 - 添加test_plugin_manager_coverage.py测试插件管理 - 添加test_executor.py测试代码执行器 - 添加test_ws.py测试WebSocket - 添加test_api.py测试API接口 - 添加test_core_managers.py测试核心管理模块 fix(plugin_manager): 修复插件加载日志变量问题 覆盖率已到达86%(忽略插件) * 更新/help指令,现在会发送图片 * feat(help): 重构帮助系统为图片渲染模式 添加浏览器管理器和图片管理器,用于通过 Playwright 渲染帮助菜单为图片 重构命令管理器以支持图片缓存和同步功能 添加 HTML 模板用于帮助菜单渲染 * build: 更新依赖文件 requirements.txt * build: 更新依赖文件 * feat: 添加性能优化和架构文档,更新依赖和核心模块 refactor(browser_manager): 实现页面池机制以提升性能 refactor(image_manager): 添加模板缓存并集成页面池 refactor(bili_parser): 迁移到异步HTTP请求并实现会话复用 docs: 新增性能优化、架构设计和最佳实践文档 chore: 更新requirements.txt添加新依赖 * docs: 更新文档内容并优化语言风格 重构所有文档内容,使用更简洁直接的语言风格 更新架构、插件开发、部署等核心文档 优化代码示例和图表说明 统一术语和格式规范 * docs: 更新文档内容,简化语言并修正格式 - 简化插件开发指南中的描述,移除冗余内容 - 调整部署文档中的Python版本说明 - 优化最佳实践文档的措辞和格式 - 更新性能优化文档,删除不准确的数据 - 重构核心概念文档,使用更简洁的语言 - 修正README中的项目描述和技术栈说明 - 更新快速上手文档,简化安装步骤 - 调整事件流转文档的描述方式 - 简化架构文档内容 - 更新指令处理文档,添加参数注入示例 - 优化单例管理器文档的表述 * refactor(core): 优化权限管理和事件模型 - 重构 AdminManager 和 PermissionManager 以 Redis 为主要数据源 - 为所有事件模型添加 slots=True 提升性能 - 更新文档说明 Mypyc 编译注意事项 - 清理测试和调试文件 - 移动静态资源到 web_static 目录 * feat: 添加模块编译脚本和导出依赖功能 refactor(events): 移除数据类的slots参数以提升兼容性 build: 更新requirements.txt依赖列表 * docs: 更新性能优化文档并修复命令管理器帮助输出 更新性能优化相关文档,详细说明 Python 3.14 JIT 编译器的使用方法和原理,补充与 Mypyc 的互补策略。同时修复命令管理器中帮助信息的输出方式,移除图片发送仅保留文本输出。 调整部署文档结构,明确两种性能优化方案(AOT 和 JIT)的配置方法和适用场景。完善架构文档中关于 JIT 的原理和启用方式说明。 * feat(help): 重构帮助菜单界面并优化样式 refactor(bili_parser): 修复 API 响应 content-type 问题 fix(command_manager): 添加帮助图片获取的错误处理 docs(deployment): 简化部署文档并移除 JIT 相关内容 * feat: 新增自动同意请求插件和API文档 docs: 更新文档结构和内容 * refactor(scripts): 重构并优化脚本文件结构 feat(scripts): 添加Python环境检查脚本 feat(scripts): 增强依赖导出脚本功能 perf(plugins/bili_parser): 优化B站解析器性能和代码结构 style(plugins/bili_parser): 统一代码风格和常量命名 * fix(scripts): 修复编码问题并添加错误追踪 在compile_machine_code.py中添加utf-8编码设置以避免潜在编码问题 添加traceback.print_exc()以在编译失败时打印完整错误堆栈 更新.gitignore以忽略config.toml文件 * feat(性能分析): 实现性能分析工具模块并添加相关测试 添加性能分析工具模块,包括时间测量、内存分析和性能统计功能 添加测试文件和示例配置,完善性能分析工具的使用场景 在工具模块中实现单例装饰器并导出到__init__.py * feat(douyin_parser): 新增抖音视频解析插件 refactor(performance): 移除未使用的asyncio导入并优化性能测试 style(compile_modules): 修正字符串引号格式 chore: 删除废弃的编译脚本和临时文件 fix(bili_parser): 增强B站链接解析的健壮性 refactor(singleton): 重构单例模式实现 docs: 更新配置文件和事件模型注释 * feat: 添加抖音视频解析插件并优化代码结构 添加抖音视频解析插件,支持自动解析抖音分享链接并提取视频信息。优化现有代码结构,包括: - 重构单例模式实现 - 移除未使用的导入和文件 - 修复性能测试脚本中的异步调用 - 优化消息事件模型中的权限常量定义 - 改进编译脚本的错误处理 - 增强B站解析插件的稳定性 同时清理了多个废弃脚本和临时文件,提升代码可维护性。 * 1 * Delete core/data/temp/help_menu.png * fix(权限管理): 增强权限检查的类型安全并修复权限引用 修复权限检查中可能传入非Permission类型导致的错误,将echo插件的权限引用从MessageEvent.ADMIN迁移到Permission.ADMIN * redis取消tls * feat(github_parser): 添加GitHub仓库信息查询功能 - 新增github_parser插件,支持通过命令或自动解析链接查询GitHub仓库信息 - 添加github_repo.html模板用于渲染仓库信息图片 - 优化图片管理器支持高质量截图和CSS缩放 - 重构消息事件类权限常量定义方式 - 更新帮助页面样式为三列布局并优化响应式设计 --------- Co-authored-by: baby20162016 <2185823427@qq.com> Co-authored-by: web vscode <youremail@example.com>
This commit is contained in:
32
core/managers/1.py
Normal file
32
core/managers/1.py
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
class 真鸭子:
|
||||
def 叫(self):
|
||||
print("嘎嘎嘎")
|
||||
|
||||
def 跑(self):
|
||||
print("鸭子摇摇摆摆跑")
|
||||
|
||||
class 玩具鸭子:
|
||||
def 叫(self):
|
||||
print("玩具鸭发出嘎嘎声")
|
||||
|
||||
def 跑(self):
|
||||
print("玩具鸭轮子咕噜噜跑")
|
||||
|
||||
class 小猫:
|
||||
def 叫(self):
|
||||
print("喵喵喵")
|
||||
def 跑(self):
|
||||
print("猫咪跑跑")
|
||||
|
||||
def 逗鸭子(鸭子一样的东西):
|
||||
鸭子一样的东西.叫()
|
||||
鸭子一样的东西.跑()
|
||||
|
||||
逗鸭子(真鸭子())
|
||||
|
||||
逗鸭子(玩具鸭子())
|
||||
|
||||
逗鸭子(小猫())
|
||||
|
||||
鸭子 = 1
|
||||
@@ -71,15 +71,21 @@ class ImageManager:
|
||||
return None
|
||||
|
||||
try:
|
||||
# 设置视口
|
||||
await page.set_viewport_size({"width": 650, "height": 100})
|
||||
width = 1920
|
||||
height = 1080
|
||||
await page.set_viewport_size({"width": width, "height": height})
|
||||
|
||||
# 加载内容
|
||||
await page.set_content(html_content)
|
||||
await page.wait_for_selector("body")
|
||||
|
||||
# 截图
|
||||
screenshot_args = {'full_page': True, 'type': image_type}
|
||||
|
||||
screenshot_args = {
|
||||
'full_page': True,
|
||||
'type': image_type,
|
||||
'omit_background': False,
|
||||
'scale': 'css'
|
||||
}
|
||||
if image_type == 'jpeg':
|
||||
screenshot_args['quality'] = quality
|
||||
|
||||
|
||||
@@ -152,6 +152,12 @@ class PermissionManager(Singleton):
|
||||
检查用户是否具有指定权限级别
|
||||
"""
|
||||
user_permission = await self.get_user_permission(user_id)
|
||||
|
||||
# 增强类型检查,防止将property对象等错误类型传递进来
|
||||
if not isinstance(required_permission, Permission):
|
||||
logger.error(f"权限检查失败:required_permission 不是 Permission 枚举类型,而是 {type(required_permission).__name__}")
|
||||
return False
|
||||
|
||||
return user_permission >= required_permission
|
||||
|
||||
async def get_all_user_permissions(self) -> Dict[str, str]:
|
||||
|
||||
@@ -33,7 +33,8 @@ class RedisManager:
|
||||
port=port,
|
||||
db=db,
|
||||
password=password,
|
||||
decode_responses=True
|
||||
decode_responses=True,
|
||||
ssl=False
|
||||
)
|
||||
if await self._redis.ping():
|
||||
logger.success("Redis 连接成功!")
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"""
|
||||
|
||||
# 导出核心工具
|
||||
from .logger import logger, ModuleLogger, log_exception
|
||||
from .logger import logger
|
||||
from .exceptions import *
|
||||
from .json_utils import *
|
||||
from .singleton import singleton
|
||||
@@ -20,12 +20,9 @@ from .performance import (
|
||||
performance_stats,
|
||||
global_stats
|
||||
)
|
||||
from .error_codes import ErrorCode, get_error_message, create_error_response, exception_to_error_response
|
||||
|
||||
__all__ = [
|
||||
'logger',
|
||||
'ModuleLogger',
|
||||
'log_exception',
|
||||
'timeit',
|
||||
'profile',
|
||||
'aprofile',
|
||||
@@ -37,9 +34,5 @@ __all__ = [
|
||||
'global_stats',
|
||||
'run_in_thread_pool',
|
||||
'initialize_executor',
|
||||
'singleton',
|
||||
'ErrorCode',
|
||||
'get_error_message',
|
||||
'create_error_response',
|
||||
'exception_to_error_response'
|
||||
'singleton'
|
||||
]
|
||||
|
||||
@@ -72,20 +72,7 @@ class MessageEvent(OneBotEvent):
|
||||
def post_type(self) -> str:
|
||||
return EventType.MESSAGE
|
||||
|
||||
@property
|
||||
def ADMIN(self) -> Permission:
|
||||
"""权限级别常量,用于装饰器参数"""
|
||||
return MESSAGE_EVENT_ADMIN
|
||||
|
||||
@property
|
||||
def OP(self) -> Permission:
|
||||
"""权限级别常量,用于装饰器参数"""
|
||||
return MESSAGE_EVENT_OP
|
||||
|
||||
@property
|
||||
def USER(self) -> Permission:
|
||||
"""权限级别常量,用于装饰器参数"""
|
||||
return MESSAGE_EVENT_USER
|
||||
|
||||
async def reply(self, message: Union[str, "MessageSegment", List["MessageSegment"]], auto_escape: bool = False):
|
||||
"""
|
||||
@@ -97,6 +84,12 @@ class MessageEvent(OneBotEvent):
|
||||
raise NotImplementedError("reply method must be implemented by subclasses")
|
||||
|
||||
|
||||
# 在类定义之后添加权限常量作为类变量
|
||||
MessageEvent.ADMIN = MESSAGE_EVENT_ADMIN
|
||||
MessageEvent.OP = MESSAGE_EVENT_OP
|
||||
MessageEvent.USER = MESSAGE_EVENT_USER
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class PrivateMessageEvent(MessageEvent):
|
||||
"""
|
||||
|
||||
@@ -6,6 +6,7 @@ Echo 与交互插件
|
||||
from core.managers.command_manager import matcher
|
||||
from core.bot import Bot
|
||||
from models.events.message import MessageEvent
|
||||
from core.permission import Permission
|
||||
|
||||
__plugin_meta__ = {
|
||||
"name": "echo",
|
||||
@@ -13,7 +14,7 @@ __plugin_meta__ = {
|
||||
"usage": "/echo [内容] - 复读内容\n/赞我 - 让机器人给你点赞",
|
||||
}
|
||||
|
||||
@matcher.command("echo",permission=MessageEvent.ADMIN)
|
||||
@matcher.command("echo", permission=Permission.ADMIN)
|
||||
async def handle_echo(bot: Bot, event: MessageEvent, args: list[str]):
|
||||
"""
|
||||
处理 echo 指令,原样回复用户输入的内容
|
||||
|
||||
228
plugins/github_parser.py
Normal file
228
plugins/github_parser.py
Normal file
@@ -0,0 +1,228 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import json
|
||||
import aiohttp
|
||||
from typing import Optional, Dict, Any, Union
|
||||
from cachetools import TTLCache
|
||||
|
||||
from core.utils.logger import logger
|
||||
from core.managers.command_manager import matcher
|
||||
from core.managers.image_manager import image_manager
|
||||
from models import MessageEvent, MessageSegment
|
||||
|
||||
# 插件元数据
|
||||
__plugin_meta__ = {
|
||||
"name": "github_parser",
|
||||
"description": "自动解析GitHub仓库链接,或通过命令查询仓库信息。",
|
||||
"usage": "(自动触发)当检测到GitHub仓库链接时,自动发送仓库信息。\n(命令触发)/查仓库 作者/仓库名",
|
||||
}
|
||||
|
||||
# 常量定义
|
||||
GITHUB_NICKNAME = "GitHub仓库信息"
|
||||
|
||||
HEADERS = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
|
||||
}
|
||||
|
||||
# 全局共享的 ClientSession
|
||||
_session: Optional[aiohttp.ClientSession] = None
|
||||
|
||||
# 缓存GitHub API响应,避免频繁请求
|
||||
api_cache = TTLCache(maxsize=100, ttl=3600) # 100个缓存项,1小时过期
|
||||
|
||||
|
||||
def get_session() -> aiohttp.ClientSession:
|
||||
"""
|
||||
获取或创建全局的aiohttp ClientSession
|
||||
|
||||
Returns:
|
||||
aiohttp.ClientSession: 客户端会话对象
|
||||
"""
|
||||
global _session
|
||||
if _session is None or _session.closed:
|
||||
_session = aiohttp.ClientSession(headers=HEADERS)
|
||||
return _session
|
||||
|
||||
|
||||
async def get_github_repo_info(owner: str, repo: str) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
通过GitHub API获取仓库信息
|
||||
|
||||
Args:
|
||||
owner (str): 仓库所有者用户名
|
||||
repo (str): 仓库名称
|
||||
|
||||
Returns:
|
||||
Optional[Dict[str, Any]]: 仓库信息字典,如果失败则返回None
|
||||
"""
|
||||
cache_key = f"{owner}/{repo}"
|
||||
if cache_key in api_cache:
|
||||
logger.info(f"[github_parser] 使用缓存的仓库信息: {cache_key}")
|
||||
return api_cache[cache_key]
|
||||
|
||||
api_url = f"https://api.github.com/repos/{owner}/{repo}"
|
||||
try:
|
||||
session = get_session()
|
||||
async with session.get(api_url, timeout=10) as response:
|
||||
response.raise_for_status()
|
||||
repo_data = await response.json()
|
||||
|
||||
# 将数据存入缓存
|
||||
api_cache[cache_key] = repo_data
|
||||
logger.info(f"[github_parser] 成功获取仓库信息并缓存: {cache_key}")
|
||||
return repo_data
|
||||
|
||||
except aiohttp.ClientError as e:
|
||||
logger.error(f"[github_parser] GitHub API请求失败: {e}")
|
||||
except json.JSONDecodeError as e:
|
||||
logger.error(f"[github_parser] 解析GitHub API响应失败: {e}")
|
||||
except Exception as e:
|
||||
logger.error(f"[github_parser] 获取仓库信息时发生未知错误: {e}")
|
||||
|
||||
return None
|
||||
|
||||
|
||||
async def generate_repo_image(repo_data: Dict[str, Any]) -> Optional[str]:
|
||||
"""
|
||||
使用Jinja2模板渲染仓库信息为图片
|
||||
|
||||
Args:
|
||||
repo_data (Dict[str, Any]): 仓库信息字典
|
||||
|
||||
Returns:
|
||||
Optional[str]: 生成的图片Base64编码,如果失败则返回None
|
||||
"""
|
||||
try:
|
||||
# 准备模板数据
|
||||
template_data = {
|
||||
"full_name": repo_data.get("full_name", ""),
|
||||
"description": repo_data.get("description", "暂无描述"),
|
||||
"owner_avatar": repo_data.get("owner", {}).get("avatar_url", ""),
|
||||
"stargazers_count": repo_data.get("stargazers_count", 0),
|
||||
"forks_count": repo_data.get("forks_count", 0),
|
||||
"open_issues_count": repo_data.get("open_issues_count", 0),
|
||||
"watchers_count": repo_data.get("watchers_count", 0),
|
||||
}
|
||||
|
||||
# 渲染模板为图片,使用高质量设置
|
||||
base64_image = await image_manager.render_template_to_base64(
|
||||
template_name="github_repo.html",
|
||||
data=template_data,
|
||||
output_name=f"github_{repo_data.get('name', 'repo')}.png",
|
||||
quality=100, # 使用最高质量
|
||||
image_type="png" # PNG格式为无损压缩
|
||||
)
|
||||
|
||||
return base64_image
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"[github_parser] 生成仓库信息图片失败: {e}")
|
||||
return None
|
||||
|
||||
|
||||
async def process_github_repo(event: MessageEvent, owner: str, repo: str):
|
||||
"""
|
||||
处理GitHub仓库信息查询,获取信息并回复
|
||||
|
||||
Args:
|
||||
event (MessageEvent): 消息事件对象
|
||||
owner (str): 仓库所有者用户名
|
||||
repo (str): 仓库名称
|
||||
"""
|
||||
try:
|
||||
# 获取仓库信息
|
||||
repo_data = await get_github_repo_info(owner, repo)
|
||||
if not repo_data:
|
||||
logger.error(f"[github_parser] 无法获取仓库信息: {owner}/{repo}")
|
||||
await event.reply("无法获取仓库信息,可能是仓库不存在或网络问题。")
|
||||
return
|
||||
|
||||
# 生成图片
|
||||
image_base64 = await generate_repo_image(repo_data)
|
||||
if image_base64:
|
||||
# 发送图片
|
||||
await event.reply(MessageSegment.image(image_base64))
|
||||
else:
|
||||
# 如果图片生成失败,发送文本信息
|
||||
text_message = (
|
||||
f"GitHub 仓库信息\n"
|
||||
f"--------------------\n"
|
||||
f"仓库: {repo_data.get('full_name', '')}\n"
|
||||
f"描述: {repo_data.get('description', '暂无描述')}\n"
|
||||
f"--------------------\n"
|
||||
f"数据:\n"
|
||||
f" 星标: {repo_data.get('stargazers_count', 0)}\n"
|
||||
f" Fork: {repo_data.get('forks_count', 0)}\n"
|
||||
f" Issues: {repo_data.get('open_issues_count', 0)}\n"
|
||||
f" 关注: {repo_data.get('watchers_count', 0)}\n"
|
||||
)
|
||||
await event.reply(text_message)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"[github_parser] 处理仓库信息时发生错误: {e}")
|
||||
await event.reply("处理仓库信息时发生错误,请稍后再试。")
|
||||
|
||||
|
||||
# GitHub仓库链接正则表达式
|
||||
GITHUB_URL_PATTERN = re.compile(r"https?://(?:www\.)?github\.com/([\w\-]+)/([\w\-\.]+)(?:/[^\s]*)?")
|
||||
|
||||
|
||||
# 注册命令处理器
|
||||
@matcher.command("查仓库", "github", "github_repo")
|
||||
async def handle_github_command(bot, event: MessageEvent):
|
||||
"""
|
||||
处理命令调用:/查仓库 作者/仓库名
|
||||
|
||||
Args:
|
||||
bot: 机器人对象
|
||||
event (MessageEvent): 消息事件对象
|
||||
"""
|
||||
# 提取命令参数
|
||||
command_text = event.raw_message
|
||||
# 移除命令前缀和命令名
|
||||
prefix = command_text.split()[0] if command_text.split() else ""
|
||||
params = command_text[len(prefix):].strip()
|
||||
|
||||
if not params:
|
||||
await event.reply("请输入仓库地址,格式:/查仓库 作者/仓库名")
|
||||
return
|
||||
|
||||
# 解析参数格式
|
||||
if "/" in params:
|
||||
owner, repo = params.split("/", 1)
|
||||
# 移除可能的.git后缀
|
||||
repo = repo.replace(".git", "")
|
||||
await process_github_repo(event, owner, repo)
|
||||
else:
|
||||
await event.reply("参数格式错误,请输入:/查仓库 作者/仓库名")
|
||||
|
||||
|
||||
# 注册消息处理器
|
||||
@matcher.on_message()
|
||||
async def handle_github_link(event: MessageEvent):
|
||||
"""
|
||||
处理消息,检测GitHub仓库链接并自动解析
|
||||
|
||||
Args:
|
||||
event (MessageEvent): 消息事件对象
|
||||
"""
|
||||
# 忽略机器人自己发送的消息,防止无限循环
|
||||
if hasattr(event, "user_id") and hasattr(event, "self_id") and event.user_id == event.self_id:
|
||||
return
|
||||
|
||||
# 提取消息文本
|
||||
message_text = ""
|
||||
for segment in event.message:
|
||||
if segment.type == "text":
|
||||
message_text += segment.data.get("text", "")
|
||||
|
||||
# 查找GitHub仓库链接
|
||||
match = GITHUB_URL_PATTERN.search(message_text)
|
||||
if match:
|
||||
owner = match.group(1)
|
||||
repo = match.group(2)
|
||||
# 移除可能的.git后缀
|
||||
repo = repo.replace(".git", "")
|
||||
|
||||
logger.info(f"[github_parser] 检测到GitHub仓库链接: {owner}/{repo}")
|
||||
await process_github_repo(event, owner, repo)
|
||||
@@ -97,6 +97,346 @@ MODULES = [
|
||||
# - API 基础类(由于多重继承问题)
|
||||
]
|
||||
|
||||
def list_compiled_modules():
|
||||
"""列出已编译的模块"""
|
||||
print(f"\n已编译的 {PLATFORM} 模块:")
|
||||
print("=" * 50)
|
||||
|
||||
# 查找所有编译后的文件
|
||||
compiled_files = []
|
||||
for ext in [EXTENSION, f'__mypyc{EXTENSION}']:
|
||||
compiled_files.extend(glob.glob(f'**/*{ext}', recursive=True))
|
||||
|
||||
# 过滤掉虚拟环境中的文件
|
||||
compiled_files = [f for f in compiled_files if 'venv' not in f and '.venv' not in f]
|
||||
|
||||
if compiled_files:
|
||||
for f in sorted(compiled_files):
|
||||
size = os.path.getsize(f) // 1024 # KB
|
||||
print(f"{f} ({size} KB)")
|
||||
else:
|
||||
print(f"未找到已编译的 {EXTENSION} 文件")
|
||||
|
||||
print(f"\n总计: {len(compiled_files)} 个文件")
|
||||
|
||||
def clean_compiled_files():
|
||||
"""清理编译生成的文件"""
|
||||
print(f"\n清理编译生成的 {EXTENSION} 文件...")
|
||||
|
||||
# 查找所有编译后的文件
|
||||
compiled_files = []
|
||||
for ext in [EXTENSION, f'__mypyc{EXTENSION}']:
|
||||
compiled_files.extend(glob.glob(f'**/*{ext}', recursive=True))
|
||||
|
||||
# 过滤掉虚拟环境中的文件
|
||||
compiled_files = [f for f in compiled_files if 'venv' not in f and '.venv' not in f]
|
||||
|
||||
if compiled_files:
|
||||
for f in sorted(compiled_files):
|
||||
try:
|
||||
os.remove(f)
|
||||
print(f"已删除: {f}")
|
||||
except Exception as e:
|
||||
print(f"删除失败 {f}: {e}")
|
||||
|
||||
# 清理 build 目录
|
||||
if os.path.exists('build'):
|
||||
try:
|
||||
shutil.rmtree('build')
|
||||
print("已删除 build 目录")
|
||||
except Exception as e:
|
||||
print(f"删除 build 目录失败: {e}")
|
||||
else:
|
||||
print(f"没有可清理的 {EXTENSION} 文件")
|
||||
|
||||
def get_platform_specific_module_name(module_path):
|
||||
"""获取平台特定的模块文件名"""
|
||||
module_name = module_path.replace('.py', '')
|
||||
return f"{module_name}.{BUILD_PREFIX}{EXTENSION}"
|
||||
|
||||
def compile_module(module_path):
|
||||
"""编译单个模块"""
|
||||
print(f"\n编译: {module_path}")
|
||||
|
||||
try:
|
||||
# 直接调用 mypyc 命令行工具
|
||||
# 使用二进制模式捕获输出以避免编码问题
|
||||
result = subprocess.run(
|
||||
[sys.executable, '-m', 'mypyc', module_path],
|
||||
capture_output=True,
|
||||
check=True
|
||||
)
|
||||
|
||||
# 解码输出时处理可能的编码错误
|
||||
try:
|
||||
stdout_text = result.stdout.decode('utf-8', errors='replace')
|
||||
stderr_text = result.stderr.decode('utf-8', errors='replace')
|
||||
except AttributeError:
|
||||
# 如果已经是字符串(Python 3.7+),则直接使用
|
||||
stdout_text = result.stdout
|
||||
stderr_text = result.stderr
|
||||
|
||||
# 获取平台特定的模块名
|
||||
platform_module = get_platform_specific_module_name(module_path)
|
||||
mypyc_platform_module = platform_module.replace(EXTENSION, f'__mypyc{EXTENSION}')
|
||||
|
||||
# 检查编译产物是否在当前目录
|
||||
if os.path.exists(platform_module):
|
||||
print(f" ✓ 编译成功: {platform_module}")
|
||||
return True
|
||||
else:
|
||||
# 检查 build 目录中是否有编译产物
|
||||
build_module_path = os.path.join(BUILD_PATH, platform_module)
|
||||
build_mypyc_path = os.path.join(BUILD_PATH, mypyc_platform_module)
|
||||
|
||||
if os.path.exists(build_module_path):
|
||||
# 如果在 build 目录中,复制到正确位置
|
||||
os.makedirs(os.path.dirname(platform_module), exist_ok=True)
|
||||
shutil.copy2(build_module_path, platform_module)
|
||||
if os.path.exists(build_mypyc_path):
|
||||
shutil.copy2(build_mypyc_path, mypyc_platform_module)
|
||||
print(f" ✓ 编译成功(已从 build 目录复制): {platform_module}")
|
||||
return True
|
||||
else:
|
||||
print(" ✗ 编译失败:找不到编译产物")
|
||||
if result.stdout:
|
||||
print(f" 编译输出:{stdout_text[:500]}...")
|
||||
if result.stderr:
|
||||
print(f" 错误信息:{stderr_text[:500]}...")
|
||||
return False
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f" ✗ 编译失败,退出码: {e.returncode}")
|
||||
if hasattr(e, 'stdout') and e.stdout:
|
||||
try:
|
||||
stdout_text = e.stdout.decode('utf-8', errors='replace') if isinstance(e.stdout, bytes) else e.stdout
|
||||
print(f" 编译输出:{stdout_text[:500]}...")
|
||||
except Exception:
|
||||
print(f" 编译输出:{str(e.stdout)[:500]}...")
|
||||
if hasattr(e, 'stderr') and e.stderr:
|
||||
try:
|
||||
stderr_text = e.stderr.decode('utf-8', errors='replace') if isinstance(e.stderr, bytes) else e.stderr
|
||||
print(f" 错误信息:{stderr_text[:500]}...")
|
||||
except Exception:
|
||||
print(f" 错误信息:{str(e.stderr)[:500]}...")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f" ✗ 编译失败,意外错误: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return False
|
||||
|
||||
def should_skip_module(module_path):
|
||||
"""检查模块是否应该被跳过编译"""
|
||||
try:
|
||||
with open(module_path, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# 检查是否包含抽象基类相关代码
|
||||
if 'from abc import ABC' in content or 'from abc import abstractmethod' in content:
|
||||
return True, "包含抽象基类,不适合编译"
|
||||
|
||||
# 检查是否包含危险的动态特性
|
||||
# 注意:我们允许基本的动态特性,如getattr,但对于eval、exec等危险操作仍然阻止
|
||||
if ('eval(' in content or 'exec(' in content or
|
||||
'compile(' in content):
|
||||
return True, "包含危险动态特性,不适合编译"
|
||||
|
||||
# 检查是否包含复杂的动态属性访问
|
||||
if ('__dict__' in content or '__class__' in content or
|
||||
'__module__' in content or '__bases__' in content):
|
||||
return True, "包含复杂动态特性,不适合编译"
|
||||
|
||||
# 检查是否包含复杂的动态属性访问
|
||||
if '.__dict__' in content or '.__class__' in content:
|
||||
return True, "包含复杂动态特性,不适合编译"
|
||||
|
||||
return False, ""
|
||||
except Exception as e:
|
||||
return True, f"读取文件时出错: {e}"
|
||||
|
||||
def compile_all_modules():
|
||||
"""编译所有指定的模块"""
|
||||
print(f"\n开始编译 {len(MODULES)} 个模块 (平台: {PLATFORM})")
|
||||
print("=" * 60)
|
||||
|
||||
# 验证模块文件是否存在并检查是否适合编译
|
||||
valid_modules = []
|
||||
skipped_modules = []
|
||||
|
||||
for module_path in MODULES:
|
||||
if os.path.exists(module_path):
|
||||
should_skip, reason = should_skip_module(module_path)
|
||||
if should_skip:
|
||||
print(f"跳过: {module_path} ({reason})")
|
||||
skipped_modules.append((module_path, reason))
|
||||
else:
|
||||
valid_modules.append(module_path)
|
||||
else:
|
||||
print(f"警告: 模块 {module_path} 不存在,将被跳过")
|
||||
|
||||
print(f"\n有效模块: {len(valid_modules)}, 跳过模块: {len(skipped_modules)}")
|
||||
|
||||
if not valid_modules:
|
||||
print("错误: 没有有效的模块可编译")
|
||||
return False
|
||||
|
||||
# 编译模块
|
||||
success_count = 0
|
||||
failed_modules = []
|
||||
|
||||
for module_path in valid_modules:
|
||||
if compile_module(module_path):
|
||||
success_count += 1
|
||||
else:
|
||||
failed_modules.append(module_path)
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print(f"编译完成: {success_count}/{len(valid_modules)} 个模块成功")
|
||||
|
||||
if failed_modules:
|
||||
print(f"失败模块: {failed_modules}")
|
||||
|
||||
if success_count == len(valid_modules):
|
||||
print("✓ 所有模块编译成功")
|
||||
return True
|
||||
else:
|
||||
print("✗ 部分模块编译失败")
|
||||
return False
|
||||
|
||||
def main():
|
||||
"""主函数"""
|
||||
# 检查 Python 版本
|
||||
if not (sys.version_info.major == 3 and sys.version_info.minor >= 8):
|
||||
print("警告: 推荐使用 Python 3.8+ 以获得最佳性能")
|
||||
print(f"当前版本: {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
|
||||
print("继续编译可能导致兼容性问题")
|
||||
print()
|
||||
|
||||
parser = argparse.ArgumentParser(description='优化版跨平台 Python 模块编译脚本')
|
||||
|
||||
group = parser.add_mutually_exclusive_group()
|
||||
group.add_argument('--compile', '-c', action='store_true', default=True,
|
||||
help='编译指定的模块 (默认)')
|
||||
group.add_argument('--list', '-l', action='store_true',
|
||||
help='列出已编译的模块')
|
||||
group.add_argument('--clean', '-k', action='store_true',
|
||||
help='清理编译生成的文件')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# 检查是否安装了 mypyc
|
||||
try:
|
||||
import mypyc
|
||||
except ImportError:
|
||||
print("错误: 未安装 mypyc,请先安装: pip install mypyc")
|
||||
sys.exit(1)
|
||||
|
||||
if args.list:
|
||||
list_compiled_modules()
|
||||
elif args.clean:
|
||||
clean_compiled_files()
|
||||
else:
|
||||
compile_all_modules()
|
||||
print("\n使用 --list 选项查看已编译的模块")
|
||||
print("使用 --clean 选项清理编译文件")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()#!/usr/bin/env python3
|
||||
"""
|
||||
跨平台 Python 模块编译脚本
|
||||
|
||||
将核心 Python 模块编译为机器码(.pyd 或 .so)以提升性能。
|
||||
|
||||
支持的平台:
|
||||
- Windows: 生成 .pyd 文件
|
||||
- Linux: 生成 .so 文件
|
||||
|
||||
使用方法:
|
||||
python compile_machine_code.py [options]
|
||||
|
||||
选项:
|
||||
--compile, -c 编译指定的模块(默认)
|
||||
--list, -l 列出已编译的模块
|
||||
--clean, -k 清理编译生成的文件
|
||||
--help, -h 显示帮助信息
|
||||
|
||||
注意:
|
||||
1. 需要安装 C 编译器 (Windows 上需要 Visual Studio Build Tools, Linux 上需要 GCC)
|
||||
2. 需要安装 mypyc: pip install mypyc
|
||||
3. 编译后的文件是平台相关的,不能跨平台复制
|
||||
4. 建议在部署的目标环境上运行此脚本
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
import subprocess
|
||||
import shutil
|
||||
import argparse
|
||||
|
||||
# 检测当前平台
|
||||
PLATFORM = sys.platform
|
||||
if PLATFORM.startswith('win'):
|
||||
EXTENSION = '.pyd'
|
||||
BUILD_PREFIX = 'cp314-win_amd64'
|
||||
BUILD_PATH = os.path.join('build', f'lib.win-amd64-cpython-314')
|
||||
elif PLATFORM.startswith('linux'):
|
||||
EXTENSION = '.so'
|
||||
BUILD_PREFIX = 'cp314-x86_64-linux-gnu'
|
||||
BUILD_PATH = os.path.join('build', f'lib.linux-x86_64-cpython-314')
|
||||
else:
|
||||
print(f"不支持的平台: {PLATFORM}")
|
||||
sys.exit(1)
|
||||
|
||||
# 要编译的模块列表
|
||||
# 注意:Mypyc 对动态特性支持有限,只选择计算密集或类型明确的模块
|
||||
MODULES = [
|
||||
# 工具模块 - 高频使用
|
||||
'core/utils/json_utils.py', # JSON 处理 - 高频使用
|
||||
'core/utils/executor.py', # 代码执行引擎 - 高频使用
|
||||
'core/utils/exceptions.py', # 自定义异常 - 基础组件
|
||||
'core/utils/performance.py', # 性能监控工具 - 重要组件
|
||||
'core/utils/logger.py', # 日志模块 - 高频使用
|
||||
'core/utils/singleton.py', # 单例模式 - 基础组件
|
||||
|
||||
# 核心管理模块 - 高频使用
|
||||
# 'core/managers/command_manager.py', # 指令匹配和分发 - 包含动态特性,不适合编译
|
||||
# 'core/managers/admin_manager.py', # 管理员管理 - 包含动态特性,不适合编译
|
||||
# 'core/managers/permission_manager.py', # 权限管理 - 包含动态特性,不适合编译
|
||||
# 'core/managers/plugin_manager.py', # 插件管理器 - 包含动态特性,不适合编译
|
||||
# 'core/managers/redis_manager.py', # Redis 管理器 - 包含动态特性,不适合编译
|
||||
# 'core/managers/image_manager.py', # 图片管理器 - 包含动态特性,不适合编译
|
||||
|
||||
# 核心基础模块 - 高频使用
|
||||
'core/ws.py', # WebSocket 核心 - 核心通信,被10个文件引用
|
||||
# 'core/bot.py', # Bot 核心抽象 - 使用多重继承,不适合编译
|
||||
'core/config_loader.py', # 配置加载 - 启动必需,被7个文件引用
|
||||
# 'core/config_models.py', # 配置模型 - 包含复杂类型定义,不适合编译
|
||||
# 'core/permission.py', # 权限枚举 - 包含动态属性,不适合编译
|
||||
|
||||
# 数据模型 - 高频使用
|
||||
'models/message.py', # 消息段模型 - 高频消息处理
|
||||
'models/sender.py', # 发送者模型 - 高频消息处理
|
||||
'models/objects.py', # API 响应数据模型 - 高频数据处理
|
||||
|
||||
# 事件处理相关 - 高频使用
|
||||
'core/handlers/event_handler.py', # 事件处理器 - 核心事件处理
|
||||
|
||||
# 事件模型 - 高频使用,但包含dataclass,可能有编译问题,暂时排除
|
||||
# 'models/events/message.py', # 消息事件 - 最高频事件类型
|
||||
# 'models/events/notice.py', # 通知事件 - 高频事件类型
|
||||
# 'models/events/request.py', # 请求事件 - 高频事件类型
|
||||
# 'models/events/meta.py', # 元事件 - 高频事件类型
|
||||
|
||||
# 注意:以下文件不适合编译
|
||||
# - 主程序文件(main.py)
|
||||
# - 测试文件(tests/目录)
|
||||
# - 插件文件(plugins/目录)
|
||||
# - 编译(脚本compile_machine_code.py等)
|
||||
# - 包含复杂动态特性的文件
|
||||
# - API 基础类(由于多重继承问题)
|
||||
]
|
||||
|
||||
def list_compiled_modules():
|
||||
"""列出已编译的模块"""
|
||||
print(f"\n已编译的 {PLATFORM} 模块:")
|
||||
@@ -316,14 +656,7 @@ def compile_all_modules():
|
||||
|
||||
def main():
|
||||
"""主函数"""
|
||||
# 检查 Python 版本
|
||||
if not (sys.version_info.major == 3 and sys.version_info.minor >= 8):
|
||||
print("警告: 推荐使用 Python 3.8+ 以获得最佳性能")
|
||||
print(f"当前版本: {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
|
||||
print("继续编译可能导致兼容性问题")
|
||||
print()
|
||||
|
||||
parser = argparse.ArgumentParser(description='优化版跨平台 Python 模块编译脚本')
|
||||
parser = argparse.ArgumentParser(description='跨平台 Python 模块编译脚本')
|
||||
|
||||
group = parser.add_mutually_exclusive_group()
|
||||
group.add_argument('--compile', '-c', action='store_true', default=True,
|
||||
|
||||
200
templates/github_repo.html
Normal file
200
templates/github_repo.html
Normal file
@@ -0,0 +1,200 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>GitHub仓库信息</title>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap');
|
||||
body {
|
||||
font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #ffffff;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.container {
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
padding: 60px;
|
||||
background-color: rgba(26, 26, 46, 0.95);
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
border: none;
|
||||
backdrop-filter: blur(10px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
.repo-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 80px;
|
||||
}
|
||||
.repo-info {
|
||||
flex: 1;
|
||||
}
|
||||
.repo-title {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: #00d4ff;
|
||||
margin: 0 0 24px 0;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 2.5px;
|
||||
}
|
||||
.repo-full-name {
|
||||
font-size: 72px;
|
||||
font-weight: 900;
|
||||
color: #ffffff;
|
||||
margin: 0 0 30px 0;
|
||||
line-height: 1.1;
|
||||
}
|
||||
.repo-description {
|
||||
font-size: 32px;
|
||||
color: #ffffff;
|
||||
margin: 0 0 36px 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.owner-avatar {
|
||||
width: 240px;
|
||||
height: 240px;
|
||||
border-radius: 50%;
|
||||
margin-left: 80px;
|
||||
object-fit: cover;
|
||||
border: 5px solid #00d4ff;
|
||||
box-shadow: 0 12px 36px rgba(0, 212, 255, 0.5);
|
||||
}
|
||||
.stats-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 40px;
|
||||
margin-top: 80px;
|
||||
padding-top: 40px;
|
||||
border-top: 3px solid rgba(15, 52, 96, 0.8);
|
||||
}
|
||||
.stat-item {
|
||||
text-align: center;
|
||||
flex: 1;
|
||||
min-width: 180px;
|
||||
}
|
||||
.stat-number {
|
||||
font-size: 96px;
|
||||
font-weight: 900;
|
||||
color: #00d4ff;
|
||||
display: block;
|
||||
line-height: 1;
|
||||
}
|
||||
.stat-label {
|
||||
font-size: 24px;
|
||||
color: #ffffff;
|
||||
margin-top: 16px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.footer {
|
||||
margin-top: 100px;
|
||||
padding-top: 40px;
|
||||
border-top: 3px solid rgba(15, 52, 96, 0.8);
|
||||
text-align: center;
|
||||
}
|
||||
.bot-info {
|
||||
font-size: 30px;
|
||||
color: rgba(0, 212, 255, 1);
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 4px;
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
body {
|
||||
padding: 0;
|
||||
}
|
||||
.container {
|
||||
padding: 20px;
|
||||
}
|
||||
.repo-header {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
.owner-avatar {
|
||||
margin-left: 0;
|
||||
margin-bottom: 24px;
|
||||
width: 160px;
|
||||
height: 160px;
|
||||
}
|
||||
.repo-title {
|
||||
font-size: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
.repo-full-name {
|
||||
font-size: 48px;
|
||||
text-align: center;
|
||||
}
|
||||
.repo-description {
|
||||
text-align: center;
|
||||
font-size: 24px;
|
||||
}
|
||||
.stats-container {
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
.stat-item {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.stat-number {
|
||||
font-size: 64px;
|
||||
}
|
||||
.stat-label {
|
||||
font-size: 20px;
|
||||
}
|
||||
.bot-info {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="repo-header">
|
||||
<div class="repo-info">
|
||||
<div class="repo-title">GitHub Repository</div>
|
||||
<h1 class="repo-full-name">{{ full_name }}</h1>
|
||||
<p class="repo-description">{{ description }}</p>
|
||||
</div>
|
||||
{% if owner_avatar %}
|
||||
<img src="{{ owner_avatar }}" alt="Owner Avatar" class="owner-avatar">
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="stats-container">
|
||||
<div class="stat-item">
|
||||
<span class="stat-number">{{ stargazers_count }}</span>
|
||||
<div class="stat-label">Stars</div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-number">{{ forks_count }}</span>
|
||||
<div class="stat-label">Forks</div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-number">{{ open_issues_count }}</span>
|
||||
<div class="stat-label">Issues</div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-number">{{ watchers_count }}</span>
|
||||
<div class="stat-label">Watchers</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<div class="bot-info">by CalglauBOT</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -32,19 +32,22 @@
|
||||
/* 居中布局 */
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 40px;
|
||||
min-height: auto;
|
||||
padding: 0;
|
||||
min-height: 100vh;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
/* 窗口容器 */
|
||||
.window {
|
||||
width: 800px; /* 稍微收窄一点,更像手机/卡片比例 */
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
background: var(--window-bg);
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
border-radius: 20px;
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
|
||||
border-radius: 0;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -52,7 +55,7 @@
|
||||
|
||||
/* 顶部标题栏 */
|
||||
.header {
|
||||
padding: 24px 32px;
|
||||
padding: 32px 40px;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
display: flex;
|
||||
@@ -67,48 +70,50 @@
|
||||
.green { background: #10b981; }
|
||||
|
||||
.title {
|
||||
font-size: 14px;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 1px;
|
||||
letter-spacing: 1.5px;
|
||||
color: var(--text-desc);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* 内容区域 */
|
||||
.content {
|
||||
padding: 32px;
|
||||
padding: 40px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px; /* 卡片之间的间距 */
|
||||
gap: 32px; /* 卡片之间的间距 */
|
||||
}
|
||||
|
||||
.page-title {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.page-title h1 {
|
||||
font-size: 32px;
|
||||
font-size: 48px;
|
||||
background: linear-gradient(to right, #fff, #94a3b8);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
.page-title p {
|
||||
color: var(--text-desc);
|
||||
font-size: 14px;
|
||||
margin-top: 8px;
|
||||
font-size: 20px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
/* 插件卡片 - 改为单列宽卡片 */
|
||||
/* 插件卡片 - 改为三列布局 */
|
||||
.plugin-card {
|
||||
background: var(--card-bg);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
border-radius: 14px;
|
||||
padding: 24px;
|
||||
display: flex;
|
||||
flex-direction: column; /* 垂直排列 */
|
||||
gap: 16px;
|
||||
transition: transform 0.2s;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
flex: 1;
|
||||
min-width: 320px;
|
||||
}
|
||||
|
||||
/* 左侧装饰线 */
|
||||
@@ -129,41 +134,41 @@
|
||||
}
|
||||
|
||||
.plugin-name {
|
||||
font-size: 18px;
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
/* 装饰性Tag */
|
||||
.plugin-tag {
|
||||
font-size: 10px;
|
||||
font-size: 14px;
|
||||
background: rgba(99, 102, 241, 0.2);
|
||||
color: #818cf8;
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
padding: 4px 8px;
|
||||
border-radius: 6px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.plugin-desc {
|
||||
font-size: 13px;
|
||||
font-size: 18px;
|
||||
color: var(--text-desc);
|
||||
line-height: 1.5;
|
||||
margin-top: 4px;
|
||||
line-height: 1.6;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
/* 指令代码块 - 核心修改区域 */
|
||||
.cmd-block {
|
||||
background: var(--cmd-bg);
|
||||
border-radius: 8px;
|
||||
padding: 16px;
|
||||
border-radius: 10px;
|
||||
padding: 20px;
|
||||
border: 1px solid var(--border-color);
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
font-size: 16px;
|
||||
line-height: 1.8;
|
||||
color: var(--text-cmd);
|
||||
|
||||
/* 处理长文本的关键 CSS */
|
||||
@@ -180,14 +185,23 @@
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
/* 插件网格布局 */
|
||||
.plugin-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 24px;
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 页脚 */
|
||||
.footer {
|
||||
padding: 20px 32px;
|
||||
padding: 24px 40px;
|
||||
border-top: 1px solid var(--border-color);
|
||||
color: rgba(255, 255, 255, 0.2);
|
||||
font-size: 12px;
|
||||
font-size: 16px;
|
||||
text-align: right;
|
||||
background: rgba(0,0,0,0.1);
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
@@ -210,7 +224,8 @@
|
||||
<p>Dashboard & Command List · {{ plugins|length }} Modules Loaded</p>
|
||||
</div>
|
||||
|
||||
<!-- 插件列表 - 单列流式布局 -->
|
||||
<!-- 插件列表 - 三列流式布局 -->
|
||||
<div class="plugin-grid">
|
||||
{% for plugin in plugins %}
|
||||
<div class="plugin-card">
|
||||
<div class="card-top">
|
||||
@@ -227,10 +242,11 @@
|
||||
<div class="cmd-block">{{ plugin.usage }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
Generated by NeoBot Render Engine
|
||||
by CalglauBOT
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user