From c387094ebeee1a249340cdbc80132f5d75de2887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=99=BD=E7=8C=BF?= <1083092844@qq.com> Date: Thu, 9 Mar 2023 00:32:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E5=BC=B9=E5=B9=95=E7=B1=BB=E5=9E=8B=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BarrageGrab/App.config | 3 +++ BarrageGrab/Appsetting.cs | 41 ++++++++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/BarrageGrab/App.config b/BarrageGrab/App.config index 10b98e4..de8fa47 100644 --- a/BarrageGrab/App.config +++ b/BarrageGrab/App.config @@ -1,5 +1,6 @@  + @@ -7,6 +8,8 @@ + + diff --git a/BarrageGrab/Appsetting.cs b/BarrageGrab/Appsetting.cs index d114af1..583a51a 100644 --- a/BarrageGrab/Appsetting.cs +++ b/BarrageGrab/Appsetting.cs @@ -4,6 +4,7 @@ using System.Configuration; using System.Linq; using System.Text; using System.Threading.Tasks; +using BarrageGrab.JsonEntity; using static System.Configuration.ConfigurationManager; namespace BarrageGrab { @@ -11,19 +12,31 @@ namespace BarrageGrab { private static readonly Appsetting ins = new Appsetting(); - public static Appsetting Instanse { get => Get(); } + public static Appsetting Current { get => ins; } public Appsetting() { - FilterProcess = AppSettings["filterProcess"].Trim().Split(','); - WsProt = int.Parse(AppSettings["wsListenPort"]); - PrintBarrage = AppSettings["printBarrage"].ToLower() == "true"; - ProxyPort = int.Parse(AppSettings["proxPort"]); - } + try + { + FilterProcess = AppSettings["filterProcess"].Trim().Split(','); + WsProt = int.Parse(AppSettings["wsListenPort"]); + PrintBarrage = AppSettings["printBarrage"].ToLower() == "true"; + ProxyPort = int.Parse(AppSettings["proxPort"]); + PrintFilter = Enum.GetValues(typeof(BarrageMsgType)).Cast().ToArray(); + //RoomIds = AppSettings["roomIds"].Trim().Split(',').Where(w=>!string.IsNullOrWhiteSpace(w)).Select(s => long.Parse(s)).ToArray(); - public static Appsetting Get() - { - return ins; + var printFilter = AppSettings["printFilter"].Trim().ToLower(); + if (printFilter != "all") + { + if (string.IsNullOrWhiteSpace(printFilter)) PrintFilter = new int[0]; + else PrintFilter = printFilter.Split(',').Select(x => int.Parse(x)).ToArray(); + } + } + catch (Exception ex) + { + Console.WriteLine("配置文件读取失败,请检查配置文件是否正确"); + throw ex; + } } /// @@ -45,5 +58,15 @@ namespace BarrageGrab /// 代理端口 /// public int ProxyPort { get; private set; } = 8827; + + /// + /// 控制台输出过滤器 + /// + public int[] PrintFilter { get; private set; } + + /// + /// 监听的房间号 + /// + public long[] RoomIds { get; private set; } = new long[0]; } }