From fd355febf71500467a15c94904c9c53df5a884c9 Mon Sep 17 00:00:00 2001 From: Ted Zyzsdy Date: Wed, 29 May 2019 22:54:46 +0800 Subject: [PATCH] =?UTF-8?q?B=E7=AB=99190529=E5=BC=B9=E5=B9=95=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BiLiRoku/Commentlib/CommentModel.cs | 85 +++++++++++++---------------- BiLiRoku/RoomList.cs | 2 +- BiLiRoku/Version.cs | 8 +-- 3 files changed, 44 insertions(+), 51 deletions(-) diff --git a/BiLiRoku/Commentlib/CommentModel.cs b/BiLiRoku/Commentlib/CommentModel.cs index a22718c..142a94f 100644 --- a/BiLiRoku/Commentlib/CommentModel.cs +++ b/BiLiRoku/Commentlib/CommentModel.cs @@ -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; } diff --git a/BiLiRoku/RoomList.cs b/BiLiRoku/RoomList.cs index 4e46e88..2c43cd1 100644 --- a/BiLiRoku/RoomList.cs +++ b/BiLiRoku/RoomList.cs @@ -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) { diff --git a/BiLiRoku/Version.cs b/BiLiRoku/Version.cs index 4d0d163..8ebfcd4 100644 --- a/BiLiRoku/Version.cs +++ b/BiLiRoku/Version.cs @@ -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"; } // 检查更新