[common] improve logging

This commit is contained in:
Andriy
2022-12-14 12:58:12 +02:00
parent 82129d8006
commit ffffe2a48a
4 changed files with 32 additions and 3 deletions
+20
View File
@@ -0,0 +1,20 @@
using System;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
namespace Kruzya.TelegramBot.Core.Extensions;
public static class ChatExtension
{
public static string ToLog(this Chat chat)
{
var title = chat.Type switch
{
ChatType.Private => $"{chat.FirstName} {chat.LastName}".Trim(),
_ => chat.Title
};
return $"{title} (ID: {chat.Id}, Username: {chat.Username ?? "N/A"})";
}
}