diff --git a/__pycache__/black.cpython-310.pyc b/__pycache__/black.cpython-310.pyc index 0c8c02d..510dbab 100644 Binary files a/__pycache__/black.cpython-310.pyc and b/__pycache__/black.cpython-310.pyc differ 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() # 等待连接,这里必定进入循环