Skip to content

Commit 78b9dd6

Browse files
authored
Merge pull request #500 from MaiM-with-u/main-fix
Main fix
2 parents edd05d5 + 8c178b8 commit 78b9dd6

63 files changed

Lines changed: 3659 additions & 3873 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docker-image.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ jobs:
2222
- name: Login to Docker Hub
2323
uses: docker/login-action@v3
2424
with:
25-
username: ${{ secrets.DOCKERHUB_USERNAME }}
25+
username: ${{ vars.DOCKERHUB_USERNAME }}
2626
password: ${{ secrets.DOCKERHUB_TOKEN }}
2727

2828
- name: Determine Image Tags
2929
id: tags
3030
run: |
3131
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
32-
echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:${{ github.ref_name }},${{ secrets.DOCKERHUB_USERNAME }}/maimbot:latest" >> $GITHUB_OUTPUT
32+
echo "tags=${{ vars.DOCKERHUB_USERNAME }}/maimbot:${{ github.ref_name }},${{ vars.DOCKERHUB_USERNAME }}/maimbot:latest" >> $GITHUB_OUTPUT
3333
elif [ "${{ github.ref }}" == "refs/heads/main" ]; then
34-
echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:main,${{ secrets.DOCKERHUB_USERNAME }}/maimbot:latest" >> $GITHUB_OUTPUT
34+
echo "tags=${{ vars.DOCKERHUB_USERNAME }}/maimbot:main,${{ vars.DOCKERHUB_USERNAME }}/maimbot:latest" >> $GITHUB_OUTPUT
3535
elif [ "${{ github.ref }}" == "refs/heads/main-fix" ]; then
36-
echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:main-fix" >> $GITHUB_OUTPUT
36+
echo "tags=${{ vars.DOCKERHUB_USERNAME }}/maimbot:main-fix" >> $GITHUB_OUTPUT
3737
fi
3838
3939
- name: Build and Push Docker Image
@@ -44,5 +44,5 @@ jobs:
4444
platforms: linux/amd64,linux/arm64
4545
tags: ${{ steps.tags.outputs.tags }}
4646
push: true
47-
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:buildcache
48-
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:buildcache,mode=max
47+
cache-from: type=registry,ref=${{ vars.DOCKERHUB_USERNAME }}/maimbot:buildcache
48+
cache-to: type=registry,ref=${{ vars.DOCKERHUB_USERNAME }}/maimbot:buildcache,mode=max

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@
9595
- MongoDB 提供数据持久化支持
9696
- NapCat 作为QQ协议端支持
9797

98-
**最新版本: v0.5.14** ([查看更新日志](changelog.md))
98+
**最新版本: v0.5.15** ([查看更新日志](changelog.md))
9999
> [!WARNING]
100-
> 注意,3月12日的v0.5.13, 该版本更新较大,建议单独开文件夹部署,然后转移/data文件 和数据库,数据库可能需要删除messages下的内容(不需要删除记忆)
100+
> 该版本更新较大,建议单独开文件夹部署,然后转移/data文件,数据库可能需要删除messages下的内容(不需要删除记忆)
101101
102102
<div align="center">
103103
<a href="https://www.bilibili.com/video/BV1amAneGE3P" target="_blank">

bot.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import platform
1515
from src.common.logger import get_module_logger
1616

17-
18-
# 配置主程序日志格式
1917
logger = get_module_logger("main_bot")
2018

2119
# 获取没有加载env时的环境变量
@@ -103,7 +101,6 @@ def dev():
103101
RuntimeError(f"ENVIRONMENT 配置错误,请检查 .env 文件中的 ENVIRONMENT 变量及对应 .env.{env} 是否存在")
104102

105103

106-
107104
def scan_provider(env_config: dict):
108105
provider = {}
109106

@@ -166,12 +163,13 @@ async def uvicorn_main():
166163
uvicorn_server = server
167164
await server.serve()
168165

