Reformatting
This commit is contained in:
@@ -3,9 +3,10 @@ script for helper functions for bot related stuff
|
||||
"""
|
||||
__author__ = "Florian Kellermann, Linus Eickhoff"
|
||||
__date__ = "10.05.2022"
|
||||
__version__ = "1.0.0"
|
||||
__version__ = "1.0.0"
|
||||
__license__ = "None"
|
||||
|
||||
|
||||
def contains_markdownv1_symbols(text):
|
||||
""" checks if text contains markdown symbols
|
||||
:type text: string
|
||||
@@ -16,13 +17,13 @@ def contains_markdownv1_symbols(text):
|
||||
|
||||
:rtype: bool
|
||||
"""
|
||||
if text.find("_") != -1 or text.find("*") != -1 or text.find("`") != -1: # check if text contains relevant markdown symbols
|
||||
if text.find("_") != -1 or text.find("*") != -1 or text.find("`") != -1: # check if text contains relevant markdown symbols
|
||||
return True
|
||||
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def make_markdown_proof(text): # used to avoid errors related to markdown parsemode for telegram messaging
|
||||
def make_markdown_proof(text): # used to avoid errors related to markdown parsemode for telegram messaging
|
||||
""" makes text markdown proof
|
||||
:type text: string
|
||||
|
||||
@@ -34,7 +35,7 @@ def make_markdown_proof(text): # used to avoid errors related to markdown parsem
|
||||
"""
|
||||
text = str(text)
|
||||
|
||||
text = text.replace("_", "\\_") # replace _ with \_ because \ is used as escape character in markdown, double escape is needed because \ is also a escape character in strings
|
||||
text = text.replace("_", "\\_") # replace _ with \_ because \ is used as escape character in markdown, double escape is needed because \ is also a escape character in strings
|
||||
text = text.replace("*", "\\*")
|
||||
text = text.replace("`", "\\`")
|
||||
text = text.replace("[", "\\[")
|
||||
@@ -57,7 +58,6 @@ def make_markdown_proof(text): # used to avoid errors related to markdown parsem
|
||||
text = text.replace("$", "\\$")
|
||||
text = text.replace("%", "\\%")
|
||||
|
||||
|
||||
return text
|
||||
|
||||
|
||||
@@ -65,4 +65,4 @@ if __name__ == '__main__':
|
||||
print("this is a module for helper functions for the bot and should not be run directly")
|
||||
print(make_markdown_proof("_test_"))
|
||||
text = make_markdown_proof("_test_")
|
||||
print(f"{text}")
|
||||
print(f"{text}")
|
||||
|
||||
Reference in New Issue
Block a user