From 9e71a6cbc47d86cfcbdf1ecd17561bd81fa01f4c Mon Sep 17 00:00:00 2001
From: Yura <81070564+ProgramUser5353@users.noreply.github.com>
Date: Sat, 26 Feb 2022 15:21:52 +0200
Subject: [PATCH] Adding function user_link for html and markdown text
decorations
---
aiogram/utils/text_decorations.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/aiogram/utils/text_decorations.py b/aiogram/utils/text_decorations.py
index ae9af7d4..b162109f 100644
--- a/aiogram/utils/text_decorations.py
+++ b/aiogram/utils/text_decorations.py
@@ -147,6 +147,9 @@ class TextDecoration(ABC):
class HtmlDecoration(TextDecoration):
def link(self, value: str, link: str) -> str:
return f'{value}'
+
+ 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}"
@@ -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}*"