lottery 修复无人参与时报错

This commit is contained in:
omg-xtao 2023-01-09 21:08:04 +08:00 committed by GitHub
parent ffbaa1babc
commit 84f85b3ebc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,6 +33,7 @@ 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))
if all_user:
while True: while True:
temp = secret_generator.choice(all_user) temp = secret_generator.choice(all_user)
if temp not in win_user: if temp not in win_user: