From 66e829680e251d6661dc82f10168611fca766863 Mon Sep 17 00:00:00 2001 From: zkhssb Date: Wed, 12 Jul 2023 19:49:54 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0RestSharp=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=92=8C=E9=A1=B9=E7=9B=AE=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QQChannelSharp/OpenApi/OpenApiFactory.cs | 14 +++++++------- QQChannelSharp/QQChannelSharp.csproj | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/QQChannelSharp/OpenApi/OpenApiFactory.cs b/QQChannelSharp/OpenApi/OpenApiFactory.cs index bc78b6c..67e21ca 100644 --- a/QQChannelSharp/OpenApi/OpenApiFactory.cs +++ b/QQChannelSharp/OpenApi/OpenApiFactory.cs @@ -15,6 +15,11 @@ public static IOpenApi Create(OpenApiOptions options) { HttpClient httpClient; RestClient restClient; + var opts = new RestClientOptions() + { + ThrowOnAnyError = false, + Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(options.BotInfo.FullToken, "Bot") + }; if (options.Retry) { /* @@ -25,10 +30,7 @@ public static IOpenApi Create(OpenApiOptions options) .OrResult(x => x.StatusCode is >= HttpStatusCode.InternalServerError or HttpStatusCode.RequestTimeout or HttpStatusCode.GatewayTimeout) .WaitAndRetryAsync(Backoff.DecorrelatedJitterBackoffV2(TimeSpan.FromSeconds(1), 5)); */ - var opts = new RestClientOptions() - { - ThrowOnAnyError = false - }; + var handler = new PolicyHttpMessageHandler(DecorrelatedJitterBackoffV2.GetRetryIntervals(options.RetryCount, options.RetryInterval), new LoggerHttpHandler()); httpClient = new(handler); httpClient.BaseAddress = new Uri(options.BotInfo.SandBox ? "https://sandbox.api.sgroup.qq.com/" : "https://api.sgroup.qq.com/"); @@ -38,10 +40,8 @@ public static IOpenApi Create(OpenApiOptions options) { httpClient = new(new LoggerHttpHandler()); httpClient.BaseAddress = new Uri(options.BotInfo.SandBox ? "https://sandbox.api.sgroup.qq.com/" : "https://api.sgroup.qq.com/"); - restClient = new(httpClient); + restClient = new(httpClient, opts); } - // 添加验证Header "Bot {appId}.{token}" - restClient.UseAuthenticator(new OAuth2AuthorizationRequestHeaderAuthenticator(options.BotInfo.FullToken, "Bot")); return new OpenApi(restClient, httpClient); } } diff --git a/QQChannelSharp/QQChannelSharp.csproj b/QQChannelSharp/QQChannelSharp.csproj index 62d0e0f..d67d85a 100644 --- a/QQChannelSharp/QQChannelSharp.csproj +++ b/QQChannelSharp/QQChannelSharp.csproj @@ -14,7 +14,7 @@ True Apache-2.0 README.md - 1.0.0-beta2 + 1.0.0-beta3 @@ -27,7 +27,7 @@ - +