模拟抽卡支持中文数字

模拟抽卡支持“抽四十连常驻”这样的指令
This commit is contained in:
kui 2023-01-10 13:12:54 +08:00 committed by GitHub
parent d4c53b1138
commit 0eda8441fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,7 +25,7 @@ __plugin_meta__ = PluginMetadata(
}
)
sim_gacha = on_regex(r'^抽((?P<num>\d+)|(?:.*))十连(?P<pool>.*?)$', priority=13, block=True, state={
sim_gacha = on_regex(r'^抽(?P<num>.*?)十连(?P<pool>.*?)$', priority=13, block=True, state={
'pm_name': '模拟抽卡',
'pm_description': '原神模拟抽卡,卡池有常驻|角色1|角色2|武器',
'pm_usage': '抽[数量]十连[卡池]',
@ -62,6 +62,15 @@ show_log = on_command('模拟抽卡记录', aliases={'查看模拟抽卡记录'}
# 'pm_priority': 6
# })
def get_num(num):
if num and num.isdigit():
return int(num)
else:
try:
digit_dict={'': 1, '': 2, '': 3, '': 4, '': 5, '': 6, '': 7, '': 8, '': 9 }
return digit_dict[num]
except:
return 1
@sim_gacha.handle()
async def _(event: MessageEvent, reGroup: Dict = RegexDict()):
@ -73,7 +82,7 @@ async def _(event: MessageEvent, reGroup: Dict = RegexDict()):
await sim_gacha.finish(f'你的模拟抽卡冷却ing...剩余{freq_limiter.left(f"gacha-group{event.group_id}-{event.user_id}")}', at_sender=True)
num = reGroup['num']
pool = reGroup['pool']
num = int(num) if num and num.isdigit() else 1
num = get_num(num)
if num > config.sim_gacha_max:
await sim_gacha.finish(f'单次最多只能{config.sim_gacha_max}十连哦!')
pool = pool or '角色1'