From c6b675625420fbb4f52f254d30aaf0a398f03109 Mon Sep 17 00:00:00 2001 From: Cyl18 Date: Mon, 22 Jan 2024 19:18:34 +0800 Subject: [PATCH] =?UTF-8?q?debug=E4=BA=86=E5=8D=8A=E5=A4=A9=E6=88=91?= =?UTF-8?q?=E7=89=B9=E4=B9=88=E5=BC=80=E4=BA=86=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WFBot/Features/Commands/SearchCommands.cs | 35 ++++++++++++++++------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/WFBot/Features/Commands/SearchCommands.cs b/WFBot/Features/Commands/SearchCommands.cs index b968159..e1c6330 100644 --- a/WFBot/Features/Commands/SearchCommands.cs +++ b/WFBot/Features/Commands/SearchCommands.cs @@ -103,7 +103,10 @@ Task Riven(string word) public static async Task> GetRivenAuctions(string urlname) { var header = new List> - {new KeyValuePair("Platform", platform)}; + { + new KeyValuePair("Platform", platform), + new KeyValuePair("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36") + }; var auctions = await WebHelper.DownloadJsonAsync(Config.Instance.UseWFBotProxy ? $"https://wfbot.cyan.cafe/api/WFBotProxy/{Config.Instance.WFBotProxyToken}*https://api.warframe.market/v1/auctions/search{Uri.EscapeDataString($"?type=riven&weapon_url_name={urlname}&sort_by=price_desc")}" : $"https://api.warframe.market/v1/auctions/search?type=riven&weapon_url_name={urlname}&sort_by=price_desc", header); @@ -133,20 +136,30 @@ public async Task SendRivenAuctions(string name) return null; } } - var auctions = await GetRivenAuctions(weapon.urlname); - if (AsyncContext.GetUseImageRendering()) + try { - var rivens = auctions.Take(Config.Instance.WFASearchCount).ToList(); - var image = ImageRenderHelper.RivenAuction(rivens, weapon); - SendImageAndText(image, rivens.Select(x => x.Owner.IngameName).Connect(", ")); - return null; + + var auctions = await GetRivenAuctions(weapon.urlname); + + if (AsyncContext.GetUseImageRendering()) + { + var rivens = auctions.Take(Config.Instance.WFASearchCount).ToList(); + var image = ImageRenderHelper.RivenAuction(rivens, weapon); + SendImageAndText(image, rivens.Select(x => x.Owner.IngameName).Connect(", ")); + return null; + } + else + { + var msg = WFFormatter.ToString(auctions.Take(Config.Instance.WFASearchCount).ToList(), weapon).AddPlatformInfo(); + sb.AppendLine(msg); + + } } - else + catch (Exception e) { - var msg = WFFormatter.ToString(auctions.Take(Config.Instance.WFASearchCount).ToList(), weapon).AddPlatformInfo(); - sb.AppendLine(msg); - + Console.WriteLine(e); + throw; } }