Skip to content

Commit

Permalink
B站190529弹幕协议更新
Browse files Browse the repository at this point in the history
  • Loading branch information
zyzsdy committed May 29, 2019
1 parent 420d09c commit fd355fe
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 51 deletions.
85 changes: 39 additions & 46 deletions BiLiRoku/Commentlib/CommentModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,53 +134,46 @@ public CommentModel(string json, long time, int version = 1)
var obj = JObject.Parse(json);

var cmd = obj["cmd"].ToString();
switch (cmd)
if (cmd.StartsWith("LIVE"))
{
case "LIVE":
MsgType = MsgTypeEnum.LiveStart;
RoomId = obj["roomid"].ToString();
break;
case "PREPARING":
MsgType = MsgTypeEnum.LiveEnd;
RoomId = obj["roomid"].ToString();
break;
case "DANMU_MSG":
CommentText = obj["info"][1].ToString();
CommentUser = obj["info"][2][1].ToString();
IsAdmin = obj["info"][2][2].ToString() == "1";
IsVip = obj["info"][2][3].ToString() == "1";
DmType = Convert.ToInt32(obj["info"][0][1]);
Fontsize = Convert.ToInt32(obj["info"][0][2]);
Color = Convert.ToInt32(obj["info"][0][3]);
SendTimestamp = Convert.ToInt64(obj["info"][0][4]);
UserHash = obj["info"][0][7].ToString();
MsgType = MsgTypeEnum.Comment;
break;
case "SEND_GIFT":
MsgType = MsgTypeEnum.GiftSend;
GiftName = obj["data"]["giftName"].ToString();
GiftUser = obj["data"]["uname"].ToString();
Giftrcost = obj["data"]["rcost"].ToString();
GiftNum = obj["data"]["num"].ToString();
break;
case "GIFT_TOP":
{
MsgType = MsgTypeEnum.GiftTop;
break;
}
case "WELCOME":
{
MsgType = MsgTypeEnum.Welcome;
CommentUser = obj["data"]["uname"].ToString();
IsVip = true;
IsAdmin = obj["data"]["isadmin"].ToString() == "1";
break;
}
default:
{
MsgType = MsgTypeEnum.Unknown;
break;
}
MsgType = MsgTypeEnum.LiveStart;
RoomId = obj["roomid"].ToString();
}else if (cmd.StartsWith("PREPARING"))
{
MsgType = MsgTypeEnum.LiveEnd;
RoomId = obj["roomid"].ToString();
}else if (cmd.StartsWith("DANMU_MSG"))
{
CommentText = obj["info"][1].ToString();
CommentUser = obj["info"][2][1].ToString();
IsAdmin = obj["info"][2][2].ToString() == "1";
IsVip = obj["info"][2][3].ToString() == "1";
DmType = Convert.ToInt32(obj["info"][0][1]);
Fontsize = Convert.ToInt32(obj["info"][0][2]);
Color = Convert.ToInt32(obj["info"][0][3]);
SendTimestamp = Convert.ToInt64(obj["info"][0][4]);
UserHash = obj["info"][0][7].ToString();
MsgType = MsgTypeEnum.Comment;
}else if (cmd.StartsWith("SEND_GIFT"))
{
MsgType = MsgTypeEnum.GiftSend;
GiftName = obj["data"]["giftName"].ToString();
GiftUser = obj["data"]["uname"].ToString();
Giftrcost = obj["data"]["rcost"].ToString();
GiftNum = obj["data"]["num"].ToString();
}else if (cmd.StartsWith("GIFT_TOP"))
{
MsgType = MsgTypeEnum.GiftTop;
}else if (cmd.StartsWith("WELCOME"))
{
MsgType = MsgTypeEnum.Welcome;
CommentUser = obj["data"]["uname"].ToString();
IsVip = true;
IsAdmin = obj["data"]["isadmin"].ToString() == "1";
}
else
{
MsgType = MsgTypeEnum.Unknown;
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion BiLiRoku/RoomList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ private void CommentProvider_OnReceivedComment(object sender, ReceivedCommentArg
try
{
//DEBUG: 弹幕显示测试
//InfoLogger.SendInfo(_roomid, "收到弹幕", e.Comment.CommentUser + ": " + e.Comment.CommentText);
//InfoLogger.SendInfo(Roomid, "收到弹幕", e.Comment.CommentUser + ": " + e.Comment.CommentText);
//接收到弹幕时的处理。
if (e.Comment.MsgType != MsgTypeEnum.LiveStart)
{
Expand Down
8 changes: 4 additions & 4 deletions BiLiRoku/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ namespace BiliRoku
[SuppressMessage("ReSharper", "InconsistentNaming")]
internal static class Ver
{
public const string VER = "2.0.2";
public const string DATE = "(2019-4-13)";
public const string DESC = "修复BUG:直播标题中特殊字符会导致程序崩溃。\nUI界面微小调整。";
public const string VER = "2.0.3";
public const string DATE = "(2019-5-29)";
public const string DESC = "B站弹幕协议更新";
public static readonly string OS_VER = "(" + WinVer.SystemVersion.Major + "." + WinVer.SystemVersion.Minor + "." + WinVer.SystemVersion.Build + ")";
public static readonly string UA = "FeelyBlog/1.1 BiliRoku/2.0.2 " + OS_VER + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36";
public static readonly string UA = "FeelyBlog/1.1 BiliRoku/2.0.3 " + OS_VER + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36";
}

// 检查更新
Expand Down

0 comments on commit fd355fe

Please sign in to comment.