Skip to content

Commit db28e25

Browse files
committed
Implicit construction of ChatId from User
1 parent 1978161 commit db28e25

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

src/Telegram.Bot/TelegramBotClient.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ public TimeSpan Timeout
3838
set => _httpClient.Timeout = value;
3939
}
4040

41-
#region For testing purposes
42-
internal string BaseRequestUrl => _options.BaseRequestUrl;
43-
internal string BaseFileUrl => _options.BaseFileUrl;
44-
#endregion
45-
4641
#pragma warning disable CS1591
4742
public delegate Task OnUpdateHandler(Update update);
4843
public delegate Task OnMessageHandler(Message message, UpdateType type);

src/Telegram.Bot/Types/ChatId.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ public ChatId(string username)
6565
[return: NotNullIfNotNull(nameof(chatFullInfo))]
6666
public static implicit operator ChatId?(ChatFullInfo? chatFullInfo) => chatFullInfo is null ? null : new(chatFullInfo.Id);
6767

68+
/// <summary>Convert a <see cref="User"/> object to a <see cref="ChatId"/></summary>
69+
[return: NotNullIfNotNull(nameof(user))]
70+
public static implicit operator ChatId?(User? user) => user is null ? null : new(user.Id);
71+
6872
/// <summary>Compares two ChatId objects</summary>
6973
public static bool operator ==(ChatId? obj1, ChatId? obj2)
7074
{

0 commit comments

Comments
 (0)