mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
Fix diario text bug
This commit is contained in:
parent
7613e368dc
commit
11b119b08e
2 changed files with 8 additions and 6 deletions
11
strings.py
11
strings.py
|
@ -7,10 +7,13 @@ class SafeDict(dict):
|
|||
return key
|
||||
|
||||
|
||||
def safely_format_string(string: str, words: typing.Dict[str, str]) -> str:
|
||||
escaped = {}
|
||||
for key in words:
|
||||
escaped[key] = words[key].replace("<", "<").replace(">", ">")
|
||||
def safely_format_string(string: str, words: typing.Dict[str, str], ignore_escaping=False) -> str:
|
||||
if ignore_escaping:
|
||||
escaped = words
|
||||
else:
|
||||
escaped = {}
|
||||
for key in words:
|
||||
escaped[key] = words[key].replace("<", "<").replace(">", ">")
|
||||
return string.format_map(SafeDict(**escaped))
|
||||
|
||||
|
||||
|
|
|
@ -53,8 +53,7 @@ sentry = raven.Client(config["Sentry"]["token"],
|
|||
|
||||
|
||||
def reply_msg(bot: telegram.Bot, chat_id: int, string: str, ignore_escaping=False, **kwargs) -> telegram.Message:
|
||||
if not ignore_escaping:
|
||||
string = strings.safely_format_string(string, words=kwargs)
|
||||
string = strings.safely_format_string(string, ignore_escaping=ignore_escaping, words=kwargs)
|
||||
return bot.send_message(chat_id, string,
|
||||
parse_mode="HTML",
|
||||
disable_web_page_preview=True)
|
||||
|
|
Loading…
Reference in a new issue