Fix some buttons having priority
This commit is contained in:
parent
003f9eb41c
commit
fe6242cbbf
@ -2,7 +2,6 @@ import asyncio
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import random
|
import random
|
||||||
from socket import socket
|
|
||||||
from typing import Callable, Awaitable
|
from typing import Callable, Awaitable
|
||||||
|
|
||||||
from fastapi import WebSocket, WebSocketDisconnect
|
from fastapi import WebSocket, WebSocketDisconnect
|
||||||
@ -177,15 +176,13 @@ async def _(get_input: InputGetter, set_output: OutputSetter):
|
|||||||
# cursed python syntax
|
# cursed python syntax
|
||||||
vote["none"] += 1
|
vote["none"] += 1
|
||||||
|
|
||||||
max_choice = None
|
max_vote = max(vote.values())
|
||||||
max_votes = -1
|
choice = random.choice(
|
||||||
for (choice, votes) in vote.items():
|
[key for (key, value) in vote.items() if value == max_vote]
|
||||||
if votes > max_votes:
|
)
|
||||||
max_votes = votes
|
|
||||||
max_choice = choice
|
|
||||||
|
|
||||||
output = {button: False for button in Button}
|
output = {button: False for button in Button}
|
||||||
if max_choice != "none":
|
if choice != "none":
|
||||||
output[max_choice] = True
|
output[choice] = True
|
||||||
|
|
||||||
set_output(output)
|
set_output(output)
|
||||||
|
Loading…
Reference in New Issue
Block a user