From 796c36230a50409335630894a0aa93ca817d06de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B1=B3?= Date: Thu, 17 Oct 2024 01:18:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=B9=E5=B9=95=E5=8F=91=E9=80=81=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=88=87=E6=8D=A2=E7=99=BB=E9=99=86=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=BA=90=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/RuntimeObject/Danmu.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Core/RuntimeObject/Danmu.cs b/Core/RuntimeObject/Danmu.cs index 1e340323..8201074c 100644 --- a/Core/RuntimeObject/Danmu.cs +++ b/Core/RuntimeObject/Danmu.cs @@ -15,6 +15,7 @@ using static Core.RuntimeObject.Danmu; using Core.Network; using AngleSharp.Dom; +using Core.Account; namespace Core.RuntimeObject { @@ -31,15 +32,19 @@ public class Danmu /// /// 房间号(长房间号) /// 发送信息(不能超过20个字符) - public static void SendDanmu(string roomId, string Message) + public static void SendDanmu(string roomId, string Message,AccountInformation account = null) { Task.Run(() => { + if(account==null) + { + account = Account.AccountInformation; + } try { CookieContainer CK = new CookieContainer { MaxCookieSize = 4096, PerDomainCapacity = 50 }; - string[] cook = Account.AccountInformation.strCookies.Replace(" ", "").Split(';'); + string[] cook = account.strCookies.Replace(" ", "").Split(';'); for (int i = 0; i < cook.Length; i++) { if (!string.IsNullOrEmpty(cook[i])) @@ -57,8 +62,8 @@ public static void SendDanmu(string roomId, string Message) { "msg", Message }, { "rnd", (DateTime.Now - TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1))).TotalSeconds.ToString() }, { "roomid", roomId }, - { "csrf_token", Account.AccountInformation.CsrfToken }, - { "csrf", Account.AccountInformation.CsrfToken } + { "csrf_token", account.CsrfToken }, + { "csrf", account.CsrfToken } }; @@ -70,8 +75,8 @@ public static void SendDanmu(string roomId, string Message) req.ContentType = "application/x-www-form-urlencoded"; req.UserAgent = Config.Core_RunConfig._HTTP_UA; - if (RuntimeObject.Account.AccountInformation != null && RuntimeObject.Account.AccountInformation.State) - req.Headers.Add("Cookie", RuntimeObject.Account.AccountInformation.strCookies); + if (account != null && account.State) + req.Headers.Add("Cookie", account.strCookies); #region 添加Post 参数 StringBuilder builder = new StringBuilder(); int i = 0; @@ -123,6 +128,7 @@ public static void SendDanmu(string roomId, string Message) } if(result.Contains("\"code\":0")) { + Log.Info(nameof(SendDanmu), $"账号【{account.Uid}】在【{roomId}】中发送弹幕【{Message}】成功"); //发送成功 } }