Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from rich.table import Table
from rich.live import Live
from utils import find_qr_code
import re

with open("./config.yaml") as stream:
try:
Expand Down Expand Up @@ -49,11 +50,13 @@
logging.info("识别成功,二维码内容:" + qrRaw)
break

store = local_data(clientId=qrRaw[81:])
match = re.search(r":(\d+)/([0-9a-fA-F-]+)", qrRaw)
uuid_str = match.group(2) if match else None
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex extraction can result in uuid_str being None if the pattern doesn't match, but there's no error handling or validation before passing it to local_data(clientId=uuid_str). This could cause issues downstream when the clientId is used in websocket messages. Consider adding validation to ensure the match was successful and handle the case where it fails, such as logging an error and exiting gracefully.

Suggested change
uuid_str = match.group(2) if match else None
if not match:
logger.error("无法从二维码内容中解析出有效的 clientId,内容为: %s", qrRaw)
raise SystemExit(1)
uuid_str = match.group(2)

Copilot uses AI. Check for mistakes.

store = local_data(clientId=uuid_str)
store.limitA = int(config["Channel_A_limit"])
store.limitB = int(config["Channel_B_limit"])


def on_message(ws, message_raw):
logger.debug(f"Received message: {message_raw}")
message_dict: dict = json.loads(message_raw)
Expand All @@ -79,7 +82,7 @@ def on_message(ws, message_raw):
break_(ws, message)
elif message.type_ == "error":
error(ws, message)
response(ws, "feedback-0", store)
# response(ws, "feedback-0", store)
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The response function call has been commented out without explanation. If this is intentional and the functionality is no longer needed, the line should be removed entirely rather than commented out. If this is temporary for debugging or testing, a comment explaining why it's disabled should be added.

Suggested change
# response(ws, "feedback-0", store)
# response(ws, "feedback-0", store) # Temporarily disabled to avoid sending automatic feedback messages; re-enable if feedback responses are required.

Copilot uses AI. Check for mistakes.


def on_error(ws, error):
Expand Down
Loading