From ee425b7d30a226a6514d89ccabd2f5b0d58cec43 Mon Sep 17 00:00:00 2001 From: MoMMde Date: Mon, 28 Feb 2022 20:28:50 +0100 Subject: [PATCH 1/3] Added an option for checking a specific status code --- sherlock/sherlock.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sherlock/sherlock.py b/sherlock/sherlock.py index e29a56a4..0de5f649 100644 --- a/sherlock/sherlock.py +++ b/sherlock/sherlock.py @@ -331,6 +331,7 @@ def sherlock(username, site_data, query_notify, # Get the expected error type error_type = net_info["errorType"] + error_code = net_info.get("errorCode") # Retrieve future and ensure it has finished future = net_info["request_future"] @@ -395,8 +396,15 @@ def sherlock(username, site_data, query_notify, QueryStatus.AVAILABLE, query_time=response_time) elif error_type == "status_code": + # Checks if the Status Code is equal to the optional "errorCode" given in 'data.json' + if error_code == r.status_code: + result = QueryResult(username, + social_network, + url, + QueryStatus.AVAILABLE, + query_time=response_time) # Checks if the status code of the response is 2XX - if not r.status_code >= 300 or r.status_code < 200: + elif not r.status_code >= 300 or r.status_code < 200: result = QueryResult(username, social_network, url, From 2cd7436b3e8babbf89a0329c93a16669457ad263 Mon Sep 17 00:00:00 2001 From: MoMMde Date: Mon, 28 Feb 2022 20:29:23 +0100 Subject: [PATCH 2/3] Implemented Mojang API check --- sherlock/resources/data.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sherlock/resources/data.json b/sherlock/resources/data.json index e2fd6a45..cf369fb6 100644 --- a/sherlock/resources/data.json +++ b/sherlock/resources/data.json @@ -1103,6 +1103,14 @@ "username_claimed": "blue", "username_unclaimed": "noonewouldeverusethis7" }, + "Mojang": { + "errorType": "status_code", + "errorCode": 204, + "url": "https://api.mojang.com/users/profiles/minecraft/{}", + "urlMain": "https://api.mojang.com", + "username_claimed": "blue", + "username_unclaimed": "noonewouldeverusethis7" + }, "MyAnimeList": { "errorType": "status_code", "url": "https://myanimelist.net/profile/{}", From ab4de462ad7ef9022b5929144f73732ce051cc94 Mon Sep 17 00:00:00 2001 From: MoMMde Date: Mon, 28 Feb 2022 20:45:36 +0100 Subject: [PATCH 3/3] renamed mojang to minecraft --- sherlock/resources/data.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sherlock/resources/data.json b/sherlock/resources/data.json index cf369fb6..6808e24d 100644 --- a/sherlock/resources/data.json +++ b/sherlock/resources/data.json @@ -1103,11 +1103,11 @@ "username_claimed": "blue", "username_unclaimed": "noonewouldeverusethis7" }, - "Mojang": { + "Minecraft": { "errorType": "status_code", "errorCode": 204, "url": "https://api.mojang.com/users/profiles/minecraft/{}", - "urlMain": "https://api.mojang.com", + "urlMain": "https://minecraft.net/", "username_claimed": "blue", "username_unclaimed": "noonewouldeverusethis7" },