166+
169167
def check_eula():
170168
eula_confirm_file = Path("eula.confirmed")
171169
privacy_confirm_file = Path("privacy.confirmed")
172170
eula_file = Path("EULA.md")
173171
privacy_file = Path("PRIVACY.md")
174-
172+
175173
eula_updated = True
176174
eula_new_hash = None
177175
privacy_updated = True
@@ -205,6 +203,9 @@ def check_eula():
205203
if eula_new_hash == confirmed_content:
206204
eula_confirmed = True
207205
eula_updated = False
206+
if eula_new_hash == os.getenv("EULA_AGREE"):
207+
eula_confirmed = True
208+
eula_updated = False
208209

209210
# 检查隐私条款确认文件是否存在
210211
if privacy_confirm_file.exists():
@@ -213,42 +214,46 @@ def check_eula():
213214
if privacy_new_hash == confirmed_content:
214215
privacy_confirmed = True
215216
privacy_updated = False
217+
if privacy_new_hash == os.getenv("PRIVACY_AGREE"):
218+
privacy_confirmed = True
219+
privacy_updated = False
216220

217221
# 如果EULA或隐私条款有更新,提示用户重新确认
218222
if eula_updated or privacy_updated:
219223
print("EULA或隐私条款内容已更新,请在阅读后重新确认,继续运行视为同意更新后的以上两款协议")
220-
print('输入"同意"或"confirmed"继续运行')
224+
print(f'输入"同意"或"confirmed"或设置环境变量"EULA_AGREE={eula_new_hash}"和"PRIVACY_AGREE={privacy_new_hash}"继续运行')
221225
while True:
222226
user_input = input().strip().lower()
223-
if user_input in ['同意', 'confirmed']:
227+
if user_input in ["同意", "confirmed"]:
224228
# print("确认成功,继续运行")
225229
# print(f"确认成功,继续运行{eula_updated} {privacy_updated}")
226230
if eula_updated:
227231
print(f"更新EULA确认文件{eula_new_hash}")
228-
eula_confirm_file.write_text(eula_new_hash,encoding="utf-8")
232+
eula_confirm_file.write_text(eula_new_hash, encoding="utf-8")
229233
if privacy_updated:
230234
print(f"更新隐私条款确认文件{privacy_new_hash}")
231-
privacy_confirm_file.write_text(privacy_new_hash,encoding="utf-8")
235+
privacy_confirm_file.write_text(privacy_new_hash, encoding="utf-8")
232236
break
233237
else:
234238
print('请输入"同意"或"confirmed"以继续运行')
235239
return
236240
elif eula_confirmed and privacy_confirmed:
237241
return
238242

243+
239244
def raw_main():
240245
# 利用 TZ 环境变量设定程序工作的时区
241246
# 仅保证行为一致,不依赖 localtime(),实际对生产环境几乎没有作用
242247
if platform.system().lower() != "windows":
243248
time.tzset()
244-
249+
245250
check_eula()
246251
print("检查EULA和隐私条款完成")
247252
easter_egg()
248253
init_config()
249254
init_env()
250255
load_env()
251-
256+
252257
# load_logger()
253258

254259
env_config = {key: os.getenv(key) for key in os.environ}
@@ -280,15 +285,15 @@ def raw_main():
280285
app = nonebot.get_asgi()
281286
loop = asyncio.new_event_loop()
282287
asyncio.set_event_loop(loop)
283-
288+
284289
try:
285290
loop.run_until_complete(uvicorn_main())
286291
except KeyboardInterrupt:
287292
logger.warning("收到中断信号,正在优雅关闭...")
288293
loop.run_until_complete(graceful_shutdown())
289294
finally:
290295
loop.close()
291-
296+
292297
except Exception as e:
293298
logger.error(f"主程序异常: {str(e)}")
294299
if loop and not loop.is_closed():

changelog.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ AI总结
77
- 新增关系系统构建与启用功能
88
- 优化关系管理系统
99
- 改进prompt构建器结构
10+
- 新增手动修改记忆库的脚本功能
11+
- 增加alter支持功能
1012

1113
#### 启动器优化
1214
- 新增MaiLauncher.bat 1.0版本
@@ -16,13 +18,17 @@ AI总结
1618
- 新增分支重置功能
1719
- 添加MongoDB支持
1820
- 优化脚本逻辑
21+
- 修复虚拟环境选项闪退和conda激活问题
22+
- 修复环境检测菜单闪退问题
23+
- 修复.env.prod文件复制路径错误
1924

