Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/dice/__init__.py

42 lines
1.7 KiB
Python
Raw Normal View History

from core.builtins import Bot
2023-03-04 08:51:56 +00:00
from core.component import module
2023-02-26 04:03:25 +00:00
from .dice import GenerateMessage
2023-01-19 12:02:49 +00:00
2023-04-30 03:30:59 +00:00
dice = module('dice', alias={'d4': 'dice d4',
2023-04-21 10:11:03 +00:00
'd6': 'dice d6',
2023-04-30 03:30:59 +00:00
'd8': 'dice d8',
'd10': 'dice d10',
'd12': 'dice d12',
2023-04-21 10:11:03 +00:00
'd20': 'dice d20',
2023-04-22 04:13:58 +00:00
'd100': 'dice d100'}, developers=['Light-Beacon'], desc='{dice.help.desc}',)
2023-01-19 12:02:49 +00:00
2023-01-19 14:22:14 +00:00
2023-04-22 04:13:58 +00:00
@dice.command('<dices> [<dc>] {{dice.help}}',
2023-03-09 14:18:57 +00:00
options_desc={
2023-06-07 08:26:44 +00:00
'{dice.help.option.polynomial.title}': '{dice.help.option.polynomial}',
'n': '{dice.help.option.n}',
'm': '{dice.help.option.m}',
'kx': '{dice.help.option.kx}',
'klx': '{dice.help.option.klx}',
'y': '{dice.help.option.y}',
'N': '{dice.help.option.N}',
'dc': '{dice.help.option.dc}'
2023-03-09 14:18:57 +00:00
})
async def _(msg: Bot.MessageSession, dices, dc='0'):
2023-02-28 10:47:28 +00:00
times = '1'
if '#' in dices:
times = dices.partition('#')[0]
dices = dices.partition('#')[2]
2023-02-28 10:47:28 +00:00
if not times.isdigit():
2023-04-22 04:13:58 +00:00
await msg.finish(msg.locale.t('dice.message.error.N.invalid') + times)
if not dc.isdigit():
2023-04-22 04:13:58 +00:00
await msg.finish(msg.locale.t('dice.message.error.dc.invalid') + dc)
2023-06-07 07:56:42 +00:00
await msg.finish(await GenerateMessage(msg, dices, int(times), int(dc)))
2023-02-26 04:03:25 +00:00
2023-03-09 14:18:57 +00:00
2023-05-22 04:34:43 +00:00
@dice.regex(r"[扔|投|掷|丢]([0-9]*)?个([0-9]*面)?骰子?", desc="{dice.help.regex.desc}")
async def _(message: Bot.MessageSession):
2023-02-26 04:03:25 +00:00
groups = message.matched_msg.groups()
diceType = groups[1][:-1] if groups[1] else '6'
2023-06-07 07:56:42 +00:00
await message.finish(await GenerateMessage(message, f'{groups[0]}D{diceType}', 1, 0))