From 7d5823e8e4930081d8f1322e0d692a38a7039cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=85=E6=B5=A9=E4=B8=9C?= <1083092844@qq.com> Date: Fri, 29 Mar 2024 17:46:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E7=B1=BB?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=86=99=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BarrageGrab/AppSetting.cs | 8 ++++---- BarrageGrab/ComPortServer.cs | 8 ++++---- BarrageGrab/Forms/FormView.cs | 26 +++++++++++++------------- BarrageGrab/Logger.cs | 6 +++--- BarrageGrab/Program.cs | 8 ++++---- BarrageGrab/Proxy/SystemProxy.cs | 6 +++--- BarrageGrab/Proxy/TitaniumProxy.cs | 16 ++++++++-------- BarrageGrab/WsBarrageServer.cs | 14 +++++++------- BarrageGrab/WssBarrageGrab.cs | 2 +- 9 files changed, 47 insertions(+), 47 deletions(-) diff --git a/BarrageGrab/AppSetting.cs b/BarrageGrab/AppSetting.cs index 45be200..b5543e6 100644 --- a/BarrageGrab/AppSetting.cs +++ b/BarrageGrab/AppSetting.cs @@ -10,13 +10,13 @@ using System.Drawing; namespace BarrageGrab { - internal class Appsetting + internal class AppSetting { - private static readonly Appsetting ins = new Appsetting(); + private static readonly AppSetting ins = new AppSetting(); - public static Appsetting Current { get { return ins; } } + public static AppSetting Current { get { return ins; } } - public Appsetting() + public AppSetting() { try { diff --git a/BarrageGrab/ComPortServer.cs b/BarrageGrab/ComPortServer.cs index 318ab37..bbdda9a 100644 --- a/BarrageGrab/ComPortServer.cs +++ b/BarrageGrab/ComPortServer.cs @@ -18,7 +18,7 @@ namespace BarrageGrab static ComPortServer() { - if (Appsetting.Current.UseComPortFilter) + if (AppSetting.Current.UseComPortFilter) { jsEngine = JsEngine.CreateNewEngine(); var jsFile = JsEngine.GetJsFile("comPortFilter.js"); @@ -28,8 +28,8 @@ namespace BarrageGrab public ComPortServer(WsBarrageServer server) { - string portName = Appsetting.Current.ComPort; - int baudRate = Appsetting.Current.ComBaudRate; + string portName = AppSetting.Current.ComPort; + int baudRate = AppSetting.Current.ComBaudRate; if (portName.IsNullOrWhiteSpace()) { return; @@ -50,7 +50,7 @@ namespace BarrageGrab { if (!sendPort.IsOpen) return; if (e == null) return; - if (!Appsetting.Current.UseComPortFilter) + if (!AppSetting.Current.UseComPortFilter) { var json = e.ToJson() + "\r\n"; var jbuff = Encoding.UTF8.GetBytes(json); diff --git a/BarrageGrab/Forms/FormView.cs b/BarrageGrab/Forms/FormView.cs index 72bbe50..b322e6b 100644 --- a/BarrageGrab/Forms/FormView.cs +++ b/BarrageGrab/Forms/FormView.cs @@ -32,7 +32,7 @@ namespace BarrageGrab AppRuntime.RoomCaches.OnCache += RoomCaches_OnCache; this.txb_wsaddr.Text = barServer.ServerLocation; this.txb_upstreamProxy.Text = proxy.HttpUpstreamProxy; - this.cbx_barrageLog.Checked = Appsetting.Current.BarrageLog; + this.cbx_barrageLog.Checked = AppSetting.Current.BarrageLog; InitTabPages(); } @@ -67,17 +67,17 @@ namespace BarrageGrab if (page == this.tabPage_Ws) { type = "ws"; - ck.Checked = Appsetting.Current.PushFilter.Contains(label.Key); + ck.Checked = AppSetting.Current.PushFilter.Contains(label.Key); } if (page == this.tabPage_Console) { type = "console"; - ck.Checked = Appsetting.Current.PrintFilter.Contains(label.Key); + ck.Checked = AppSetting.Current.PrintFilter.Contains(label.Key); } if (page == this.tabPage_Log) { type = "log"; - ck.Checked = Appsetting.Current.LogFilter.Contains(label.Key); + ck.Checked = AppSetting.Current.LogFilter.Contains(label.Key); } ck.Name = $"cbx_bartype_{type}_{label.Key}"; ck.CheckedChanged += Ck_CheckedChanged; @@ -94,17 +94,17 @@ namespace BarrageGrab var selected = GetCheckedBarTypes((FlowLayoutPanel)cbx.Parent); if (cbx.Parent.Parent == this.tabPage_Console) { - Appsetting.Current.PrintFilter = selected; + AppSetting.Current.PrintFilter = selected; } if (cbx.Parent.Parent == this.tabPage_Ws) { - Appsetting.Current.PushFilter = selected; + AppSetting.Current.PushFilter = selected; } if(cbx.Parent.Parent == this.tabPage_Log) { - Appsetting.Current.LogFilter = selected; + AppSetting.Current.LogFilter = selected; } - Appsetting.Current.Save(); + AppSetting.Current.Save(); } private int[] GetCheckedBarTypes(FlowLayoutPanel panel) @@ -171,7 +171,7 @@ namespace BarrageGrab { //将弹幕输出到richTextBox //颜色转换 - Color color = Appsetting.Current.ColorMap[e.MsgType].Item2; + Color color = AppSetting.Current.ColorMap[e.MsgType].Item2; string msg = e.Message; this.Invoke(new Action(() => @@ -218,8 +218,8 @@ namespace BarrageGrab try { proxy.SetUpstreamProxy(text); - Appsetting.Current.UpstreamProxy = text; - Appsetting.Current.Save(); + AppSetting.Current.UpstreamProxy = text; + AppSetting.Current.Save(); } catch (Exception ex) { @@ -231,8 +231,8 @@ namespace BarrageGrab private void cbx_barrageLog_CheckedChanged(object sender, EventArgs e) { var checker = (CheckBox)sender; - Appsetting.Current.BarrageLog = checker.Checked; - Appsetting.Current.Save(); + AppSetting.Current.BarrageLog = checker.Checked; + AppSetting.Current.Save(); } } } diff --git a/BarrageGrab/Logger.cs b/BarrageGrab/Logger.cs index 32cd6bc..507e082 100644 --- a/BarrageGrab/Logger.cs +++ b/BarrageGrab/Logger.cs @@ -94,9 +94,9 @@ namespace BarrageGrab /// 弹幕内容 public static void LogBarrage(PackMsgType type, Msg msg) { - if (!Appsetting.Current.BarrageLog) return; + if (!AppSetting.Current.BarrageLog) return; if (type == PackMsgType.无) return; - if (Appsetting.Current.LogFilter.Any() && !Appsetting.Current.LogFilter.Contains(type.GetHashCode())) return; + if (AppSetting.Current.LogFilter.Any() && !AppSetting.Current.LogFilter.Contains(type.GetHashCode())) return; try { @@ -135,7 +135,7 @@ namespace BarrageGrab text += $" [{msg.User?.GenderToString()}] "; } - ConsoleColor color = Appsetting.Current.ColorMap[barType].Item1; + ConsoleColor color = AppSetting.Current.ColorMap[barType].Item1; var append = msg.Content; switch (barType) { diff --git a/BarrageGrab/Program.cs b/BarrageGrab/Program.cs index 4391ef4..2ecb8e0 100644 --- a/BarrageGrab/Program.cs +++ b/BarrageGrab/Program.cs @@ -63,21 +63,21 @@ namespace BarrageGrab AppRuntime.Init(); WinApi.SetConsoleCtrlHandler(controlCtr, true);//捕获控制台关闭 WinApi.DisableQuickEditMode();//禁用控制台快速编辑模式 - AppRuntime.DisplayConsole(!Appsetting.Current.HideConsole);//控制控制台可见 - AppRuntime.WsServer.Grab.Proxy.SetUpstreamProxy(Appsetting.Current.UpstreamProxy);//设置上游代理 + AppRuntime.DisplayConsole(!AppSetting.Current.HideConsole);//控制控制台可见 + AppRuntime.WsServer.Grab.Proxy.SetUpstreamProxy(AppSetting.Current.UpstreamProxy);//设置上游代理 AppRuntime.WsServer.OnClose += (s, e) => { exited = true; }; //串口写入服务 - if (!Appsetting.Current.ComPort.IsNullOrWhiteSpace()) + if (!AppSetting.Current.ComPort.IsNullOrWhiteSpace()) { AppRuntime.ComPortServer.OpenStart(); } //显示窗体 - if (Appsetting.Current.ShowWindow) + if (AppSetting.Current.ShowWindow) { var uiThread = new Thread(new ThreadStart(() => { diff --git a/BarrageGrab/Proxy/SystemProxy.cs b/BarrageGrab/Proxy/SystemProxy.cs index fdcc8b9..661417c 100644 --- a/BarrageGrab/Proxy/SystemProxy.cs +++ b/BarrageGrab/Proxy/SystemProxy.cs @@ -32,7 +32,7 @@ namespace BarrageGrab.Proxy /// /// 代理端口 /// - public int ProxyPort { get { return Appsetting.Current.ProxyPort; } } + public int ProxyPort { get { return AppSetting.Current.ProxyPort; } } public abstract string HttpUpstreamProxy { get; } @@ -55,11 +55,11 @@ namespace BarrageGrab.Proxy { host = host.Trim().ToLower(); - if (!Appsetting.Current.FilterHostName) return true; + if (!AppSetting.Current.FilterHostName) return true; if (host.StartsWith("webcast")) return true; - if (Appsetting.Current.HostNameFilter.Any(a => a.Trim().ToLower() == host)) return true; + if (AppSetting.Current.HostNameFilter.Any(a => a.Trim().ToLower() == host)) return true; return false; } diff --git a/BarrageGrab/Proxy/TitaniumProxy.cs b/BarrageGrab/Proxy/TitaniumProxy.cs index 1825470..b9e7e05 100644 --- a/BarrageGrab/Proxy/TitaniumProxy.cs +++ b/BarrageGrab/Proxy/TitaniumProxy.cs @@ -212,7 +212,7 @@ namespace BarrageGrab.Proxy var scriptContext = BuildContext(new Dictionary() { {"PROCESS_NAME","'{processName}'"}, - {"AUTOPAUSE",Appsetting.Current.AutoPause.ToString().ToLower()} + {"AUTOPAUSE",AppSetting.Current.AutoPause.ToString().ToLower()} }); liveRoomInjectScript = scriptContext + liveRoomInjectScript; var html = await e.GetResponseBodyAsString(); @@ -275,7 +275,7 @@ namespace BarrageGrab.Proxy } //给script标签 src加上时间戳避免缓存 - if (Appsetting.Current.DisableLivePageScriptCache) + if (AppSetting.Current.DisableLivePageScriptCache) { var scripts = doc.DocumentNode.SelectNodes("//script[@src]"); if (scripts != null) @@ -311,7 +311,7 @@ namespace BarrageGrab.Proxy var scriptContext = BuildContext(new Dictionary() { {"PROCESS_NAME","'{processName}'"}, - {"AUTOPAUSE",Appsetting.Current.AutoPause.ToString().ToLower()} + {"AUTOPAUSE",AppSetting.Current.AutoPause.ToString().ToLower()} }); liveHoomInjectScript = scriptContext + liveHoomInjectScript; @@ -382,7 +382,7 @@ namespace BarrageGrab.Proxy } } - if (url.Contains(LIVE_SCRIPT_PATH) && Appsetting.Current.ForcePolling) + if (url.Contains(LIVE_SCRIPT_PATH) && AppSetting.Current.ForcePolling) { var reg = new Regex(@"if\s*\((?!this\.stopPolling)\)"); var js = await e.GetResponseBodyAsString(); @@ -393,7 +393,7 @@ namespace BarrageGrab.Proxy var pollingIntervalMatch = pollingIntervalReg.Match(js); if (pollingIntervalMatch.Success) { - var myValue = Appsetting.Current.PollingInterval; + var myValue = AppSetting.Current.PollingInterval; js = pollingIntervalReg.Replace(js, $"this.pollingInterval={myValue},"); Logger.PrintColor($"直播间已成功修改轮询间隔为{myValue}ms", ConsoleColor.Green); } @@ -515,7 +515,7 @@ namespace BarrageGrab.Proxy { proxyServer.Stop(); proxyServer.Dispose(); - if (Appsetting.Current.UsedProxy) + if (AppSetting.Current.UsedProxy) { CloseSystemProxy(); } @@ -526,8 +526,8 @@ namespace BarrageGrab.Proxy /// override public void Start() { - proxyServer.Start(Appsetting.Current.UsedProxy); - if (Appsetting.Current.UsedProxy) + proxyServer.Start(AppSetting.Current.UsedProxy); + if (AppSetting.Current.UsedProxy) { proxyServer.SetAsSystemHttpProxy(explicitEndPoint); proxyServer.SetAsSystemHttpsProxy(explicitEndPoint); diff --git a/BarrageGrab/WsBarrageServer.cs b/BarrageGrab/WsBarrageServer.cs index f388a29..9aed910 100644 --- a/BarrageGrab/WsBarrageServer.cs +++ b/BarrageGrab/WsBarrageServer.cs @@ -36,7 +36,7 @@ namespace BarrageGrab Timer dieout = new Timer(10000);//离线客户端清理计时器 Timer giftCountTimer = new Timer(10000);//礼物缓存清理计时器 WssBarrageGrab grab = new WssBarrageGrab();//弹幕解析器核心 - Appsetting Appsetting = Appsetting.Current;//全局配置文件实例 + AppSetting Appsetting = AppSetting.Current;//全局配置文件实例 static int printCount = 0; //控制台输出计数,用于判断清理控制台 /// @@ -120,12 +120,12 @@ namespace BarrageGrab //判断Rommid是否符合拦截规则 private bool CheckRoomId(long roomid) { - if (!Appsetting.Current.WebRoomIds.Any()) return true; + if (!AppSetting.Current.WebRoomIds.Any()) return true; var webrid = AppRuntime.RoomCaches.GetCachedWebRoomid(roomid.ToString()); if (webrid <= 0) return true; - return Appsetting.Current.WebRoomIds.Contains(webrid); + return AppSetting.Current.WebRoomIds.Contains(webrid); } //解析用户 @@ -174,7 +174,7 @@ namespace BarrageGrab text += $" [{msg.User?.GenderToString()}] "; } - ConsoleColor color = Appsetting.Current.ColorMap[barType].Item1; + ConsoleColor color = AppSetting.Current.ColorMap[barType].Item1; var append = msg.Content; switch (barType) { @@ -185,13 +185,13 @@ namespace BarrageGrab text += append; - if (Appsetting.Current.BarrageLog) + if (AppSetting.Current.BarrageLog) { Logger.LogBarrage(barType, msg); } if (!Appsetting.PrintBarrage) return; - if (Appsetting.Current.PrintFilter.Any() && !Appsetting.Current.PrintFilter.Contains(barType.GetHashCode())) return; + if (AppSetting.Current.PrintFilter.Any() && !AppSetting.Current.PrintFilter.Contains(barType.GetHashCode())) return; OnPrint?.Invoke(this, new PrintEventArgs() { @@ -575,7 +575,7 @@ namespace BarrageGrab public void Broadcast(BarrageMsgPack pack) { if (pack == null) return; - if (Appsetting.Current.PushFilter.Any() && !Appsetting.Current.PushFilter.Contains(pack.Type.GetHashCode())) return; + if (AppSetting.Current.PushFilter.Any() && !AppSetting.Current.PushFilter.Contains(pack.Type.GetHashCode())) return; var offLines = new List(); foreach (var item in socketList) diff --git a/BarrageGrab/WssBarrageGrab.cs b/BarrageGrab/WssBarrageGrab.cs index 4f524d0..4552e1a 100644 --- a/BarrageGrab/WssBarrageGrab.cs +++ b/BarrageGrab/WssBarrageGrab.cs @@ -19,7 +19,7 @@ namespace BarrageGrab { //ISystemProxy proxy = new FiddlerProxy(); ISystemProxy proxy = new TitaniumProxy(); - Appsetting appsetting = Appsetting.Current; + AppSetting appsetting = AppSetting.Current; /// /// 进入直播间