From a4f6d00bd0adf1cd88da71c48b3447f54432699f Mon Sep 17 00:00:00 2001 From: Wizou Date: Tue, 21 Dec 2021 02:28:35 +0100 Subject: [PATCH] fix InformationalVersion --- src/Client.cs | 20 ++++++++------------ src/WTelegramClient.csproj | 1 - 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Client.cs b/src/Client.cs index 6b9111e..4c7d296 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -718,7 +718,10 @@ namespace WTelegram result = reader.ReadTLValue(type); } if (type.IsEnum) result = Enum.ToObject(type, result); - Log(1, ""); + if (result is RpcError rpcError) + Helpers.Log(4, $" → RpcError {rpcError.error_code,3} {rpcError.error_message,-24} #{(short)msgId.GetHashCode():X4}"); + else + Helpers.Log(1, $" → {result?.GetType().Name,-37} #{(short)msgId.GetHashCode():X4}"); tcs.SetResult(result); } catch (Exception ex) @@ -731,19 +734,11 @@ namespace WTelegram { result = reader.ReadTLObject(); if (MsgIdToStamp(msgId) >= _session.SessionStart) - Log(4, "for unknown msgId "); + Helpers.Log(4, $" → {result?.GetType().Name,-37} for unknown msgId #{(short)msgId.GetHashCode():X4}"); else - Log(1, "for past msgId "); + Helpers.Log(1, $" → {result?.GetType().Name,-37} for past msgId #{(short)msgId.GetHashCode():X4}"); } return new RpcResult { req_msg_id = msgId, result = result }; - - void Log(int level, string msgIdprefix) - { - if (result is RpcError rpcError) - Helpers.Log(4, $" → RpcError {rpcError.error_code,3} {rpcError.error_message,-24} {msgIdprefix}#{(short)msgId.GetHashCode():X4}"); - else - Helpers.Log(level, $" → {result?.GetType().Name,-37} {msgIdprefix}#{(short)msgId.GetHashCode():X4}"); - } } private (Type type, TaskCompletionSource tcs) PullPendingRequest(long msgId) @@ -876,7 +871,8 @@ namespace WTelegram bool retryLast = badMsgNotification.bad_msg_id == _dcSession.LastSentMsgId; var lastSentMsg = _lastSentMsg; _sendSemaphore.Release(); - Helpers.Log(4, $"BadMsgNotification {badMsgNotification.error_code} for msg #{(short)badMsgNotification.bad_msg_id.GetHashCode():X4}"); + var logLevel = badMsgNotification.error_code == 48 ? 2 : 4; + Helpers.Log(logLevel, $"BadMsgNotification {badMsgNotification.error_code} for msg #{(short)badMsgNotification.bad_msg_id.GetHashCode():X4}"); switch (badMsgNotification.error_code) { case 32: // msg_seqno too low (the server has already received a message with a lower msg_id but with either a higher or an equal and odd seqno) diff --git a/src/WTelegramClient.csproj b/src/WTelegramClient.csproj index 7c40646..6932929 100644 --- a/src/WTelegramClient.csproj +++ b/src/WTelegramClient.csproj @@ -21,7 +21,6 @@ true https://github.com/wiz0u/WTelegramClient.git git - source Telegram;Client;Api;UserBot;MTProto;TLSharp;OpenTl README.md IDE0079;0419;1573;1591