From 0a91487ea7457368333fcb4c699edf2efd02ab51 Mon Sep 17 00:00:00 2001 From: CheshireCaat Date: Thu, 23 Jan 2020 10:11:24 +0300 Subject: [PATCH] Add methods for working with usernames. (#897) Added methods for working with usernames: Check username (Validates a username and checks availability) Update username (Changes username for the current user) --- TLSharp.Core/TelegramClient.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index d86b349..ffc334c 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -234,6 +234,26 @@ namespace TLSharp.Core return (T)result; } + public async Task UpdateUsernameAsync(string username) + { + if (!IsUserAuthorized()) + throw new InvalidOperationException("Authorize user first!"); + + var req = new TLRequestUpdateUsername { Username = username }; + + return await SendRequestAsync(req); + } + + public async Task CheckUsernameAsync(string username) + { + if (!IsUserAuthorized()) + throw new InvalidOperationException("Authorize user first!"); + + var req = new TLRequestCheckUsername { Username = username }; + + return await SendRequestAsync(req); + } + public async Task ImportContactsAsync(IReadOnlyList contacts) { if (!IsUserAuthorized())