Commit Graph

133 Commits

Author SHA1 Message Date
minecraft1024a
2f1a9fa966 refactor(cleanup): 移除未使用的导入项与冗余代码
清理了整个代码库中所有无用的模块导入、重复定义以及冗余变量引用,具体包括:
- bot.py 去掉了 random、typing 的未使用 import
- antipromptinjector 模块统一移除未引用的 DetectionResult、Dict、List 等
- chat_loop 中删除了未调用的 Timer、mai_thinking_manager、events_manager 等引用
- qzone_service 删除多余 f-string 大括号,避免日志警告格式问题
- 其他模块同步剔除各自范围内的冗余 import(asyncio、datetime 等共 20+ 处)

保持功能不变,仅作代码整洁度优化,无破坏性变更。(并添加了一个现在暂时还没加进去的必应搜索源文件)
2025-11-19 22:45:22 +08:00
雅诺狐
89687bd5c0 去掉一行注释 2025-11-19 22:45:05 +08:00
雅诺狐
31e028ab25 Refactor anti-injection system into modular subpackages
Split the anti-prompt-injector module into core, processors, management, and decision submodules for better maintainability and separation of concerns. Moved and refactored detection, shielding, statistics, user ban, message processing, and counter-attack logic into dedicated files. Updated imports and initialization in __init__.py and anti_injector.py to use the new structure. No functional changes to detection logic, but code organization is significantly improved.
2025-11-19 22:45:01 +08:00
minecraft1024a
b3174c4498 fix(bot): 移除加权随机彩蛋功能。(不要再闲的没事动那beyond的彩蛋了) 2025-11-19 22:45:00 +08:00
tt-P607
1b15e23448 refactor(bot): 统一关闭逻辑到finally块
将优雅关闭(graceful_shutdown)的调用逻辑从`KeyboardInterrupt`异常处理块移动到`finally`块中。

这确保了无论程序是正常退出、收到中断信号,还是发生其他任何异常,都会尝试执行统一的、可靠的清理和关闭流程,从而增强了程序的健壮性。
2025-11-19 22:44:57 +08:00
minecraft1024a
31b06fb4a3 ~~哎呀,主人,你又在乱改代码了。这次的修改还真是……微妙呢。算了,看在你这么努力的份上,本小姐就帮你写个像样点的 commit message 吧。拿去用,不谢。~~
refactor(easter_egg): 简化彩蛋实现并移除未使用的选项

- 移除了 `bot.py` 中 `easter_egg` 函数内的加权随机选择逻辑,现在固定显示一个彩蛋。
- 删除了两个未被使用的彩蛋文本。
- 在 `src/main.py` 中为 `zip` 函数调用添加了 `strict=True` 参数,以增强代码的健壮性,确保彩蛋文本和权重列表长度严格匹配。
2025-11-19 22:44:46 +08:00
ikun两年半
35f3042d95 更新 bot.py
回调彩蛋喵~
2025-11-19 22:44:45 +08:00
雅诺狐
bb4592846c Refactor config system to use Pydantic validation
Refactored configuration classes to inherit from a new ValidatedConfigBase using Pydantic for robust validation and error reporting. Updated api_ada_configs.py, config.py, config_base.py, and official_configs.py to replace dataclasses with Pydantic models, add field validation, and improve error messages. This change enhances configuration reliability and developer feedback for misconfigurations. Also includes minor code cleanups and removal of unused variables in other modules.
2025-11-19 22:44:45 +08:00
minecraft1024a
97ece6524c refactor(utils): 移除自定义加权随机函数并改用 random.choices
将原先在 `bot.py` 中实现的 `weighted_choice` 函数移除,并在 `src/main.py` 中改用 Python 内置的 `random.choices` 函数来实现启动时彩蛋的加权随机选择。

这一更改简化了代码,提高了可读性,并利用了标准库的优化实现。同时调整了彩蛋文本和对应的权重。
2025-11-19 22:44:41 +08:00
雅诺狐
6e4047c807 Add rare easter egg message and adjust weights
Introduced a new rare easter egg message to the items list and updated the selection weights to make the new message extremely rare while adjusting the probabilities of the existing messages.
2025-11-19 22:44:41 +08:00
ikun两年半
c1043ef50b 更新 bot.py
修改彩蛋权重喵~主打一个众生平等喵
2025-11-19 22:44:40 +08:00
雅诺狐
053bf81b25 Add weighted_choice utility and improve easter_egg randomness
Introduced a weighted_choice function for weighted random selection. Refactored the easter_egg function to use weighted_choice for more flexible and controlled message selection, replacing the previous randint-based logic.
2025-11-19 22:44:05 +08:00
ikun两年半
c2a8e9bd43 更新 bot.py
喵喵~修复了彩蛋概率问题喵~
2025-11-19 22:44:05 +08:00
minecraft1024a
46246d6f34 chore(deps): remove legacy gemini client and fix easter egg range 2025-11-19 22:44:04 +08:00
minecraft1024a
bd218db8e4 feat(彩蛋): 增加彩蛋文本的随机性
在 `easter_egg` 函数中引入了随机数生成逻辑。
现在有20%的概率显示猫娘文本,80%的概率显示一个原有的文本,增加了趣味性。
2025-11-19 22:44:04 +08:00
ikun-11451
be454303c5 喵喵~ 2025-11-19 22:44:03 +08:00
minecraft1024a
27c63380c2 refactor(core): 调整数据库初始化时机
将数据库的初始化、表结构创建和自动迁移逻辑从配置文件加载时移动到主程序 `raw_main` 函数中。

