mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
21 lines
625 B
C#
21 lines
625 B
C#
|
|
using System.Text;
|
||
|
|
using Telegram.Bot.Types;
|
||
|
|
|
||
|
|
namespace Kruzya.TelegramBot.Core.Extensions
|
||
|
|
{
|
||
|
|
public static class UserExtension
|
||
|
|
{
|
||
|
|
public static string ToHtml(this User user)
|
||
|
|
{
|
||
|
|
var text = new StringBuilder();
|
||
|
|
text.Append("<a href=\"tg://user?id={member.Id}\">");
|
||
|
|
if (!string.IsNullOrWhiteSpace(user.Username))
|
||
|
|
text.Append(user.Username);
|
||
|
|
else
|
||
|
|
text.Append($"{user.FirstName} {user.LastName}".Trim().HtmlEncode());
|
||
|
|
text.Append("</a>");
|
||
|
|
|
||
|
|
return text.ToString();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|