From e948a144096ea987d44871788e1ab8cfce70ddd6 Mon Sep 17 00:00:00 2001 From: xyj Date: Sat, 9 Mar 2024 15:10:58 +0800 Subject: [PATCH] update --- __pycache__/black.cpython-310.pyc | Bin 326 -> 326 bytes main.py | 30 +++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/__pycache__/black.cpython-310.pyc b/__pycache__/black.cpython-310.pyc index 0c8c02d7f9ca02221e41cde3fed20ca8d21b9216..510dbaba743d41c80940bbd041a3ee1fe16fb4b1 100644 GIT binary patch delta 26 gcmX@cbc~5BpO=@50SL~sP2{R(iMYiWIk9su09F_WfB*mh delta 26 gcmX@cbc~5BpO=@50SHdBOysI&skp^hIk9su09Pyrx&QzG diff --git a/main.py b/main.py index 69c4f3c..89968d2 100644 --- a/main.py +++ b/main.py @@ -15,6 +15,22 @@ def click_it(x, y): def is_black(black): + for v in black_list: + if dict_equal(v, black): + return True + return False + + +def dict_equal(dict1, dict2): + if len(dict2) != len(dict1): + return False + for k, v1 in dict1.items(): + v2 = dict2.get(k) + if v1 != v2: + return False + if k == "Point": + if len(v1[0]) != len(v2[0]): + return False return True @@ -39,19 +55,19 @@ def handle_client(client_socket): data = data.decode("utf-8") data = json.loads(data) print(data) - for v in black_list: - if is_black(v): - print("黑名单") - client_socket.send(b"ACK!") - client_socket.close() - return + if is_black(data): + print("黑名单") + client_socket.send(b"ACK!") + client_socket.close() + return Point = data["Point"] x = Point[0]["X"] y = Point[0]["Y"] - print(x, y) click_it(x, y) except Exception as e: pass + client_socket.send(b"ACK!") + client_socket.close() # 等待连接,这里必定进入循环