这一改动旨在解决循环导入问题,并确保数据库在所有配置和核心模块加载完毕后才进行初始化,提高了程序的启动鲁棒性和模块独立性。
2025-11-19 22:43:17 +08:00
SengokuCola
8053067af5 feat:优化关键词显示,优化表达方式配置和逻辑 2025-08-09 00:10:41 +08:00
墨梓柒
e240fb92ca fix: 更新模型配置和环境变量,调整版本号和模型参数 2025-07-27 13:37:21 +08:00
UnCLAS-Prommer
1aa2734d62 typing fix 2025-07-17 00:10:41 +08:00
墨梓柒
2229f98993 fix:修复LPMM学习问题 2025-07-16 19:58:19 +08:00
github-actions[bot]
9eeff628b8 🤖 自动格式化代码 [skip ci] 2025-07-08 18:10:43 +00:00
SengokuCola
50f0ddf2ce feat;新的情绪系统 2025-07-09 01:50:26 +08:00
github-actions[bot]
324b294b5f 🤖 自动格式化代码 [skip ci] 2025-07-01 11:33:16 +00:00
SengokuCola
3ef3923a8b Merge branch 'dev-s4u' into dev 2025-07-01 19:33:06 +08:00
SengokuCola
7b18ad17fc Merge branch 'dev-s4u' of https://github.com/MaiM-with-u/MaiBot into dev-s4u 2025-07-01 15:41:59 +08:00
Cookie987
2d2f6ecd8d 非TTY环境禁用console_input_loop 2025-07-01 12:50:10 +08:00
github-actions[bot]
284c248add 🤖 自动格式化代码 [skip ci] 2025-06-25 07:55:16 +00:00
SengokuCola
5351b7639c better:优化表达方式和侧面人格 2025-06-25 15:53:59 +08:00
github-actions[bot]
36e763ec89 🤖 自动格式化代码 [skip ci] 2025-06-24 14:35:49 +00:00
SengokuCola
8595268740 feat:不完善的控制台发送 2025-06-24 22:32:06 +08:00
SengokuCola
2b572b9abf feat:不完善的控制台发送 2025-06-24 22:17:59 +08:00
github-actions[bot]
a733020228 🤖 自动格式化代码 [skip ci] 2025-06-15 05:14:57 +00:00
SengokuCola
83ae078d6e fix:修复日志占用和文件层级 2025-06-15 13:14:39 +08:00
github-actions[bot]
86be17405a 🤖 自动格式化代码 [skip ci] 2025-06-14 17:28:38 +00:00
SengokuCola
327580dbec fix:ai哥神秘修复无法模式切换 2025-06-15 01:27:54 +08:00
SengokuCola
1a1a48508d fix:修复零散小问题 2025-06-14 11:41:41 +08:00
SengokuCola
247645f8b5 update logger 2025-06-12 23:56:58 +08:00
SengokuCola
91636b82ec fix:ruff 2025-06-12 20:32:18 +08:00
github-actions[bot]
9b4fa2155e 🤖 自动格式化代码 [skip ci] 2025-06-12 12:30:00 +00:00
SengokuCola
745d762dbb feat:可配置log,解决可读性问题 2025-06-12 20:13:47 +08:00
春河晴
6767bd6715 fix: 懒加载单例以修复环境变量加载问题 2025-06-11 17:22:43 +09:00
春河晴
61d6672b46 use logger.warning instead of logger.warn 2025-06-11 16:15:24 +09:00
春河晴
7b4e7b94f8 use structlog instead of loguru 2025-06-11 15:17:08 +09:00
Oct-autumn
46d15b1fe7 feat: 添加异步任务管理器和本地存储管理器,重构统计模块 2025-05-13 00:55:50 +08:00
github-actions[bot]
afbe4f280e 🤖 自动格式化代码 [skip ci] 2025-05-06 16:21:18 +00:00
墨梓柒
1e2cdeeea5 feat: 添加强制停止MAI Bot的API接口(半成品),优化嵌入数据目录路径处理 2025-05-07 00:21:04 +08:00
SengokuCola
15ec8394d7 fix:使用工作路径使mmc在启动器运行时读取文件无误 2025-05-06 14:14:54 +08:00
SengokuCola
49a34581c3 feat:新增flet启动器 2025-05-04 18:02:46 +08:00
墨梓柒
edda834538 fix: 移除Traceback函数中的 show_locals 参数以简化错误追踪 2025-05-02 12:01:05 +08:00