mirror of
https://github.com/TeamPGM/PagerMaid_Plugins_Pyro.git
synced 2024-11-22 09:41:54 +00:00
lottery 修复无人参与时报错
This commit is contained in:
parent
ffbaa1babc
commit
84f85b3ebc
@ -33,12 +33,13 @@ async def lottery_end():
|
|||||||
secret_generator = secrets.SystemRandom()
|
secret_generator = secrets.SystemRandom()
|
||||||
win_user = []
|
win_user = []
|
||||||
win_user_num = min(lottery_json["win"], len(all_user))
|
win_user_num = min(lottery_json["win"], len(all_user))
|
||||||
while True:
|
if all_user:
|
||||||
temp = secret_generator.choice(all_user)
|
while True:
|
||||||
if temp not in win_user:
|
temp = secret_generator.choice(all_user)
|
||||||
win_user.append(temp)
|
if temp not in win_user:
|
||||||
if len(win_user) >= win_user_num:
|
win_user.append(temp)
|
||||||
break
|
if len(win_user) >= win_user_num:
|
||||||
|
break
|
||||||
win_text = end_text.format(
|
win_text = end_text.format(
|
||||||
lottery_json["title"],
|
lottery_json["title"],
|
||||||
"\n".join(f"<a href=\"tg://user?id={uid}\">@{uid}</a>" for uid in win_user
|
"\n".join(f"<a href=\"tg://user?id={uid}\">@{uid}</a>" for uid in win_user
|
||||||
|
Loading…
Reference in New Issue
Block a user