mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-22 00:14:10 +00:00
Use headers from settings on initial checks and update regexes
This commit is contained in:
parent
6fd8c0575e
commit
399c07905a
|
@ -41,13 +41,13 @@ def clean_link(link: str) -> str:
|
|||
|
||||
|
||||
def sanitize_to_markdown(text: str) -> str:
|
||||
"""Sanitizes given text to escape markdown formatting. It is used in values that will be visible on Discord in messages"""
|
||||
text = text.replace("\\", "\\\\").replace('/\\/', '\\').replace("](", "]\\(") # replace escaping and links
|
||||
text = re.sub(r"([`_*~:<>{}@|])", "\\\\\\1", text) # Escape common Markdown characters
|
||||
text = re.sub(r"^#+ ", '\\\\\\g<0>', text) # Escape headers
|
||||
text = re.sub(r"^(\s*)- ", '\\1\\- ', text) # Escape lists
|
||||
text = re.sub(r"^(\s*\d+)\. ", "\\1\\. ", text) # Escape numbered lists
|
||||
return text
|
||||
"""Sanitizes given text to escape markdown formatting. It is used in values that will be visible on Discord in messages"""
|
||||
text = text.replace("\\", "\\\\").replace('//', '/\\/').replace("](", "]\\(") # replace escaping and links
|
||||
text = re.sub(r"([`_*~:<>{}@|])", "\\\\\\1", text) # Escape common Markdown characters
|
||||
text = re.sub(r"^(#+ )", '\\\\\\1', text, 0, re.MULTILINE) # Escape headers
|
||||
text = re.sub(r"^(\s*)- ", '\\1\\\\- ', text, 0, re.MULTILINE) # Escape lists
|
||||
text = re.sub(r"^(\s*\d+)\. ", "\\1\\\\. ", text, 0, re.MULTILINE) # Escape numbered lists
|
||||
return text
|
||||
|
||||
|
||||
def sanitize_to_url(text: str) -> str: # TODO ) replaces needed?
|
||||
|
|
|
@ -281,7 +281,7 @@ def prepare_paths(path: str, dry=False):
|
|||
False if it appears invalid
|
||||
dictionary when it appears valid"""
|
||||
try:
|
||||
request = requests.get(url, timeout=5)
|
||||
request = requests.get(url, timeout=5, headers=settings["header"])
|
||||
if request.status_code == requests.codes.ok:
|
||||
if request.json()["query"]["general"] is not None:
|
||||
return request
|
||||
|
|
Loading…
Reference in a new issue