修复了串群问题
This commit is contained in:
parent
72c1e7a494
commit
f228fdde69
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from typing import TYPE_CHECKING, TypeVar
|
from typing import TYPE_CHECKING, TypeVar
|
||||||
|
|
||||||
@ -7,14 +9,17 @@ else:
|
|||||||
IcaNewMessage = TypeVar("NewMessage")
|
IcaNewMessage = TypeVar("NewMessage")
|
||||||
IcaClient = TypeVar("IcaClient")
|
IcaClient = TypeVar("IcaClient")
|
||||||
|
|
||||||
EMPTY_VOTE = {i: [] for i in range(0, 24)}
|
|
||||||
|
def gen_room() -> dict[int, list[int]]:
|
||||||
|
return {i: [] for i in range(0, 24)}
|
||||||
|
|
||||||
VOTE = {}
|
VOTE = {}
|
||||||
|
|
||||||
|
|
||||||
def fmt_vote(room_id) -> str:
|
def fmt_vote(room_id) -> str:
|
||||||
global VOTE
|
global VOTE
|
||||||
if room_id not in VOTE:
|
if room_id not in VOTE:
|
||||||
VOTE[room_id] = EMPTY_VOTE.copy()
|
VOTE[room_id] = gen_room()
|
||||||
return "\n".join(
|
return "\n".join(
|
||||||
f"{x}: {len(VOTE[room_id][x])}" for x in VOTE[room_id] if VOTE[room_id][x]
|
f"{x}: {len(VOTE[room_id][x])}" for x in VOTE[room_id] if VOTE[room_id][x]
|
||||||
)
|
)
|
||||||
@ -28,7 +33,7 @@ def hypvote(msg: IcaNewMessage, client: IcaClient):
|
|||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
if msg.room_id not in VOTE:
|
if msg.room_id not in VOTE:
|
||||||
VOTE[msg.room_id] = EMPTY_VOTE.copy()
|
VOTE[msg.room_id] = gen_room()
|
||||||
if arg[0] == "vote":
|
if arg[0] == "vote":
|
||||||
for x in arg[1:]:
|
for x in arg[1:]:
|
||||||
if x.isdigit() and 0 <= int(x) < 24:
|
if x.isdigit() and 0 <= int(x) < 24:
|
||||||
@ -41,7 +46,7 @@ def hypvote(msg: IcaNewMessage, client: IcaClient):
|
|||||||
if msg.sender_id in VOTE[msg.room_id][int(x) % 24]:
|
if msg.sender_id in VOTE[msg.room_id][int(x) % 24]:
|
||||||
VOTE[msg.room_id][int(x) % 24].remove(msg.sender_id)
|
VOTE[msg.room_id][int(x) % 24].remove(msg.sender_id)
|
||||||
elif arg[0] == "clear":
|
elif arg[0] == "clear":
|
||||||
VOTE[msg.room_id] = EMPTY_VOTE.copy()
|
VOTE[msg.room_id] = gen_room()
|
||||||
elif arg == [] or arg[0] == "ls":
|
elif arg == [] or arg[0] == "ls":
|
||||||
res = fmt_vote(msg.room_id)
|
res = fmt_vote(msg.room_id)
|
||||||
reply = msg.reply_with(res)
|
reply = msg.reply_with(res)
|
||||||
|
Loading…
Reference in New Issue
Block a user