using System.Text; using Telegram.Bot.Types; namespace Kruzya.TelegramBot.Core.Extensions { public static class UserExtension { public static string ToHtml(this User user, bool byUsername = false) { var text = new StringBuilder(); text.Append($""); if (byUsername && !string.IsNullOrWhiteSpace(user.Username)) { text.Append(user.Username); } else { text.Append($"{user.FirstName} {user.LastName}".Trim().HtmlEncode()); } return text.Append("").ToString(); } } }