mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Adding function user_link for html and markdown text decorations
This commit is contained in:
parent
4a4eb51bd4
commit
9e71a6cbc4
1 changed files with 6 additions and 0 deletions
|
|
@ -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}*"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue