add pyTelegramBotAPI

This commit is contained in:
jxxghp
2023-06-09 07:37:08 +08:00
parent fa4159c563
commit f5f9f5349a
3 changed files with 46 additions and 75 deletions

View File

@ -512,3 +512,21 @@ class StringUtils:
大写首字母兼容None
"""
return s.title() if s else s
@staticmethod
def escape_markdown(content: str) -> str:
"""
Escapes Markdown characters in a string of Markdown.
Credits to: simonsmh
:param content: The string of Markdown to escape.
:type content: :obj:`str`
:return: The escaped string.
:rtype: :obj:`str`
"""
parses = re.sub(r"([_*\[\]()~`>#+\-=|.!{}])", r"\\\1", content)
reparse = re.sub(r"\\\\([_*\[\]()~`>#+\-=|.!{}])", r"\1", parses)
return reparse