Adding function user_link for html and markdown text decorations

This commit is contained in:
Yura 2022-02-26 15:21:52 +02:00 committed by GitHub
parent 4a4eb51bd4
commit 9e71a6cbc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -147,6 +147,9 @@ class TextDecoration(ABC):
class HtmlDecoration(TextDecoration):
def link(self, value: str, link: str) -> str:
return f'<a href="{link}">{value}</a>'
def user_link(self, value: str, user_id: int) -> str:
return link(value, f"tg://openmessage?user_id={user_id}")
def bold(self, value: str) -> str:
return f"<b>{value}</b>"
@ -181,6 +184,9 @@ class MarkdownDecoration(TextDecoration):
def link(self, value: str, link: str) -> str:
return f"[{value}]({link})"
def user_link(self, value: str, user_id: int) -> str:
return link(value, f"tg://openmessage?user_id={user_id}")
def bold(self, value: str) -> str:
return f"*{value}*"