Archived
1
0
Fork 0

dice syntax

This commit is contained in:
Nattiden 2023-02-28 18:28:57 +08:00 committed by GitHub
parent 91e0735fed
commit 63036133f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,13 +6,15 @@ dice = on_command('dice', alias={'d4': 'dice d4', 'd6': 'dice d6',
'd8': 'dice d8', 'd10': 'dice d10', 'd12': 'dice d12', 'd20': 'dice d20', 'd100': 'dice d100'}, developers=['Light-Beacon'], desc='随机骰子',)
@dice.handle('<dices> [<times>] [<dc>] {投掷指定骰子,可指定投骰次数与 dc 判断判定。}',)
@dice.handle('<dices> [<dc>] {投掷指定骰子,可指定投骰次数与 dc 判断判定。}',)
async def _(msg: MessageSession):
dice = msg.parsed_msg['<dices>']
times = msg.parsed_msg.get('<times>', '1')
dc = msg.parsed_msg.get('<dc>', '0')
if '#' in dice:
times = dice.partition('#')[0]
dice = dice.partition('#')[2]
if not times.isdigit():
await msg.finish('发生错误:无效的投骰次数:' + dc)
await msg.finish('发生错误:无效的投骰次数:' + times)
if not dc.isdigit():
await msg.finish('发生错误:无效的 dc' + dc)
await msg.finish(await GenerateMessage(dice, int(times), int(dc)))