feat(core): log stream cut off and ban

close #484
This commit is contained in:
genteure 2023-06-17 19:37:21 +08:00
parent f1918ea37f
commit 1f2073fc3b
2 changed files with 32 additions and 8 deletions

View File

@ -36,7 +36,15 @@ namespace BililiveRecorder.Core.Api.Danmaku
/// <summary>
/// 房间信息更新
/// </summary>
RoomChange
RoomChange,
/// <summary>
/// 房间被锁定
/// </summary>
RoomLock,
/// <summary>
/// 直播被切断
/// </summary>
CutOff,
}
internal class DanmakuModel
@ -181,15 +189,15 @@ namespace BililiveRecorder.Core.Api.Danmaku
switch (cmd)
{
case "LIVE":
case "LIVE": // 开播
this.MsgType = DanmakuMsgType.LiveStart;
this.RoomID = obj["roomid"]?.ToObject<string>();
break;
case "PREPARING":
case "PREPARING": // 下播
this.MsgType = DanmakuMsgType.LiveEnd;
this.RoomID = obj["roomid"]?.ToObject<string>();
break;
case "DANMU_MSG":
case "DANMU_MSG": // 弹幕
this.MsgType = DanmakuMsgType.Comment;
this.CommentText = obj["info"]?[1]?.ToObject<string>();
this.UserID = obj["info"]?[2]?[0]?.ToObject<long>() ?? 0;
@ -198,14 +206,14 @@ namespace BililiveRecorder.Core.Api.Danmaku
this.IsVIP = obj["info"]?[2]?[3]?.ToObject<string>() == "1";
this.UserGuardLevel = obj["info"]?[7]?.ToObject<int>() ?? 0;
break;
case "SEND_GIFT":
case "SEND_GIFT": // 送礼物
this.MsgType = DanmakuMsgType.GiftSend;
this.GiftName = obj["data"]?["giftName"]?.ToObject<string>();
this.UserName = obj["data"]?["uname"]?.ToObject<string>();
this.UserID = obj["data"]?["uid"]?.ToObject<long>() ?? 0;
this.GiftCount = obj["data"]?["num"]?.ToObject<int>() ?? 0;
break;
case "GUARD_BUY":
case "GUARD_BUY": // 购买舰长
{
this.MsgType = DanmakuMsgType.GuardBuy;
this.UserID = obj["data"]?["uid"]?.ToObject<long>() ?? 0;
@ -215,7 +223,7 @@ namespace BililiveRecorder.Core.Api.Danmaku
this.GiftCount = obj["data"]?["num"]?.ToObject<int>() ?? 0;
break;
}
case "SUPER_CHAT_MESSAGE":
case "SUPER_CHAT_MESSAGE": // SC
{
this.MsgType = DanmakuMsgType.SuperChat;
this.CommentText = obj["data"]?["message"]?.ToString();
@ -225,7 +233,7 @@ namespace BililiveRecorder.Core.Api.Danmaku
this.SCKeepTime = obj["data"]?["time"]?.ToObject<int>() ?? 0;
break;
}
case "ROOM_CHANGE":
case "ROOM_CHANGE": // 房间信息变更
{
this.MsgType = DanmakuMsgType.RoomChange;
this.Title = obj["data"]?["title"]?.ToObject<string>();
@ -233,6 +241,16 @@ namespace BililiveRecorder.Core.Api.Danmaku
this.ParentAreaName = obj["data"]?["parent_area_name"]?.ToObject<string>();
break;
}
case "ROOM_LOCK": // 房间被锁定
{
this.MsgType = DanmakuMsgType.RoomLock;
break;
}
case "CUT_OFF": // 直播被切断
{
this.MsgType = DanmakuMsgType.CutOff;
break;
}
default:
{
this.MsgType = DanmakuMsgType.Unknown;

View File

@ -549,6 +549,12 @@ retry:
this.AreaNameParent = d.ParentAreaName ?? this.AreaNameParent;
this.AreaNameChild = d.AreaName ?? this.AreaNameChild;
break;
case Api.Danmaku.DanmakuMsgType.RoomLock:
this.logger.Information("直播间被封禁");
break;
case Api.Danmaku.DanmakuMsgType.CutOff:
this.logger.Information("直播被管理员切断");
break;
default:
break;
}