Merge branch 'master' of https://gitee.com/haodong108/dy-barrage-grab
This commit is contained in:
@@ -7,9 +7,13 @@ using System.IO.Ports;
|
|||||||
using Jint;
|
using Jint;
|
||||||
using Jint.Runtime;
|
using Jint.Runtime;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Jint.Native;
|
||||||
|
|
||||||
namespace BarrageGrab
|
namespace BarrageGrab
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 串口服务
|
||||||
|
/// </summary>
|
||||||
public class ComPortServer : IDisposable
|
public class ComPortServer : IDisposable
|
||||||
{
|
{
|
||||||
WsBarrageServer server;
|
WsBarrageServer server;
|
||||||
@@ -22,7 +26,15 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
jsEngine = JsEngine.CreateNewEngine();
|
jsEngine = JsEngine.CreateNewEngine();
|
||||||
var jsFile = JsEngine.GetJsFile("comPortFilter.js");
|
var jsFile = JsEngine.GetJsFile("comPortFilter.js");
|
||||||
jsEngine.Execute(jsFile);
|
try
|
||||||
|
{
|
||||||
|
jsEngine.Execute(jsFile);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError(ex, $"comPortFilter.js 执行错误: {ex.Message}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,6 +62,8 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
if (!sendPort.IsOpen) return;
|
if (!sendPort.IsOpen) return;
|
||||||
if (e == null) return;
|
if (e == null) return;
|
||||||
|
if (e.Message == null) return;
|
||||||
|
|
||||||
if (!AppSetting.Current.UseComPortFilter)
|
if (!AppSetting.Current.UseComPortFilter)
|
||||||
{
|
{
|
||||||
var json = e.ToJson() + "\r\n";
|
var json = e.ToJson() + "\r\n";
|
||||||
@@ -57,7 +71,20 @@ namespace BarrageGrab
|
|||||||
Send(jbuff);
|
Send(jbuff);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var result = jsEngine.Invoke("onPackData", e.MsgType.GetHashCode(), e.Message);
|
|
||||||
|
var roomInfo = AppRuntime.RoomCaches.GetCachedWebRoomInfo(e.Message.RoomId.ToString());
|
||||||
|
JsValue result = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = jsEngine.Invoke("onPackData", e.MsgType.GetHashCode(), e.Message, roomInfo);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError(ex, $"串口过滤器 onPackData 执行错误:{ex.Message}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (result == null) return;
|
||||||
|
|
||||||
var nocanTypes = new Types[]
|
var nocanTypes = new Types[]
|
||||||
{
|
{
|
||||||
Types.Null,
|
Types.Null,
|
||||||
@@ -115,15 +142,14 @@ namespace BarrageGrab
|
|||||||
sendPort.Open();
|
sendPort.Open();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
sendPort.Close();
|
sendPort.Close();
|
||||||
sendPort.Dispose();
|
sendPort.Dispose();
|
||||||
sendPort = null;
|
sendPort = null;
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (sendPort == null) return;
|
if (sendPort == null) return;
|
||||||
|
|||||||
+71
-5
@@ -12,6 +12,10 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
public static class JsEngine
|
public static class JsEngine
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 创建一个Js引擎
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public static Engine CreateNewEngine()
|
public static Engine CreateNewEngine()
|
||||||
{
|
{
|
||||||
var jsonParse = new Func<object, string>((obj) =>
|
var jsonParse = new Func<object, string>((obj) =>
|
||||||
@@ -28,8 +32,15 @@ namespace BarrageGrab
|
|||||||
});
|
});
|
||||||
|
|
||||||
var engine = new Engine();
|
var engine = new Engine();
|
||||||
|
|
||||||
|
engine.Execute(@"
|
||||||
|
byteToUint8Array = function(arr){
|
||||||
|
return new Uint8Array(arr);
|
||||||
|
}");
|
||||||
|
|
||||||
engine.SetValue("console", new JsConsole());
|
engine.SetValue("console", new JsConsole());
|
||||||
engine.SetValue("encoder", new JsEncoder(engine));
|
engine.SetValue("encoder", new JsEncoder(engine));
|
||||||
|
engine.SetValue("bitConvert", new JsBitConvert(engine));
|
||||||
|
|
||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
@@ -72,11 +83,7 @@ namespace BarrageGrab
|
|||||||
Engine eng;
|
Engine eng;
|
||||||
public JsEncoder(Engine eng)
|
public JsEncoder(Engine eng)
|
||||||
{
|
{
|
||||||
this.eng = eng;
|
this.eng = eng;
|
||||||
eng.Execute(@"
|
|
||||||
byteToUint8Array = function(arr){
|
|
||||||
return new Uint8Array(arr);
|
|
||||||
}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JsValue ByteConvert(byte[] buff)
|
private JsValue ByteConvert(byte[] buff)
|
||||||
@@ -144,5 +151,64 @@ namespace BarrageGrab
|
|||||||
return Encoding.ASCII.GetString(bytes);
|
return Encoding.ASCII.GetString(bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class JsBitConvert
|
||||||
|
{
|
||||||
|
Engine eng;
|
||||||
|
public JsBitConvert(Engine eng)
|
||||||
|
{
|
||||||
|
this.eng = eng;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JsValue ByteConvert(byte[] buff)
|
||||||
|
{
|
||||||
|
return eng.Invoke("byteToUint8Array", buff);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsValue toNumber(byte[] buff,int startIndex = 0)
|
||||||
|
{
|
||||||
|
return BitConverter.ToDouble(buff, startIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool toBoolean(byte[] buff, int startIndex = 0)
|
||||||
|
{
|
||||||
|
return BitConverter.ToBoolean(buff, startIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string toString(byte[] buff, int startIndex = 0)
|
||||||
|
{
|
||||||
|
return BitConverter.ToString(buff, startIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string toString(byte[] buff, int startIndex, int length)
|
||||||
|
{
|
||||||
|
return BitConverter.ToString(buff, startIndex, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsValue getBytes(JsValue value)
|
||||||
|
{
|
||||||
|
byte[] buff = new byte[0];
|
||||||
|
switch (value.Type)
|
||||||
|
{
|
||||||
|
case Jint.Runtime.Types.Empty:
|
||||||
|
case Jint.Runtime.Types.Undefined:
|
||||||
|
case Jint.Runtime.Types.Null:
|
||||||
|
break;
|
||||||
|
case Jint.Runtime.Types.Boolean:
|
||||||
|
buff = BitConverter.GetBytes(value.AsBoolean());
|
||||||
|
break;
|
||||||
|
case Jint.Runtime.Types.Number:
|
||||||
|
buff = BitConverter.GetBytes(value.AsNumber());
|
||||||
|
break;
|
||||||
|
case Jint.Runtime.Types.BigInt:
|
||||||
|
buff = BitConverter.GetBytes((long)value.AsNumber());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Exception($"不支持该类型转换:" + value.Type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ByteConvert(buff);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ namespace BarrageGrab.Modles.JsonEntity
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 房间号
|
/// 房间号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long RoomId { get; set; }
|
public string RoomId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// web直播间ID
|
/// web直播间ID
|
||||||
|
|||||||
@@ -135,11 +135,12 @@ namespace BarrageGrab
|
|||||||
return !createdNew;
|
return !createdNew;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
private static void JintTest()
|
private static void JintTest()
|
||||||
{
|
{
|
||||||
var jsEng = JsEngine.CreateNewEngine();
|
var jsEng = JsEngine.CreateNewEngine();
|
||||||
var jsFile = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "Scripts", "engine", "comPortFilter.js"), Encoding.UTF8);
|
var jsFile = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "Scripts", "engine", "comPortFilter.js"), Encoding.UTF8);
|
||||||
|
//var jsFile = @"D:\develop\Project\dy-barrage-grab\BarrageGrab\Scripts\engine\comPortFilter.js";
|
||||||
jsEng.Execute(jsFile);
|
jsEng.Execute(jsFile);
|
||||||
var result = jsEng.Invoke("onPackData", 1, new
|
var result = jsEng.Invoke("onPackData", 1, new
|
||||||
{
|
{
|
||||||
@@ -150,9 +151,8 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
{ "key1","value1" }
|
{ "key1","value1" }
|
||||||
}
|
}
|
||||||
});
|
},null);
|
||||||
|
Console.WriteLine($"返回类型:{ result.Type.ToString()},值:{result.ToString()}");
|
||||||
Console.WriteLine("返回类型:" + result.Type.ToString());
|
|
||||||
if (result.Type == Types.String)
|
if (result.Type == Types.String)
|
||||||
{
|
{
|
||||||
Console.WriteLine("返回String: " + result.ToString());
|
Console.WriteLine("返回String: " + result.ToString());
|
||||||
@@ -170,5 +170,6 @@ namespace BarrageGrab
|
|||||||
Console.WriteLine("返回Symbol: " + result.ToString());
|
Console.WriteLine("返回Symbol: " + result.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,6 @@ using System.Runtime.InteropServices;
|
|||||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||||
//通过使用 "*",如下所示:
|
//通过使用 "*",如下所示:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.7.2.0")]
|
[assembly: AssemblyVersion("2.7.3.0")]
|
||||||
[assembly: AssemblyFileVersion("2.7.2.0")]
|
[assembly: AssemblyFileVersion("2.7.3.0")]
|
||||||
[assembly: NeutralResourcesLanguage("zh-CN")]
|
[assembly: NeutralResourcesLanguage("zh-CN")]
|
||||||
|
|||||||
@@ -1,28 +1,38 @@
|
|||||||
/**
|
/*
|
||||||
* 注解:串口数据过滤脚本,可用于自定义配置串口的发送报文
|
* 注解:串口数据过滤脚本,可用于自定义配置串口的发送报文
|
||||||
* Tip: 该脚本引擎为Jint,支持的语法请参考官方文档:https://github.com/sebastienros/jint
|
* Tip: 该脚本引擎为Jint,支持的语法请参考官方文档:https://github.com/sebastienros/jint
|
||||||
* 工具环境:
|
* 为了 工具环境:
|
||||||
* 1.支持 console.log, console.error, console.warn 这些日志将被输出到控制台, 其中error日志将被记录到日志文件
|
* 1.控制台: console: 控制台输出
|
||||||
* 2.编码工具 encoder.utf8ToBytes(str),encoder.utf8ToString 字符串 和 Uint8Array 互转
|
* console.log, console.error, console.warn 这些日志将被输出到控制台, 其中error日志将被记录到日志文件
|
||||||
* encoder.utf32ToBytes(str),encoder.utf32ToString
|
*
|
||||||
* encoder.asciiToBytes(str),encoder.asciiToString
|
* 2.编码器: encoder: 字符串 和 Uint8Array 互转
|
||||||
|
* encoder.utf8ToBytes(str):Unit8Array ,encoder.utf8ToString(buff):String
|
||||||
|
* encoder.utf32ToBytes(str):Unit8Array ,encoder.utf32ToString(buff):String
|
||||||
|
* encoder.asciiToBytes(str):Unit8Array ,encoder.asciiToString(buff):String
|
||||||
|
*
|
||||||
|
* 3.Bit转换: bitConvert: 支持 Number,Boolean 与 Uint8Array 互转
|
||||||
|
* bitConvert.toNumber(bytes, offset):Number
|
||||||
|
* bitConvert.toBoolean(bytes, offset):Boolean
|
||||||
|
* bitConvert.toString(bytes, offset, length):String
|
||||||
|
* bitConvert.toString(bytes, offset):String
|
||||||
|
* bitConvert.toString(bytes):String
|
||||||
|
* bitConvert.getBytes(value):Unit8Array 支持传入 Number,Boolean String请使用 encoder.utf8ToBytes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 这个函数由程序JS引擎调用,不要删除
|
* 这个函数由程序JS引擎调用,不要删除
|
||||||
* @param {number} msgType 消息类型,如礼物,弹幕消息等,和程序内定义一致
|
* @param {number} msgType 消息类型,如礼物,弹幕消息等,和程序内定义一致 见 Modles\JsonEntity\BarrageMessages.cs PackMsgType 枚举
|
||||||
* @param {Object} msg 被WsBarrageServer简化后的消息对象,具体可参考Json实体文件
|
* @param {Object} msg 被WsBarrageServer简化后的消息对象,具体可参考Json实体文件 见 Modles\JsonEntity\BarrageMessages.cs
|
||||||
* @returns {Uint8Array|string} 返回一个Uint8Array类型的数据,或者返回一个字符串,如果返回 null 则不发送数据。返回的数据将会被发送到串口
|
* @param {Object} roomInfo 当前消息对应的房间信息 见 Modles\RoomInfo.cs 结构
|
||||||
|
* @returns {Uint8Array|string} 返回一个Uint8Array类型的数据,或者返回一个字符串(将自动进行utf8编码),如果返回 null 则不发送数据。返回的数据将会被发送到串口
|
||||||
*/
|
*/
|
||||||
function onPackData(msgType, msg) {
|
function onPackData(msgType, msg , roomInfo) {
|
||||||
let excludeMsgType = [3, 6, 0]; // 过滤掉进入直播间和统计信息
|
let json = JSON.stringify(msg);
|
||||||
if (excludeMsgType.includes(msgType)) return;
|
return json+"\n";
|
||||||
var result = msg.Content + "\r\n";
|
// let excludeMsgType = [3, 6, 0]; // 过滤掉进入直播间和统计信息
|
||||||
return result;
|
// if (excludeMsgType.includes(msgType)) return;
|
||||||
// var buff = encoder.utf8ToBytes(result);
|
// var result = msg.Content + "\r\n";
|
||||||
// var newjs = encoder.utf8ToString(buff);
|
// return result;
|
||||||
// console.log(newjs);
|
|
||||||
// return newjs;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
MsgId = msg.Common.msgId,
|
MsgId = msg.Common.msgId,
|
||||||
Content = msg.Content,
|
Content = msg.Content,
|
||||||
RoomId = msg.Common.roomId,
|
RoomId = msg.Common.roomId.ToString(),
|
||||||
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
||||||
Type = msg.Type,
|
Type = msg.Type,
|
||||||
User = GetUser(msg.User)
|
User = GetUser(msg.User)
|
||||||
@@ -311,7 +311,7 @@ namespace BarrageGrab
|
|||||||
TotalUserCount = msg.totalUser,
|
TotalUserCount = msg.totalUser,
|
||||||
TotalUserCountStr = msg.totalPvForAnchor,
|
TotalUserCountStr = msg.totalPvForAnchor,
|
||||||
OnlineUserCountStr = msg.onlineUserForAnchor,
|
OnlineUserCountStr = msg.onlineUserForAnchor,
|
||||||
RoomId = msg.Common.roomId,
|
RoomId = msg.Common.roomId.ToString(),
|
||||||
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
||||||
Content = $"当前直播间人数 {msg.onlineUserForAnchor},累计直播间人数 {msg.totalPvForAnchor}",
|
Content = $"当前直播间人数 {msg.onlineUserForAnchor},累计直播间人数 {msg.totalPvForAnchor}",
|
||||||
User = null
|
User = null
|
||||||
@@ -395,7 +395,7 @@ namespace BarrageGrab
|
|||||||
var enty = new GiftMsg()
|
var enty = new GiftMsg()
|
||||||
{
|
{
|
||||||
MsgId = msg.Common.msgId,
|
MsgId = msg.Common.msgId,
|
||||||
RoomId = msg.Common.roomId,
|
RoomId = msg.Common.roomId.ToString(),
|
||||||
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
||||||
Content = $"{msg.User.Nickname} 送出 {msg.Gift.Name}{(msg.Gift.Combo ? "(可连击)" : "")} x {msg.repeatCount}个,增量{count}个",
|
Content = $"{msg.User.Nickname} 送出 {msg.Gift.Name}{(msg.Gift.Combo ? "(可连击)" : "")} x {msg.repeatCount}个,增量{count}个",
|
||||||
DiamondCount = msg.Gift.diamondCount,
|
DiamondCount = msg.Gift.diamondCount,
|
||||||
@@ -433,7 +433,7 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
MsgId = msg.Common.msgId,
|
MsgId = msg.Common.msgId,
|
||||||
Content = $"{msg.User.Nickname} 关注了主播",
|
Content = $"{msg.User.Nickname} 关注了主播",
|
||||||
RoomId = msg.Common.roomId,
|
RoomId = msg.Common.roomId.ToString(),
|
||||||
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
||||||
User = GetUser(msg.User)
|
User = GetUser(msg.User)
|
||||||
};
|
};
|
||||||
@@ -463,7 +463,7 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
MsgId = msg.Common.msgId,
|
MsgId = msg.Common.msgId,
|
||||||
Content = $"{msg.User.Nickname} 分享了直播间到{type}",
|
Content = $"{msg.User.Nickname} 分享了直播间到{type}",
|
||||||
RoomId = msg.Common.roomId,
|
RoomId = msg.Common.roomId.ToString(),
|
||||||
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
||||||
ShareType = type,
|
ShareType = type,
|
||||||
User = GetUser(msg.User)
|
User = GetUser(msg.User)
|
||||||
@@ -490,7 +490,7 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
MsgId = msg.Common.msgId,
|
MsgId = msg.Common.msgId,
|
||||||
Content = $"{msg.User.Nickname} 来了 直播间人数:{msg.memberCount}",
|
Content = $"{msg.User.Nickname} 来了 直播间人数:{msg.memberCount}",
|
||||||
RoomId = msg.Common.roomId,
|
RoomId = msg.Common.roomId.ToString(),
|
||||||
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
||||||
CurrentCount = msg.memberCount,
|
CurrentCount = msg.memberCount,
|
||||||
User = GetUser(msg.User)
|
User = GetUser(msg.User)
|
||||||
@@ -516,7 +516,7 @@ namespace BarrageGrab
|
|||||||
MsgId = msg.Common.msgId,
|
MsgId = msg.Common.msgId,
|
||||||
Count = msg.Count,
|
Count = msg.Count,
|
||||||
Content = $"{msg.User.Nickname} 为主播点了{msg.Count}个赞,总点赞{msg.Total}",
|
Content = $"{msg.User.Nickname} 为主播点了{msg.Count}个赞,总点赞{msg.Total}",
|
||||||
RoomId = msg.Common.roomId,
|
RoomId = msg.Common.roomId.ToString(),
|
||||||
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
||||||
Total = msg.Total,
|
Total = msg.Total,
|
||||||
User = GetUser(msg.User)
|
User = GetUser(msg.User)
|
||||||
@@ -540,7 +540,7 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
MsgId = msg.Common.msgId,
|
MsgId = msg.Common.msgId,
|
||||||
Content = msg.Content,
|
Content = msg.Content,
|
||||||
RoomId = msg.Common.roomId,
|
RoomId = msg.Common.roomId.ToString(),
|
||||||
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
||||||
User = GetUser(msg.User),
|
User = GetUser(msg.User),
|
||||||
};
|
};
|
||||||
@@ -567,7 +567,7 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
MsgId = msg.Common.msgId,
|
MsgId = msg.Common.msgId,
|
||||||
Content = "直播已结束",
|
Content = "直播已结束",
|
||||||
RoomId = msg.Common.roomId,
|
RoomId = msg.Common.roomId.ToString(),
|
||||||
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
||||||
User = null
|
User = null
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,14 +2,27 @@
|
|||||||
|
|
||||||
## 🔉前文提要
|
## 🔉前文提要
|
||||||
|
|
||||||
+ Github(受网络影响,更新很可能不及时)大佬请移步 [Gitee](https://gitee.com/haodong108/dy-barrage-grab) ,参与Issues讨论,QQ讨论群:819927029(进群前请⭐**Star**,谢谢🔪)
|
+ Github(受网络影响,更新很可能不及时)大佬请移步 [Gitee](https://gitee.com/haodong108/dy-barrage-grab) ,参与Issues讨论,QQ技术讨论群:<br>
|
||||||
|
+ 群1: 819927029 (已满)
|
||||||
|
+ 群2: 789875441 (新建)
|
||||||
|
+ 注: (进群前请先⭐**Star**,并填入答案,用于排除行外人员,特殊原因请私聊我),之前因满员踢掉的群员可申请群2。
|
||||||
|
+ <span style="font-size:10px">开不起千人群😅</span>
|
||||||
+ 发行版下载地址在[这里](https://gitee.com/haodong108/dy-barrage-grab/releases),别下成源码包了!!,**决定下载使用前请先仔细阅读文档**,不要进群提问已经介绍到的问题
|
+ 发行版下载地址在[这里](https://gitee.com/haodong108/dy-barrage-grab/releases),别下成源码包了!!,**决定下载使用前请先仔细阅读文档**,不要进群提问已经介绍到的问题
|
||||||
+ 💭 需要ws多直播间直连、自动私信,私信监听、自动发弹幕(正在修复)、获取榜单、礼物、直播间、用户主页信息、直播间其他所有消息类型解析 等功能的可以找我(QQ1083092844)提供一些技术支持(不支持匿名直播间)
|
+ 💭 需要**多直播间超长稳定连接**、**自动私信**(支持群组,单发,支持多账号切换),**私信监听**、**自动关注**、**关注,粉丝群,作品点赞,评论监听**、**直播间发弹幕**、**获取榜单**、**直播间,用户主页信息**、**采集商品上架,连麦,PK等其他所有消息**、**自动作品评论,点赞(开发中...)**、 等功能的可以找我(QQ 1083092844)提供一些技术支持 (注:主要面向个人直播自动化,不面向恶意j流,不支持匿名直播间,想搞采集匿名的勿扰,加群也不会有人支持)
|
||||||
+ 如果这个开源项目能帮老板们赚到玛尼,还望能请杯咖啡支持我更新下去(见底部<a href="#jz">捐赠通道</a>)
|
+ 支持接单,个人定制,dy相关优先,其他方面也可以找我帮忙转发定制,匿名直播间需求勿扰
|
||||||
|
+ 那年,我与TA不可告人的<a href="#user-content-支持一下">秘密</a>😏
|
||||||
|
|
||||||
## ⛳近期更新
|
## ⛳近期更新
|
||||||
2024-03-10 v2.7.2
|
2024-04-26 v2.7.3 (需要升级版本,请先仔细阅读)
|
||||||
|
1. 支持串口转发,详见下方说明<a href="#user-content-串口转发">**串口转发**</a>
|
||||||
|
2. 推送包字段更新<br/>
|
||||||
|
1. 推送包添加 `Onwer`字段,用户描述主播基本信息,客户端应**优先使用其中的SecUid或者Uid作为直播间标识**
|
||||||
|
2. **[破坏性更新]** `WebRoomid` 和 `Roomid` 改为String类型
|
||||||
|
3. 之前直播伴侣开播会导致WebRoomid为-1,现会抓取直播伴侣开播响应信息,并填充WebRoomid,但直播伴侣的WebRoomid设定为主播**抖音号**,需要根据进程名做判断,使用请注意
|
||||||
|
3. [重要修复] 发现抖音部分的礼物弹幕的可连击标识与实际不匹配,导致连击判断出现问题,所以程序更新了本地礼物数据缓存+下载更新的方式,弹幕礼物信息会优先使用本地缓存
|
||||||
|
|
||||||
|
|
||||||
|
2024-03-10 v2.7.2
|
||||||
1. [**重要更新**] 支持设置为轮询模式监听(见配置项**forcePolling**,直播伴侣尚未支持),比起ws更稳定,适合长时间监听
|
1. [**重要更新**] 支持设置为轮询模式监听(见配置项**forcePolling**,直播伴侣尚未支持),比起ws更稳定,适合长时间监听
|
||||||
2. 支持进入直播间画面自动暂停
|
2. 支持进入直播间画面自动暂停
|
||||||
3. 优化礼物连击判定规则,可区分出可连击的礼物,进一步避免礼物数量推送不准确的问题,并新增字段:
|
3. 优化礼物连击判定规则,可区分出可连击的礼物,进一步避免礼物数量推送不准确的问题,并新增字段:
|
||||||
@@ -24,7 +37,7 @@
|
|||||||
|
|
||||||
1. 修复了因抖音版本升级导致的WebRoomId获取不到的问题,并更近了正则表达式尽量兼容后续的变更
|
1. 修复了因抖音版本升级导致的WebRoomId获取不到的问题,并更近了正则表达式尽量兼容后续的变更
|
||||||
2. 添加了winfrom窗体,功能有限,默认隐藏
|
2. 添加了winfrom窗体,功能有限,默认隐藏
|
||||||
3. 支持了控制台隐藏,推送器弹幕类型过滤,日志弹幕类型过滤,弹幕文件日志 (见配置文件)
|
3. 支持了控制台隐藏,推送器弹幕类型过滤,日志弹幕类型过滤,弹幕文件日志 (见<a href="#tag1">配置文件</a>)
|
||||||
4. 支持了更多的ws命令,见 [Command.cs](./BarrageGrab/Modles/JsonEntity/Command.cs)
|
4. 支持了更多的ws命令,见 [Command.cs](./BarrageGrab/Modles/JsonEntity/Command.cs)
|
||||||
|
|
||||||
2023-11-04 v2.6.9
|
2023-11-04 v2.6.9
|
||||||
@@ -102,6 +115,10 @@
|
|||||||
<add key="pollingInterval" value="3000"/>
|
<add key="pollingInterval" value="3000"/>
|
||||||
<!--禁用直播页浏览器脚本缓存 (如果需要确保脚本每次能够正常匹配替换,则启用它,可能会损失一定的页面加载速度)-->
|
<!--禁用直播页浏览器脚本缓存 (如果需要确保脚本每次能够正常匹配替换,则启用它,可能会损失一定的页面加载速度)-->
|
||||||
<add key="disableLivePageScriptCache" value="true"/>
|
<add key="disableLivePageScriptCache" value="true"/>
|
||||||
|
<!--指定要发送的COM串口 格式:'COM1:9600' 代表用COM1发送,波特率9600,若不需要使用串口抄送服务请留空 -->
|
||||||
|
<add key="comPort" value="" />
|
||||||
|
<!--启用自定义消息过滤,启用后可去程序根目录 Scripts/engine/comPortFilter.js 调整过滤规则 -->
|
||||||
|
<add key="useComPortFilter" value="true" />
|
||||||
</appSettings>
|
</appSettings>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -114,12 +131,15 @@
|
|||||||
2. 打开浏览器进入任何直播间进行测试,没有问题再启动直播伴侣
|
2. 打开浏览器进入任何直播间进行测试,没有问题再启动直播伴侣
|
||||||
3. 如果需要对接自己的应用程序,请先了解 [WebSocket](https://www.bilibili.com/video/BV1KN411n7WD/?share_source=copy_web&vd_source=39ebf42c923024b9eddeca32c9e46d16) ,然后进行对接,可前往[这里](http://wstool.jackxiang.com/)测试
|
3. 如果需要对接自己的应用程序,请先了解 [WebSocket](https://www.bilibili.com/video/BV1KN411n7WD/?share_source=copy_web&vd_source=39ebf42c923024b9eddeca32c9e46d16) ,然后进行对接,可前往[这里](http://wstool.jackxiang.com/)测试
|
||||||
|
|
||||||
|
<a id="user-content-串口转发"></a>
|
||||||
|
## 🔌 串口转发</i>
|
||||||
|
+ 配置串口:见<a href="#tag1">配置文件</a>`comPort`,配置发送串口以及波特率,不填则不启用
|
||||||
|
+ 串口报文自定义:可在根目录`Scripts/engine/comPortFilter.js` 根据自己的需求配置转发报文,提供了一定的Bit转换函数,详见其注释
|
||||||
|
|
||||||
## 👨⚕️ 诊断排查
|
## 👨⚕️ 诊断排查
|
||||||
|
|
||||||
+ **启动后无法获取,排查清单**
|
+ **启动后无法获取,排查清单**
|
||||||
1. 先判断自己的浏览器进程名称是否在配置文件列表中
|
1. 先判断自己的浏览器进程名称是否在<a href="#tag1">配置文件</a>列表中
|
||||||
2. 程序启动后,检查系统代理有无正常打开,有可能修改注册表被其他杀毒软件拦截
|
2. 程序启动后,检查系统代理有无正常打开,有可能修改注册表被其他杀毒软件拦截
|
||||||
3. 检查程序是否以管理员身份启动
|
3. 检查程序是否以管理员身份启动
|
||||||
4. 注意程序启动先后顺序(很重要),必须保证在进入直播间之前监听程序已在运行
|
4. 注意程序启动先后顺序(很重要),必须保证在进入直播间之前监听程序已在运行
|
||||||
@@ -131,41 +151,39 @@
|
|||||||
+ 关闭Windows网络防火墙(设置-搜索) ,可能会阻止访问端口号
|
+ 关闭Windows网络防火墙(设置-搜索) ,可能会阻止访问端口号
|
||||||
|
|
||||||
+ *以一种访问权限不允许的方式做了一个访问套接字的尝试*
|
+ *以一种访问权限不允许的方式做了一个访问套接字的尝试*
|
||||||
+ 可能是端口被占用了,请尝试前往配置文件将8888端口号修改为别的号码(1000~65535)
|
+ 可能是端口被占用了,请尝试前往<a href="#tag1">配置文件</a>将8888端口号修改为别的号码(1000~65535)
|
||||||
+ 关杀毒
|
+ 关杀毒
|
||||||
|
|
||||||
+ *尝试执行未经授权的操作*
|
+ *尝试执行未经授权的操作*
|
||||||
+ 关杀毒
|
+ 关杀毒
|
||||||
|
|
||||||
+ *以上都不行*
|
+ *以上都不行*
|
||||||
+ 请前往[这里](https://www.baidu.com/s?word=电脑购买)瞧瞧
|
+ 请前往[这里](https://www.baidu.com/s?word=新款电脑淘宝)瞧瞧
|
||||||
|
|
||||||
|
|
||||||
+ **弹幕断连**
|
+ **弹幕断连**
|
||||||
|
|
||||||
+ 如果浏览器总是连接一段时间后,就在在控制台看不到弹幕了,优先使用Chrome 和 Edge 浏览器,其他浏览器(例如360浏览器) 可能会存在该问题
|
+ 如果浏览器总是连接一段时间后,就在在控制台看不到弹幕了,优先使用Chrome 和 Edge 浏览器,其他浏览器(例如360浏览器) 可能会存在该问题
|
||||||
|
|
||||||
|
+ 尝试打开配置文件 `forcePolling` 选项,情况获取会有所改善
|
||||||
|
|
||||||
+ 其他可能是网络原因,或者直播间断连导致,正在想办法优化解决中。。。需要长时间连接可以找我使用其他方式,支持直连和轮询获取方式
|
+ 其他可能是网络原因,或者直播间断连导致,正在想办法优化解决中。。。需要长时间连接可以找我使用其他方式,支持直连和轮询获取方式
|
||||||
|
|
||||||
+ **程序关闭后无法上网**
|
+ **程序关闭后无法上网**
|
||||||
|
|
||||||
+ 这是因为本程序运行时会占用系统代理,不正确的关闭方式可能会导致系统代理未能正确关闭,请前往找到 系统设置-网络和Internet-代理-使用代理服务器 并关闭它即可
|
+ 这是因为本程序运行时会占用系统代理,不正确的关闭方式可能会导致系统代理未能正确关闭,请前往找到 系统设置-网络和Internet-代理-使用代理服务器 并关闭它即可,也可管理员运行[关闭代理.bat](./关闭代理.bat)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 🎲 实践指南
|
||||||
## 🎲 辅助功能支持
|
+ **隐藏控制台**:见配置文件 `hideConsole`<br><br>
|
||||||
|
+ **远程控制程序**:例如远程关闭,隐藏/显示控制台,启用/关闭系统代理,可发送Json数据包 `{"Cmd":xx,"Data":xx}` 到ws推送地址,数据格式详见: [Command.cs](./BarrageGrab/Modles/JsonEntity/Command.cs)<br><br>
|
||||||
+ **隐藏控制台**: 见配置文件 `hideConsole`
|
+ **启用弹幕文件日志**:见配置文件 `barrageFileLog`,启用后,抓到弹幕会记录在根目录 logs/弹幕日志 文件夹中,支持类型过滤,见`logFilter` 配置项<br><br>
|
||||||
+ **远程控制程序**,例如远程关闭,隐藏/显示控制台,启用/关闭系统代理:
|
+ **UI界面**: 见配置文件 `showWindow ` (做的仓促,功能简陋)<br><br>
|
||||||
+ 发送Json数据包 `{"Cmd":xx,"Data":xx}` 到ws推送地址,数据格式详见: [Command.cs](./BarrageGrab/Modles/JsonEntity/Command.cs)
|
+ **上游代理**:一般用于自己有 代理工具/代理服务器,希望在使用本程序时访问外网不受到影响,见配置文件项`upstreamProxy` 将它改为你代理工具的代理地址<br><br>
|
||||||
+ **启用弹幕文件日志**:
|
+ **局域代理**: 若是只需要监听了浏览器,且不想占用系统代理,可创建一个浏览器快捷方式,打开属性,并在exe文件路径后附加启动参数,`--proxy-server=127.0.0.1:8827`,例如:`"C:\\xxx\chrome.exe" --proxy-server=127.0.0.1:8827`<br><br>
|
||||||
+ 见配置文件 `barrageFileLog`,启用后,抓到弹幕会记录在根目录 logs/弹幕日志 文件夹中,支持类型过滤,见`logFilter` 配置项
|
+ **直播间区分**: 推送包含 `Onwer`字段,用户描述主播基本信息,客户端可以优先使用其中的`SecUid`或者`Uid`作为直播间标识,若使用`WebRoomid`则需要注意直播伴侣进程需要特殊处理,因为直播伴侣推送的WebRoomid是用户的抖音号。`RoomId`只能作为场次标识,每次开播都会不一样,不可用作直播间唯一区分<br><br>
|
||||||
|
+ **直播间地址**: 冷知识,使用`https://live.douyin.com/<抖音号>` 也可以进入主播直播间
|
||||||
+ **上游代理设置**:
|
|
||||||
+ 一般用于自己有 代理工具/代理服务器,希望在使用本程序时访问外网不受到影响,见配置文件项`upstreamProxy` 将它改为你代理工具的代理地址
|
|
||||||
+ **UI界面**: 见配置文件 `showWindow ` (做的仓促,功能简陋)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ⚠️特别注意
|
## ⚠️特别注意
|
||||||
@@ -176,7 +194,7 @@
|
|||||||
|
|
||||||
3. 只有到达客户端的弹幕数据才能被接收,被抖音服务器过滤的弹幕是抓不到的
|
3. 只有到达客户端的弹幕数据才能被接收,被抖音服务器过滤的弹幕是抓不到的
|
||||||
|
|
||||||
4. 关闭程序后若有无法上网的情况请检查: 网络和internet设置-->代理-->使用代理服务器 ,关闭即可
|
4. 关闭程序后若有无法上网的情况请检查: 网络和internet设置-->代理-->使用代理服务器 ,关闭即可,也可管理员运行[关闭代理.bat](./关闭代理.bat)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -193,9 +211,9 @@
|
|||||||
+ 本程序仅供学习参考,不得用于商业用途,不得用于恶意搜集他人直播间用户信息!
|
+ 本程序仅供学习参考,不得用于商业用途,不得用于恶意搜集他人直播间用户信息!
|
||||||
+ 请详细阅读[免责声明](./免责声明.txt)条款后进行使用
|
+ 请详细阅读[免责声明](./免责声明.txt)条款后进行使用
|
||||||
|
|
||||||
|
<a id="user-content-支持一下" class="anchor"></a>
|
||||||
## 🍻支持一下?
|
## 🍻支持一下?
|
||||||
开源不易
|
开源不易啊老板
|
||||||
|
<p>
|
||||||
<p id="'jz'">
|
|
||||||
<img src="./imgs/微信.png" alt="微信支付" style="zoom:70%;border-radius: 5px;" />
|
<img src="./imgs/微信.png" alt="微信支付" style="zoom:70%;border-radius: 5px;" />
|
||||||
</p>
|
</p>
|
||||||
Reference in New Issue
Block a user