From a97bf7d55ccaad16a474f5b7720356c64c887607 Mon Sep 17 00:00:00 2001 From: MixBadGun <1059129006@qq.com> Date: Mon, 29 Sep 2025 00:00:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=91=87=E9=AA=B0=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- konabot/plugins/roll_dice/__init__.py | 12 +++++++ konabot/plugins/roll_dice/roll_dice.py | 46 ++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 konabot/plugins/roll_dice/__init__.py create mode 100644 konabot/plugins/roll_dice/roll_dice.py diff --git a/konabot/plugins/roll_dice/__init__.py b/konabot/plugins/roll_dice/__init__.py new file mode 100644 index 0000000..402904b --- /dev/null +++ b/konabot/plugins/roll_dice/__init__.py @@ -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()) diff --git a/konabot/plugins/roll_dice/roll_dice.py b/konabot/plugins/roll_dice/roll_dice.py new file mode 100644 index 0000000..fd2887a --- /dev/null +++ b/konabot/plugins/roll_dice/roll_dice.py @@ -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()] \ No newline at end of file