From c8a0882587f072730b568ad9551e65d089de05c2 Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Tue, 28 May 2024 00:37:58 +0200 Subject: [PATCH] Fix: ReactorError wasn't always triggered correctly on connection lost --- src/Client.Helpers.cs | 2 +- src/Client.cs | 4 ++-- src/WTelegramClient.csproj | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Client.Helpers.cs b/src/Client.Helpers.cs index 3870a2f..0303d72 100644 --- a/src/Client.Helpers.cs +++ b/src/Client.Helpers.cs @@ -620,7 +620,7 @@ namespace WTelegram chats = (await this.Messages_GetChats(chat.chat_id)).chats }; case InputPeerChannel channel: return await this.Channels_EditAdmin(channel, user, - new ChatAdminRights { flags = is_admin ? (ChatAdminRights.Flags)0x8BF : 0 }, null); + new ChatAdminRights { flags = is_admin ? (ChatAdminRights.Flags)0x1E8BF : 0 }, null); default: throw new ArgumentException(OnlyChatChannel); } diff --git a/src/Client.cs b/src/Client.cs index 6572d5c..763c977 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -366,7 +366,7 @@ namespace WTelegram lock (_pendingRpcs) // abort all pending requests { foreach (var rpc in _pendingRpcs.Values) - rpc.tcs.SetException(ex); + rpc.tcs.TrySetException(ex); _pendingRpcs.Clear(); _bareRpc = null; } @@ -879,9 +879,9 @@ namespace WTelegram if (defaultDc != 0) _dcSession ??= _session.DCSessions.GetValueOrDefault(defaultDc); _dcSession ??= new() { Id = Helpers.RandomLong() }; _dcSession.Client = this; + _dcSession.DataCenter = null; Helpers.Log(2, $"Connecting to {endpoint}..."); tcpClient = await TcpHandler(endpoint.Address.ToString(), endpoint.Port); - _dcSession.DataCenter = null; } } } diff --git a/src/WTelegramClient.csproj b/src/WTelegramClient.csproj index e2acf39..f4dedc4 100644 --- a/src/WTelegramClient.csproj +++ b/src/WTelegramClient.csproj @@ -16,7 +16,7 @@ Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 179 Release Notes: $(ReleaseNotes.Replace("|", "%0D%0A").Replace(" - ","%0D%0A- ").Replace(" ", "%0D%0A%0D%0A")) Copyright © Olivier Marcoux 2021-2024 MIT - https://github.com/wiz0u/WTelegramClient + https://wiz0u.github.io/WTelegramClient logo.png true https://github.com/wiz0u/WTelegramClient.git