Compare commits

..

4 Commits

Author SHA1 Message Date
c8dae680a3 跨平台适配
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2025-09-29 00:41:29 +08:00
adebd51605 fix: 删掉前缀匹配
All checks were successful
continuous-integration/drone/push Build is passing
2025-09-29 00:18:44 +08:00
f0fdc930d4 删除多余引用 2025-09-29 00:15:18 +08:00
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
4 changed files with 75 additions and 0 deletions

View File

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

View File

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

View File

@ -0,0 +1,19 @@
from nonebot.adapters import Event as BaseEvent
from nonebot.adapters.console.event import MessageEvent as ConsoleMessageEvent
from nonebot.adapters.discord.event import MessageEvent as DiscordMessageEvent
from nonebot_plugin_alconna import Alconna, UniMessage, on_alconna
from konabot.plugins.roll_dice.roll_dice import roll_dice
evt = on_alconna(Alconna(
"摇骰子"
), use_cmd_start=True, use_cmd_sep=False, skip_for_unmatch=True)
@evt.handle()
async def _(event: BaseEvent):
if isinstance(event, DiscordMessageEvent):
await evt.send(await UniMessage().text("```\n" + roll_dice() + "\n```").export())
elif isinstance(event, ConsoleMessageEvent):
await evt.send(await UniMessage().text(roll_dice()).export())
else:
await evt.send(await UniMessage().text(roll_dice(wide=True)).export())

View File

@ -0,0 +1,54 @@
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)
def roll_dice(wide: bool = False) -> str:
raw = number_arts[get_random_number()]
if wide:
raw = (raw
.replace("/", "")
.replace("\\", "")
.replace("_", "_")
.replace("|", "")
.replace(" ", " "))
return raw