From 45030b67311cb3312f8f9826cdbcab7a436f46a1 Mon Sep 17 00:00:00 2001 From: Frisk Date: Sun, 9 May 2021 23:01:23 +0200 Subject: [PATCH] Just a few tweaks --- src/api/util.py | 2 +- src/fileio/database.py | 4 ++++ src/misc.py | 2 +- src/wiki.py | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/api/util.py b/src/api/util.py index 7cd20a4..b5e55d5 100644 --- a/src/api/util.py +++ b/src/api/util.py @@ -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? diff --git a/src/fileio/database.py b/src/fileio/database.py index b4fd946..888d22a 100644 --- a/src/fileio/database.py +++ b/src/fileio/database.py @@ -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)) diff --git a/src/misc.py b/src/misc.py index 2466340..fe26bc7 100644 --- a/src/misc.py +++ b/src/misc.py @@ -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 + "**") diff --git a/src/wiki.py b/src/wiki.py index 1b0f547..4cbb8e6 100644 --- a/src/wiki.py +++ b/src/wiki.py @@ -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"]))