Compare commits

..

6 Commits

Author SHA1 Message Date
a97bf7d55c 摇骰子
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2025-09-29 00:00:48 +08:00
4a26177ab9 调整 README 关于运行和自动重载的部分
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2025-09-28 20:35:04 +08:00
a727c108fe 添加 Debug 调试任务和运行 bot 的 task 2025-09-28 20:31:18 +08:00
d6d68dcc96 删除无用的 VSCode Task 2025-09-28 20:21:47 +08:00
b0e8779bff 配置 Alconna 全局不使用 to_me 来简化 Alconna 指令调用流程 2025-09-28 20:20:24 +08:00
c3a0b02e10 根据文档,不能将 tag 绑定到 branch 上
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2025-09-28 01:51:59 +08:00
9 changed files with 102 additions and 10 deletions

View File

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

View File

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

View File

@ -1,2 +1,3 @@
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"
},
"problemMatcher": [],
"detail": "导出生产环境依赖到 requirements.txt,不包含开发依赖和哈希值。"
"detail": "导出生产环境依赖到 requirements.txt"
},
{
"label": "Poetry: Export requirements.txt (Full)",
"label": "Bot: Run with Auto-reload",
"type": "shell",
"command": "poetry export -f requirements.txt --output requirements.txt",
"command": "poetry run watchfiles bot.main",
"group": "build",
"isBackground": true,
"presentation": {
"reveal": "always",
"panel": "new"
},
"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
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_minecraft = os.environ.get("ENABLE_MINECRAFT", "none")
if __name__ == "__main__":
def main():
nonebot.init()
driver = nonebot.get_driver()
@ -35,3 +35,6 @@ if __name__ == "__main__":
nonebot.load_plugins("konabot/plugins")
nonebot.run()
if __name__ == "__main__":
main()

View File

@ -0,0 +1,12 @@
from nonebot_plugin_alconna import Alconna, Args, Field, UniMessage, on_alconna
from konabot.plugins.roll_dice.roll_dice import roll_dice
from konabot.plugins.weather.fetcher import fetch_radar
evt = on_alconna(Alconna(
"摇骰子"
), use_cmd_start=True, use_cmd_sep=False, skip_for_unmatch=True)
@evt.handle()
async def _():
await evt.send(await UniMessage().text(await roll_dice()).export())

View File

@ -0,0 +1,46 @@
number_arts = {
1: ''' _
/ |
| |
| |
|_|
''',
2: ''' ____
|___ \
__) |
/ __/
|_____|
''',
3: ''' _____
|___ /
|_ \
___) |
|____/
''',
4: ''' _ _
| || |
| || |_
|__ _|
|_|
''',
5: ''' ____
| ___|
|___ \
___) |
|____/
''',
6: ''' __
/ /_
| '_ \
| (_) |
\___/
'''
}
def get_random_number(min: int = 1, max: int = 6) -> int:
import random
return random.randint(min, max)
async def roll_dice() -> str:
return number_arts[get_random_number()]