mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
Just a few tweaks
This commit is contained in:
parent
ceefcfb0a1
commit
45030b6731
|
@ -42,7 +42,7 @@ 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"""
|
||||
return re.sub(r"([`_*~:<>{}@|\\])", "\\\\\\1", text, 0).replace('//', "/\\/").replace('](', "]\\(")
|
||||
return re.sub(r"([`_*~:<>{}@|\\])", "\\\\\\1", text).replace('//', "/\\/").replace('](', "]\\(")
|
||||
|
||||
|
||||
def sanitize_to_url(text: str) -> str: # TODO ) replaces needed?
|
||||
|
|
|
@ -62,6 +62,10 @@ def check_tables():
|
|||
|
||||
def add_entry(pageid: int, revid: int, logid: int, message, message_id: str):
|
||||
"""Add an edit or log entry to the DB
|
||||
:param message:
|
||||
:param logid:
|
||||
:param revid:
|
||||
:param pageid:
|
||||
:param message_id:
|
||||
"""
|
||||
db_cursor.execute("INSERT INTO messages (message_id, content) VALUES (?, ?)", (message_id, message))
|
||||
|
|
|
@ -152,7 +152,7 @@ class ContentParser(HTMLParser):
|
|||
def handle_data(self, data):
|
||||
def escape_formatting(data: str) -> str:
|
||||
"""Escape Discord formatting"""
|
||||
return re.sub(r"([`_*~<>{}@/|\\])", "\\\\\\1", data, 0)
|
||||
return re.sub(r"([`_*~<>{}@/|\\])", "\\\\\\1", data)
|
||||
data = escape_formatting(data)
|
||||
if self.current_tag == "ins" and self.ins_length <= 1000:
|
||||
self.ins_length += len("**" + data + "**")
|
||||
|
|
|
@ -411,7 +411,7 @@ class Wiki(object):
|
|||
except KeyError:
|
||||
self.tags[tag["name"]] = None # Tags with no display name are hidden and should not appear on RC as well
|
||||
for message in startup_info["allmessages"]:
|
||||
if not "missing" in message: # ignore missing strings
|
||||
if "missing" not in message: # ignore missing strings
|
||||
self.mw_messages[message["name"]] = message["*"]
|
||||
else:
|
||||
logging.warning("Could not fetch the MW message translation for: {}".format(message["name"]))
|
||||
|
|
Loading…
Reference in a new issue