🚧 Core improvements

This commit is contained in:
2020-03-01 22:46:07 +04:00
parent bae09d5ba4
commit a7b3f97f1a
6 changed files with 73 additions and 4 deletions
+21
View File
@@ -0,0 +1,21 @@
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();
}
}
}