配置文件类大小写变更
This commit is contained in:
@@ -10,13 +10,13 @@ using System.Drawing;
|
|||||||
|
|
||||||
namespace BarrageGrab
|
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
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace BarrageGrab
|
|||||||
|
|
||||||
static ComPortServer()
|
static ComPortServer()
|
||||||
{
|
{
|
||||||
if (Appsetting.Current.UseComPortFilter)
|
if (AppSetting.Current.UseComPortFilter)
|
||||||
{
|
{
|
||||||
jsEngine = JsEngine.CreateNewEngine();
|
jsEngine = JsEngine.CreateNewEngine();
|
||||||
var jsFile = JsEngine.GetJsFile("comPortFilter.js");
|
var jsFile = JsEngine.GetJsFile("comPortFilter.js");
|
||||||
@@ -28,8 +28,8 @@ namespace BarrageGrab
|
|||||||
|
|
||||||
public ComPortServer(WsBarrageServer server)
|
public ComPortServer(WsBarrageServer server)
|
||||||
{
|
{
|
||||||
string portName = Appsetting.Current.ComPort;
|
string portName = AppSetting.Current.ComPort;
|
||||||
int baudRate = Appsetting.Current.ComBaudRate;
|
int baudRate = AppSetting.Current.ComBaudRate;
|
||||||
if (portName.IsNullOrWhiteSpace())
|
if (portName.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -50,7 +50,7 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
if (!sendPort.IsOpen) return;
|
if (!sendPort.IsOpen) return;
|
||||||
if (e == null) return;
|
if (e == null) return;
|
||||||
if (!Appsetting.Current.UseComPortFilter)
|
if (!AppSetting.Current.UseComPortFilter)
|
||||||
{
|
{
|
||||||
var json = e.ToJson() + "\r\n";
|
var json = e.ToJson() + "\r\n";
|
||||||
var jbuff = Encoding.UTF8.GetBytes(json);
|
var jbuff = Encoding.UTF8.GetBytes(json);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace BarrageGrab
|
|||||||
AppRuntime.RoomCaches.OnCache += RoomCaches_OnCache;
|
AppRuntime.RoomCaches.OnCache += RoomCaches_OnCache;
|
||||||
this.txb_wsaddr.Text = barServer.ServerLocation;
|
this.txb_wsaddr.Text = barServer.ServerLocation;
|
||||||
this.txb_upstreamProxy.Text = proxy.HttpUpstreamProxy;
|
this.txb_upstreamProxy.Text = proxy.HttpUpstreamProxy;
|
||||||
this.cbx_barrageLog.Checked = Appsetting.Current.BarrageLog;
|
this.cbx_barrageLog.Checked = AppSetting.Current.BarrageLog;
|
||||||
InitTabPages();
|
InitTabPages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,17 +67,17 @@ namespace BarrageGrab
|
|||||||
if (page == this.tabPage_Ws)
|
if (page == this.tabPage_Ws)
|
||||||
{
|
{
|
||||||
type = "ws";
|
type = "ws";
|
||||||
ck.Checked = Appsetting.Current.PushFilter.Contains(label.Key);
|
ck.Checked = AppSetting.Current.PushFilter.Contains(label.Key);
|
||||||
}
|
}
|
||||||
if (page == this.tabPage_Console)
|
if (page == this.tabPage_Console)
|
||||||
{
|
{
|
||||||
type = "console";
|
type = "console";
|
||||||
ck.Checked = Appsetting.Current.PrintFilter.Contains(label.Key);
|
ck.Checked = AppSetting.Current.PrintFilter.Contains(label.Key);
|
||||||
}
|
}
|
||||||
if (page == this.tabPage_Log)
|
if (page == this.tabPage_Log)
|
||||||
{
|
{
|
||||||
type = "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.Name = $"cbx_bartype_{type}_{label.Key}";
|
||||||
ck.CheckedChanged += Ck_CheckedChanged;
|
ck.CheckedChanged += Ck_CheckedChanged;
|
||||||
@@ -94,17 +94,17 @@ namespace BarrageGrab
|
|||||||
var selected = GetCheckedBarTypes((FlowLayoutPanel)cbx.Parent);
|
var selected = GetCheckedBarTypes((FlowLayoutPanel)cbx.Parent);
|
||||||
if (cbx.Parent.Parent == this.tabPage_Console)
|
if (cbx.Parent.Parent == this.tabPage_Console)
|
||||||
{
|
{
|
||||||
Appsetting.Current.PrintFilter = selected;
|
AppSetting.Current.PrintFilter = selected;
|
||||||
}
|
}
|
||||||
if (cbx.Parent.Parent == this.tabPage_Ws)
|
if (cbx.Parent.Parent == this.tabPage_Ws)
|
||||||
{
|
{
|
||||||
Appsetting.Current.PushFilter = selected;
|
AppSetting.Current.PushFilter = selected;
|
||||||
}
|
}
|
||||||
if(cbx.Parent.Parent == this.tabPage_Log)
|
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)
|
private int[] GetCheckedBarTypes(FlowLayoutPanel panel)
|
||||||
@@ -171,7 +171,7 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
//将弹幕输出到richTextBox
|
//将弹幕输出到richTextBox
|
||||||
//颜色转换
|
//颜色转换
|
||||||
Color color = Appsetting.Current.ColorMap[e.MsgType].Item2;
|
Color color = AppSetting.Current.ColorMap[e.MsgType].Item2;
|
||||||
string msg = e.Message;
|
string msg = e.Message;
|
||||||
|
|
||||||
this.Invoke(new Action(() =>
|
this.Invoke(new Action(() =>
|
||||||
@@ -218,8 +218,8 @@ namespace BarrageGrab
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
proxy.SetUpstreamProxy(text);
|
proxy.SetUpstreamProxy(text);
|
||||||
Appsetting.Current.UpstreamProxy = text;
|
AppSetting.Current.UpstreamProxy = text;
|
||||||
Appsetting.Current.Save();
|
AppSetting.Current.Save();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -231,8 +231,8 @@ namespace BarrageGrab
|
|||||||
private void cbx_barrageLog_CheckedChanged(object sender, EventArgs e)
|
private void cbx_barrageLog_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var checker = (CheckBox)sender;
|
var checker = (CheckBox)sender;
|
||||||
Appsetting.Current.BarrageLog = checker.Checked;
|
AppSetting.Current.BarrageLog = checker.Checked;
|
||||||
Appsetting.Current.Save();
|
AppSetting.Current.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,9 +94,9 @@ namespace BarrageGrab
|
|||||||
/// <param name="msg">弹幕内容</param>
|
/// <param name="msg">弹幕内容</param>
|
||||||
public static void LogBarrage(PackMsgType type, Msg msg)
|
public static void LogBarrage(PackMsgType type, Msg msg)
|
||||||
{
|
{
|
||||||
if (!Appsetting.Current.BarrageLog) return;
|
if (!AppSetting.Current.BarrageLog) return;
|
||||||
if (type == PackMsgType.无) 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
|
try
|
||||||
{
|
{
|
||||||
@@ -135,7 +135,7 @@ namespace BarrageGrab
|
|||||||
text += $" [{msg.User?.GenderToString()}] ";
|
text += $" [{msg.User?.GenderToString()}] ";
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleColor color = Appsetting.Current.ColorMap[barType].Item1;
|
ConsoleColor color = AppSetting.Current.ColorMap[barType].Item1;
|
||||||
var append = msg.Content;
|
var append = msg.Content;
|
||||||
switch (barType)
|
switch (barType)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,21 +63,21 @@ namespace BarrageGrab
|
|||||||
AppRuntime.Init();
|
AppRuntime.Init();
|
||||||
WinApi.SetConsoleCtrlHandler(controlCtr, true);//捕获控制台关闭
|
WinApi.SetConsoleCtrlHandler(controlCtr, true);//捕获控制台关闭
|
||||||
WinApi.DisableQuickEditMode();//禁用控制台快速编辑模式
|
WinApi.DisableQuickEditMode();//禁用控制台快速编辑模式
|
||||||
AppRuntime.DisplayConsole(!Appsetting.Current.HideConsole);//控制控制台可见
|
AppRuntime.DisplayConsole(!AppSetting.Current.HideConsole);//控制控制台可见
|
||||||
AppRuntime.WsServer.Grab.Proxy.SetUpstreamProxy(Appsetting.Current.UpstreamProxy);//设置上游代理
|
AppRuntime.WsServer.Grab.Proxy.SetUpstreamProxy(AppSetting.Current.UpstreamProxy);//设置上游代理
|
||||||
AppRuntime.WsServer.OnClose += (s, e) =>
|
AppRuntime.WsServer.OnClose += (s, e) =>
|
||||||
{
|
{
|
||||||
exited = true;
|
exited = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
//串口写入服务
|
//串口写入服务
|
||||||
if (!Appsetting.Current.ComPort.IsNullOrWhiteSpace())
|
if (!AppSetting.Current.ComPort.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
AppRuntime.ComPortServer.OpenStart();
|
AppRuntime.ComPortServer.OpenStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
//显示窗体
|
//显示窗体
|
||||||
if (Appsetting.Current.ShowWindow)
|
if (AppSetting.Current.ShowWindow)
|
||||||
{
|
{
|
||||||
var uiThread = new Thread(new ThreadStart(() =>
|
var uiThread = new Thread(new ThreadStart(() =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace BarrageGrab.Proxy
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 代理端口
|
/// 代理端口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int ProxyPort { get { return Appsetting.Current.ProxyPort; } }
|
public int ProxyPort { get { return AppSetting.Current.ProxyPort; } }
|
||||||
|
|
||||||
public abstract string HttpUpstreamProxy { get; }
|
public abstract string HttpUpstreamProxy { get; }
|
||||||
|
|
||||||
@@ -55,11 +55,11 @@ namespace BarrageGrab.Proxy
|
|||||||
{
|
{
|
||||||
host = host.Trim().ToLower();
|
host = host.Trim().ToLower();
|
||||||
|
|
||||||
if (!Appsetting.Current.FilterHostName) return true;
|
if (!AppSetting.Current.FilterHostName) return true;
|
||||||
|
|
||||||
if (host.StartsWith("webcast")) 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ namespace BarrageGrab.Proxy
|
|||||||
var scriptContext = BuildContext(new Dictionary<string, string>()
|
var scriptContext = BuildContext(new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
{"PROCESS_NAME","'{processName}'"},
|
{"PROCESS_NAME","'{processName}'"},
|
||||||
{"AUTOPAUSE",Appsetting.Current.AutoPause.ToString().ToLower()}
|
{"AUTOPAUSE",AppSetting.Current.AutoPause.ToString().ToLower()}
|
||||||
});
|
});
|
||||||
liveRoomInjectScript = scriptContext + liveRoomInjectScript;
|
liveRoomInjectScript = scriptContext + liveRoomInjectScript;
|
||||||
var html = await e.GetResponseBodyAsString();
|
var html = await e.GetResponseBodyAsString();
|
||||||
@@ -275,7 +275,7 @@ namespace BarrageGrab.Proxy
|
|||||||
}
|
}
|
||||||
|
|
||||||
//给script标签 src加上时间戳避免缓存
|
//给script标签 src加上时间戳避免缓存
|
||||||
if (Appsetting.Current.DisableLivePageScriptCache)
|
if (AppSetting.Current.DisableLivePageScriptCache)
|
||||||
{
|
{
|
||||||
var scripts = doc.DocumentNode.SelectNodes("//script[@src]");
|
var scripts = doc.DocumentNode.SelectNodes("//script[@src]");
|
||||||
if (scripts != null)
|
if (scripts != null)
|
||||||
@@ -311,7 +311,7 @@ namespace BarrageGrab.Proxy
|
|||||||
var scriptContext = BuildContext(new Dictionary<string, string>()
|
var scriptContext = BuildContext(new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
{"PROCESS_NAME","'{processName}'"},
|
{"PROCESS_NAME","'{processName}'"},
|
||||||
{"AUTOPAUSE",Appsetting.Current.AutoPause.ToString().ToLower()}
|
{"AUTOPAUSE",AppSetting.Current.AutoPause.ToString().ToLower()}
|
||||||
});
|
});
|
||||||
liveHoomInjectScript = scriptContext + liveHoomInjectScript;
|
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*\((?<patt>!this\.stopPolling)\)");
|
var reg = new Regex(@"if\s*\((?<patt>!this\.stopPolling)\)");
|
||||||
var js = await e.GetResponseBodyAsString();
|
var js = await e.GetResponseBodyAsString();
|
||||||
@@ -393,7 +393,7 @@ namespace BarrageGrab.Proxy
|
|||||||
var pollingIntervalMatch = pollingIntervalReg.Match(js);
|
var pollingIntervalMatch = pollingIntervalReg.Match(js);
|
||||||
if (pollingIntervalMatch.Success)
|
if (pollingIntervalMatch.Success)
|
||||||
{
|
{
|
||||||
var myValue = Appsetting.Current.PollingInterval;
|
var myValue = AppSetting.Current.PollingInterval;
|
||||||
js = pollingIntervalReg.Replace(js, $"this.pollingInterval={myValue},");
|
js = pollingIntervalReg.Replace(js, $"this.pollingInterval={myValue},");
|
||||||
Logger.PrintColor($"直播间已成功修改轮询间隔为{myValue}ms", ConsoleColor.Green);
|
Logger.PrintColor($"直播间已成功修改轮询间隔为{myValue}ms", ConsoleColor.Green);
|
||||||
}
|
}
|
||||||
@@ -515,7 +515,7 @@ namespace BarrageGrab.Proxy
|
|||||||
{
|
{
|
||||||
proxyServer.Stop();
|
proxyServer.Stop();
|
||||||
proxyServer.Dispose();
|
proxyServer.Dispose();
|
||||||
if (Appsetting.Current.UsedProxy)
|
if (AppSetting.Current.UsedProxy)
|
||||||
{
|
{
|
||||||
CloseSystemProxy();
|
CloseSystemProxy();
|
||||||
}
|
}
|
||||||
@@ -526,8 +526,8 @@ namespace BarrageGrab.Proxy
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
override public void Start()
|
override public void Start()
|
||||||
{
|
{
|
||||||
proxyServer.Start(Appsetting.Current.UsedProxy);
|
proxyServer.Start(AppSetting.Current.UsedProxy);
|
||||||
if (Appsetting.Current.UsedProxy)
|
if (AppSetting.Current.UsedProxy)
|
||||||
{
|
{
|
||||||
proxyServer.SetAsSystemHttpProxy(explicitEndPoint);
|
proxyServer.SetAsSystemHttpProxy(explicitEndPoint);
|
||||||
proxyServer.SetAsSystemHttpsProxy(explicitEndPoint);
|
proxyServer.SetAsSystemHttpsProxy(explicitEndPoint);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace BarrageGrab
|
|||||||
Timer dieout = new Timer(10000);//离线客户端清理计时器
|
Timer dieout = new Timer(10000);//离线客户端清理计时器
|
||||||
Timer giftCountTimer = new Timer(10000);//礼物缓存清理计时器
|
Timer giftCountTimer = new Timer(10000);//礼物缓存清理计时器
|
||||||
WssBarrageGrab grab = new WssBarrageGrab();//弹幕解析器核心
|
WssBarrageGrab grab = new WssBarrageGrab();//弹幕解析器核心
|
||||||
Appsetting Appsetting = Appsetting.Current;//全局配置文件实例
|
AppSetting Appsetting = AppSetting.Current;//全局配置文件实例
|
||||||
static int printCount = 0; //控制台输出计数,用于判断清理控制台
|
static int printCount = 0; //控制台输出计数,用于判断清理控制台
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -120,12 +120,12 @@ namespace BarrageGrab
|
|||||||
//判断Rommid是否符合拦截规则
|
//判断Rommid是否符合拦截规则
|
||||||
private bool CheckRoomId(long roomid)
|
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());
|
var webrid = AppRuntime.RoomCaches.GetCachedWebRoomid(roomid.ToString());
|
||||||
if (webrid <= 0) return true;
|
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()}] ";
|
text += $" [{msg.User?.GenderToString()}] ";
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleColor color = Appsetting.Current.ColorMap[barType].Item1;
|
ConsoleColor color = AppSetting.Current.ColorMap[barType].Item1;
|
||||||
var append = msg.Content;
|
var append = msg.Content;
|
||||||
switch (barType)
|
switch (barType)
|
||||||
{
|
{
|
||||||
@@ -185,13 +185,13 @@ namespace BarrageGrab
|
|||||||
|
|
||||||
text += append;
|
text += append;
|
||||||
|
|
||||||
if (Appsetting.Current.BarrageLog)
|
if (AppSetting.Current.BarrageLog)
|
||||||
{
|
{
|
||||||
Logger.LogBarrage(barType, msg);
|
Logger.LogBarrage(barType, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Appsetting.PrintBarrage) return;
|
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()
|
OnPrint?.Invoke(this, new PrintEventArgs()
|
||||||
{
|
{
|
||||||
@@ -575,7 +575,7 @@ namespace BarrageGrab
|
|||||||
public void Broadcast(BarrageMsgPack pack)
|
public void Broadcast(BarrageMsgPack pack)
|
||||||
{
|
{
|
||||||
if (pack == null) return;
|
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<string>();
|
var offLines = new List<string>();
|
||||||
foreach (var item in socketList)
|
foreach (var item in socketList)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
//ISystemProxy proxy = new FiddlerProxy();
|
//ISystemProxy proxy = new FiddlerProxy();
|
||||||
ISystemProxy proxy = new TitaniumProxy();
|
ISystemProxy proxy = new TitaniumProxy();
|
||||||
Appsetting appsetting = Appsetting.Current;
|
AppSetting appsetting = AppSetting.Current;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 进入直播间
|
/// 进入直播间
|
||||||
|
|||||||
Reference in New Issue
Block a user