添加 输出弹幕类型过滤
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<!--配置更改后重启才能生效-->
|
||||
<appSettings>
|
||||
<!--过滤Websocket数据源进程,可用','进行分隔,程序将会监听以下进程的弹幕信息-->
|
||||
<add key="filterProcess" value="直播伴侣,chrome,msedge"/>
|
||||
@@ -7,6 +8,8 @@
|
||||
<add key="wsListenPort" value="8888"/>
|
||||
<!--在控制台输出弹幕-->
|
||||
<add key="printBarrage" value="true"/>
|
||||
<!--要在控制台打印的弹幕类型,可以用','隔开 all[全部],1[普通弹幕],2[点赞消息],3[进入直播间],4[关注消息],5[礼物消息],6[统计消息],7[粉丝团消息]-->
|
||||
<add key="printFilter" value="all"/>
|
||||
<!--系统代理端口-->
|
||||
<add key="proxPort" value="8827"/>
|
||||
</appSettings>
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
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<int>().ToArray();
|
||||
//RoomIds = AppSettings["roomIds"].Trim().Split(',').Where(w=>!string.IsNullOrWhiteSpace(w)).Select(s => long.Parse(s)).ToArray();
|
||||
|
||||
public static Appsetting Get()
|
||||
var printFilter = AppSettings["printFilter"].Trim().ToLower();
|
||||
if (printFilter != "all")
|
||||
{
|
||||
return ins;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -45,5 +58,15 @@ namespace BarrageGrab
|
||||
/// 代理端口
|
||||
/// </summary>
|
||||
public int ProxyPort { get; private set; } = 8827;
|
||||
|
||||
/// <summary>
|
||||
/// 控制台输出过滤器
|
||||
/// </summary>
|
||||
public int[] PrintFilter { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 监听的房间号
|
||||
/// </summary>
|
||||
public long[] RoomIds { get; private set; } = new long[0];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user