mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
fixing escape()
fixing escape() as replacing a None would throw an exception 'NoneType' object has no attribute 'replace'. useful in case of escaping a None string given from message.from_user.last_name as you dont know wether the user has a last name or not
This commit is contained in:
parent
109ae69f27
commit
34acae9a59
@ -399,8 +399,12 @@ def escape(text: str) -> str:
|
|||||||
:return: the escaped text
|
:return: the escaped text
|
||||||
"""
|
"""
|
||||||
chars = {"&": "&", "<": "<", ">": ">"}
|
chars = {"&": "&", "<": "<", ">": ">"}
|
||||||
for old, new in chars.items(): text = text.replace(old, new)
|
if text == None:
|
||||||
return text
|
return None
|
||||||
|
else:
|
||||||
|
for old, new in chars.items():
|
||||||
|
text = text.replace(old, new)
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
def user_link(user: types.User, include_id: bool=False) -> str:
|
def user_link(user: types.User, include_id: bool=False) -> str:
|
||||||
|
Loading…
Reference in New Issue
Block a user