headers = {
"User-Agent": config["useragent"],
}
+
# HTTP headers for API requests
api_headers = {
"User-Agent": config["useragent"],
return has_pending
def update_instance_data(domain: str):
+ # DEBUG: print(f"DEBUG: domain={domain} - CALLED!")
if type(domain) != str:
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
raise ValueError(f"Parameter 'domain' cannot be empty")
+ elif not has_pending_instance_data(domain):
+ raise Exception(f"Domain '{domain}' has no pending instance data, but function invoked")
# DEBUG: print(f"DEBUG: Updating nodeinfo for domain='{domain}' ...")
sql_string = ''
# DEBUG: print("DEBUG: EXIT!")
def update_last_instance_fetch(domain: str):
+ # DEBUG: print(f"DEBUG: domain={domain} - CALLED!")
if type(domain) != str:
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
# DEBUG: print("DEBUG: EXIT!")
def update_last_nodeinfo(domain: str):
+ # DEBUG: print(f"DEBUG: domain={domain} - CALLED!")
if type(domain) != str:
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
# DEBUG: print("DEBUG: EXIT!")
def get_peers(domain: str, software: str) -> list:
+ # DEBUG: print(f"DEBUG: domain({len(domain)})={domain},software={software} - CALLED!")
if type(domain) != str:
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
return data
def fetch_nodeinfo(domain: str, path: str = None) -> list:
+ # DEBUG: print(f"DEBUG: domain='{domain}',path={path} - CALLED!")
if type(domain) != str:
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
raise ValueError(f"Parameter 'domain' cannot be empty")
+ elif type(path) != str and path != None:
+ raise ValueError(f"Parameter path[]={type(path)} is not 'str'")
# DEBUG: print("DEBUG: Fetching nodeinfo from domain,path:", domain, path)
-
nodeinfo = fetch_wellknown_nodeinfo(domain)
- # DEBUG: print("DEBUG: nodeinfo:", nodeinfo)
+ # DEBUG: print(f"DEBUG: nodeinfo({len(nodeinfo)})={nodeinfo}")
if len(nodeinfo) > 0:
- # DEBUG: print("DEBUG: Returning auto-discovered nodeinfo:", len(nodeinfo))
+ # DEBUG: print("DEBUG: nodeinfo()={len(nodeinfo))} - EXIT!")
return nodeinfo
requests = [
update_last_error(domain, e)
pass
- # DEBUG: print("DEBUG: Returning data[]:", type(data))
+ # DEBUG: print(f"DEBUG: data()={len(data)} - EXIT!")
return data
def fetch_wellknown_nodeinfo(domain: str) -> list:
+ # DEBUG: print(f"DEBUG: domain={domain} - CALLED!")
if type(domain) != str:
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
return data
def fetch_generator_from_path(domain: str, path: str = "/") -> str:
+ # DEBUG: print(f"DEBUG: domain({len(domain)})={domain},path={path} - CALLED!")
if type(domain) != str:
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
return software
def determine_software(domain: str, path: str = None) -> str:
+ # DEBUG: print(f"DEBUG: domain({len(domain)})={domain},path={path} - CALLED!")
if type(domain) != str:
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
raise ValueError(f"Parameter 'domain' cannot be empty")
+ elif type(path) != str and path != None:
+ raise ValueError(f"Parameter path[]={type(path)} is not 'str'")
# DEBUG: print("DEBUG: Determining software for domain,path:", domain, path)
software = None
return software
def update_block_reason(reason: str, blocker: str, blocked: str, block_level: str):
+ # DEBUG: print(f"DEBUG: reason='{reason}',blocker={blocker},blocked={blocked},block_level={block_level} - CALLED!")
if type(reason) != str and reason != None:
raise ValueError(f"Parameter reason[]='{type(reason)}' is not 'str'")
elif type(blocker) != str:
# DEBUG: print("DEBUG: EXIT!")
def is_instance_registered(domain: str) -> bool:
+ # DEBUG: print(f"DEBUG: domain={domain} - CALLED!")
if type(domain) != str:
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
return registered
def add_instance(domain: str, origin: str, originator: str, path: str = None):
+ # DEBUG: print(f"DEBUG: domain={domain},origin={origin},originator={originator},path={path} - CALLED!")
if type(domain) != str:
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
# DEBUG: print("DEBUG: EXIT!")
def send_bot_post(instance: str, blocks: dict):
+ # DEBUG: print(f"DEBUG: instance={instance},blocks()={len(blocks)} - CALLED!")
message = instance + " has blocked the following instances:\n\n"
truncated = False
return True
def get_mastodon_blocks(domain: str) -> dict:
+ # DEBUG: print(f"DEBUG: domain={domain} - CALLED!")
if type(domain) != str:
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
}
def get_friendica_blocks(domain: str) -> dict:
+ # DEBUG: print(f"DEBUG: domain={domain} - CALLED!")
if type(domain) != str:
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
}
def get_misskey_blocks(domain: str) -> dict:
+ # DEBUG: print(f"DEBUG: domain={domain} - CALLED!")
if type(domain) != str:
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
}
def tidyup(string: str) -> str:
+ # DEBUG: print(f"DEBUG: string='{string}' - CALLED!")
if type(string) != str:
raise ValueError(f"Parameter string[]={type(string)} is not expected")
- # some retards put their blocks in variable case
+ # All lower-case and strip spaces out
string = string.lower().strip()
- # other retards put the port
+ # No port number
string = re.sub("\:\d+$", "", string)
- # bigger retards put the schema in their blocklist, sometimes even without slashes
+ # No protocol, sometimes with the slashes
string = re.sub("^https?\:(\/*)", "", string)
- # and trailing slash
+ # No trailing slash
string = re.sub("\/$", "", string)
- # and the @
+ # No @ sign
string = re.sub("^\@", "", string)
- # the biggest retards of them all try to block individual users
+ # No individual users in block lists
string = re.sub("(.+)\@", "", string)
+ # DEBUG: print(f"DEBUG: string='{string}' - EXIT!")
return string