mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +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
|
return key
|
||||||
|
|
||||||
|
|
||||||
def safely_format_string(string: str, words: typing.Dict[str, str]) -> str:
|
def safely_format_string(string: str, words: typing.Dict[str, str], ignore_escaping=False) -> str:
|
||||||
escaped = {}
|
if ignore_escaping:
|
||||||
for key in words:
|
escaped = words
|
||||||
escaped[key] = words[key].replace("<", "<").replace(">", ">")
|
else:
|
||||||
|
escaped = {}
|
||||||
|
for key in words:
|
||||||
|
escaped[key] = words[key].replace("<", "<").replace(">", ">")
|
||||||
return string.format_map(SafeDict(**escaped))
|
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:
|
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, ignore_escaping=ignore_escaping, words=kwargs)
|
||||||
string = strings.safely_format_string(string, words=kwargs)
|
|
||||||
return bot.send_message(chat_id, string,
|
return bot.send_message(chat_id, string,
|
||||||
parse_mode="HTML",
|
parse_mode="HTML",
|
||||||
disable_web_page_preview=True)
|
disable_web_page_preview=True)
|
||||||
|
|
Loading…
Reference in a new issue