2025
#### 日志系统改进
2126
- 新增GUI日志查看器
2227
- 重构日志工厂处理机制
2328
- 优化日志级别配置
2429
- 支持环境变量配置日志级别
2530
- 改进控制台日志输出
31+
- 优化logger输出格式
2632

2733
### 💻 系统架构优化
2834
#### 配置系统升级
@@ -31,11 +37,19 @@ AI总结
3137
- 新增配置文件版本检测功能
3238
- 改进配置文件保存机制
3339
- 修复重复保存可能清空list内容的bug
40+
- 修复人格设置和其他项配置保存问题
41+
42+
#### WebUI改进
43+
- 优化WebUI界面和功能
44+
- 支持安装后管理功能
45+
- 修复部分文字表述错误
3446

3547
#### 部署支持扩展
3648
- 优化Docker构建流程
3749
- 改进MongoDB服务启动逻辑
3850
- 完善Windows脚本支持
51+
- 优化Linux一键安装脚本
52+
- 新增Debian 12专用运行脚本
3953

4054
### 🐛 问题修复
4155
#### 功能稳定性
@@ -44,13 +58,23 @@ AI总结
4458
- 修复新版本由于版本判断不能启动的问题
4559
- 修复配置文件更新和学习知识库的确认逻辑
4660
- 优化token统计功能
61+
- 修复EULA和隐私政策处理时的编码兼容问题
62+
- 修复文件读写编码问题,统一使用UTF-8
63+
- 修复颜文字分割问题
64+
- 修复willing模块cfg变量引用问题
4765

4866
### 📚 文档更新
4967
- 更新CLAUDE.md为高信息密度项目文档
5068
- 添加mermaid系统架构图和模块依赖图
5169
- 添加核心文件索引和类功能表格
5270
- 添加消息处理流程图
5371
- 优化文档结构
72+
- 更新EULA和隐私政策文档
73+
74+
### 🔧 其他改进
75+
- 更新全球在线数量展示功能
76+
- 优化statistics输出展示
77+
- 新增手动修改内存脚本(支持添加、删除和查询节点和边)
5478

5579
### 主要改进方向
5680
1. 完善关系系统功能

config/auto_update.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,35 @@
33
import tomlkit
44
from pathlib import Path
55

6+
67
def update_config():
78
# 获取根目录路径
89
root_dir = Path(__file__).parent.parent
910
template_dir = root_dir / "template"
1011
config_dir = root_dir / "config"
11-
12+
1213
# 定义文件路径
1314
template_path = template_dir / "bot_config_template.toml"
1415
old_config_path = config_dir / "bot_config.toml"
1516
new_config_path = config_dir / "bot_config.toml"
16-
17+
1718
# 读取旧配置文件
1819
old_config = {}
1920
if old_config_path.exists():
2021
with open(old_config_path, "r", encoding="utf-8") as f:
2122
old_config = tomlkit.load(f)
22-
23+
2324
# 删除旧的配置文件
2425
if old_config_path.exists():
2526
os.remove(old_config_path)
26-
27+
2728
# 复制模板文件到配置目录
2829
shutil.copy2(template_path, new_config_path)
29-
30+
3031
# 读取新配置文件
3132
with open(new_config_path, "r", encoding="utf-8") as f:
3233
new_config = tomlkit.load(f)
33-
34+
3435
# 递归更新配置
3536
def update_dict(target, source):
3637
for key, value in source.items():
@@ -55,13 +56,14 @@ def update_dict(target, source):
5556
except (TypeError, ValueError):
5657
# 如果转换失败,直接赋值
5758
target[key] = value
58-
59+
5960
# 将旧配置的值更新到新配置中
6061
update_dict(new_config, old_config)
61-
62+
6263
# 保存更新后的配置(保留注释和格式)
6364
with open(new_config_path, "w", encoding="utf-8") as f:
6465
f.write(tomlkit.dumps(new_config))
6566

67+
6668
if __name__ == "__main__":
6769
update_config()

0 commit comments

Comments
 (0)