Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c8dae680a3 | |||
| adebd51605 | |||
| f0fdc930d4 | |||
| a97bf7d55c |
1
.env.dev
1
.env.dev
@ -1,3 +1,4 @@
|
|||||||
DRIVER=~fastapi+~httpx+~websockets
|
DRIVER=~fastapi+~httpx+~websockets
|
||||||
COMMAND_START=["!", "!", "", "/"]
|
COMMAND_START=["!", "!", "", "/"]
|
||||||
|
|
||||||
ALCONNA_USE_ORIGIN=true
|
ALCONNA_USE_ORIGIN=true
|
||||||
@ -1,3 +1,4 @@
|
|||||||
DRIVER=~fastapi+~httpx+~websockets
|
DRIVER=~fastapi+~httpx+~websockets
|
||||||
COMMAND_START=["!", "!", "", "/"]
|
COMMAND_START=["!", "!", "", "/"]
|
||||||
|
|
||||||
ALCONNA_USE_ORIGIN=true
|
ALCONNA_USE_ORIGIN=true
|
||||||
19
konabot/plugins/roll_dice/__init__.py
Normal file
19
konabot/plugins/roll_dice/__init__.py
Normal 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())
|
||||||
54
konabot/plugins/roll_dice/roll_dice.py
Normal file
54
konabot/plugins/roll_dice/roll_dice.py
Normal 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
|
||||||
Reference in New Issue
Block a user