mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
cache system
This commit is contained in:
parent
b90f6c7b6d
commit
cd664607b1
@ -30,6 +30,10 @@ class Sherlock():
|
|||||||
self.dict[sherlockdict]["cache"] = dict()
|
self.dict[sherlockdict]["cache"] = dict()
|
||||||
|
|
||||||
def check_network(self, username, social_network):
|
def check_network(self, username, social_network):
|
||||||
|
|
||||||
|
if username in self.dict[social_network]["cache"]:
|
||||||
|
return True
|
||||||
|
|
||||||
url = self.dict.get(social_network).get("url").format(username)
|
url = self.dict.get(social_network).get("url").format(username)
|
||||||
error_type = self.dict.get(social_network).get("errorType")
|
error_type = self.dict.get(social_network).get("errorType")
|
||||||
cant_have_period = self.dict.get(social_network).get("noPeriod")
|
cant_have_period = self.dict.get(social_network).get("noPeriod")
|
||||||
@ -40,28 +44,30 @@ class Sherlock():
|
|||||||
|
|
||||||
r, error_type = self.make_request(url=url, error_type=error_type, social_network=social_network)
|
r, error_type = self.make_request(url=url, error_type=error_type, social_network=social_network)
|
||||||
|
|
||||||
|
user_exists = True
|
||||||
|
|
||||||
if error_type == "message":
|
if error_type == "message":
|
||||||
error = self.dict.get(social_network).get("errorMsg")
|
error = self.dict.get(social_network).get("errorMsg")
|
||||||
# Checks if the error message is in the HTML
|
# Checks if the error message is in the HTML
|
||||||
if error not in r.text:
|
if error in r.text:
|
||||||
return True
|
user_exists = False
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
elif error_type == "status_code":
|
elif error_type == "status_code":
|
||||||
# Checks if the status code of the repsonse is 404
|
# Checks if the status code of the repsonse is 404
|
||||||
if not r.status_code == 404:
|
if r.status_code == 404:
|
||||||
return True
|
user_exists = False
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
elif error_type == "response_url":
|
elif error_type == "response_url":
|
||||||
error = self.dict.get(social_network).get("errorUrl")
|
error = self.dict.get(social_network).get("errorUrl")
|
||||||
# Checks if the redirect url is the same as the one defined in data.json
|
# Checks if the redirect url is the same as the one defined in data.json
|
||||||
if error not in r.url:
|
if error in r.url:
|
||||||
return True
|
user_exists = False
|
||||||
else:
|
|
||||||
return False
|
if user_exists:
|
||||||
|
self.dict[social_network]["cache"].append(username)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def make_request(self, url, error_type, social_network):
|
def make_request(self, url, error_type, social_network):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user