Compare commits

..

5 Commits

7 changed files with 44 additions and 10 deletions

View File

@ -40,8 +40,6 @@ type: docker
trigger: trigger:
event: event:
- tag - tag
branch:
- master
steps: steps:
- name: 构建并推送 Release Docker 镜像 - name: 构建并推送 Release Docker 镜像

View File

@ -1,2 +1,3 @@
DRIVER=~fastapi+~httpx+~websockets DRIVER=~fastapi+~httpx+~websockets
COMMAND_START=["!", "", "", "/"] COMMAND_START=["!", "", "", "/"]
ALCONNA_USE_ORIGIN=true

View File

@ -1,2 +1,3 @@
DRIVER=~fastapi+~httpx+~websockets DRIVER=~fastapi+~httpx+~websockets
COMMAND_START=["!", "", "", "/"] COMMAND_START=["!", "", "", "/"]
ALCONNA_USE_ORIGIN=true

24
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "运行 Bot 并调试(自动重载)",
"type": "debugpy",
"request": "launch",
"module": "watchfiles",
"args": [
"bot.main"
],
"console": "integratedTerminal",
"justMyCode": true,
"env": {
"PYTHONPATH": "${workspaceFolder}"
},
"cwd": "${workspaceFolder}",
"presentation": {
"hidden": false,
"group": "bot"
}
}
]
}

9
.vscode/tasks.json vendored
View File

@ -11,19 +11,20 @@
"panel": "new" "panel": "new"
}, },
"problemMatcher": [], "problemMatcher": [],
"detail": "导出生产环境依赖到 requirements.txt,不包含开发依赖和哈希值。" "detail": "导出生产环境依赖到 requirements.txt"
}, },
{ {
"label": "Poetry: Export requirements.txt (Full)", "label": "Bot: Run with Auto-reload",
"type": "shell", "type": "shell",
"command": "poetry export -f requirements.txt --output requirements.txt", "command": "poetry run watchfiles bot.main",
"group": "build", "group": "build",
"isBackground": true,
"presentation": { "presentation": {
"reveal": "always", "reveal": "always",
"panel": "new" "panel": "new"
}, },
"problemMatcher": [], "problemMatcher": [],
"detail": "导出所有依赖(包括生产和开发依赖)到 requirements.txt包含哈希值以确保完全一致。" "detail": "运行 bot 并启用自动重载功能"
} }
] ]
} }

View File

@ -65,7 +65,13 @@ code .
### 运行 ### 运行
如果改动了代码,应该先用 `Ctrl+C` 或者根据控制台提示退出,然后再重新启动。 你可以在 VSCode 的「运行与调试」窗口,启动 `运行 Bot 并调试(自动重载)` 任务来启动 Bot也可以使用命令行手动启动 Bot
```bash
poetry run watchfiles bot.main
```
如果你不希望自动重载,只是想运行 Bot可以直接运行
```bash ```bash
poetry run python bot.py poetry run python bot.py

5
bot.py
View File

@ -14,7 +14,7 @@ env_enable_qq = os.environ.get("ENABLE_QQ", "none")
env_enable_discord = os.environ.get("ENABLE_DISCORD", "none") env_enable_discord = os.environ.get("ENABLE_DISCORD", "none")
env_enable_minecraft = os.environ.get("ENABLE_MINECRAFT", "none") env_enable_minecraft = os.environ.get("ENABLE_MINECRAFT", "none")
if __name__ == "__main__": def main():
nonebot.init() nonebot.init()
driver = nonebot.get_driver() driver = nonebot.get_driver()
@ -35,3 +35,6 @@ if __name__ == "__main__":
nonebot.load_plugins("konabot/plugins") nonebot.load_plugins("konabot/plugins")
nonebot.run() nonebot.run()
if __name__ == "__main__":
main()