Skip to content

Commit

Permalink
屏蔽功能适配礼物
Browse files Browse the repository at this point in the history
  • Loading branch information
CHKZL committed Aug 20, 2024
1 parent 1501ebf commit e2b3fae
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 80 deletions.
163 changes: 85 additions & 78 deletions Core/RuntimeObject/Download/Basics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,97 +414,104 @@ public static List<long> GetOptionalClarity(long RoomId, string protocol_name, s
public static void LiveChatListener_MessageReceived(object? sender, Core.LiveChat.MessageEventArgs e)
{
LiveChatListener liveChatListener = (LiveChatListener)sender;
switch (e)
if (liveChatListener != null)
{
case DanmuMessageEventArgs Danmu:
{
string[] BlockWords = Core.Config.Core_RunConfig._BlockBarrageList.Split('|');
if (BlockWords.Any(Danmu.Message.Contains))
switch (e)
{
case DanmuMessageEventArgs Danmu:
{
string[] BlockWords = Core.Config.Core_RunConfig._BlockBarrageList.Split('|');
if (BlockWords.Any(Danmu.Message.Contains))
{
return;
}
liveChatListener.DanmuMessage.Danmu.Add(new Danmu.DanmuInfo
{
color = Danmu.MessageColor,
pool = 0,
size = 25,
timestamp = Danmu.Timestamp,
type = Danmu.MessageType,
time = liveChatListener.TimeStopwatch.ElapsedMilliseconds / 1000.00,
uid = Danmu.UserId,
Message = Danmu.Message,
Nickname = Danmu.UserName,
LV = Danmu.GuardLV
});

break;
}
liveChatListener.DanmuMessage.Danmu.Add(new Danmu.DanmuInfo
case SuperchatEventArg SuperchatEvent:
{
color = Danmu.MessageColor,
pool = 0,
size = 25,
timestamp = Danmu.Timestamp,
type = Danmu.MessageType,
time = liveChatListener.TimeStopwatch.ElapsedMilliseconds / 1000.00,
uid = Danmu.UserId,
Message = Danmu.Message,
Nickname = Danmu.UserName,
LV = Danmu.GuardLV
});

break;
}
case SuperchatEventArg SuperchatEvent:
{

liveChatListener.DanmuMessage.SuperChat.Add(new Danmu.SuperChatInfo()
liveChatListener.DanmuMessage.SuperChat.Add(new Danmu.SuperChatInfo()
{
Message = SuperchatEvent.Message,
MessageTrans = SuperchatEvent.messageTrans,
Price = SuperchatEvent.Price,
Time = liveChatListener.TimeStopwatch.ElapsedMilliseconds / 1000.00,
Timestamp = SuperchatEvent.Timestamp,
UserId = SuperchatEvent.UserId,
UserName = SuperchatEvent.UserName,
TimeLength = SuperchatEvent.TimeLength
});
break;
}
case GuardBuyEventArgs GuardBuyEvent:
{
Message = SuperchatEvent.Message,
MessageTrans = SuperchatEvent.messageTrans,
Price = SuperchatEvent.Price,
Time = liveChatListener.TimeStopwatch.ElapsedMilliseconds / 1000.00,
Timestamp = SuperchatEvent.Timestamp,
UserId = SuperchatEvent.UserId,
UserName = SuperchatEvent.UserName,
TimeLength = SuperchatEvent.TimeLength
});
break;
}
case GuardBuyEventArgs GuardBuyEvent:
{

liveChatListener.DanmuMessage.GuardBuy.Add(new Danmu.GuardBuyInfo()
liveChatListener.DanmuMessage.GuardBuy.Add(new Danmu.GuardBuyInfo()
{
GuardLevel = GuardBuyEvent.GuardLevel,
GuradName = GuardBuyEvent.GuardName,
Number = GuardBuyEvent.Number,
Price = GuardBuyEvent.Price,
Time = liveChatListener.TimeStopwatch.ElapsedMilliseconds / 1000.00,
Timestamp = GuardBuyEvent.Timestamp,
UserId = GuardBuyEvent.UserId,
UserName = GuardBuyEvent.UserName
});
break;
}
case GuardRenewEventArgs guardRenewEvent:
{
GuardLevel = GuardBuyEvent.GuardLevel,
GuradName = GuardBuyEvent.GuardName,
Number = GuardBuyEvent.Number,
Price = GuardBuyEvent.Price,
Time = liveChatListener.TimeStopwatch.ElapsedMilliseconds / 1000.00,
Timestamp = GuardBuyEvent.Timestamp,
UserId = GuardBuyEvent.UserId,
UserName = GuardBuyEvent.UserName
});
break;
}
case GuardRenewEventArgs guardRenewEvent:
{

liveChatListener.DanmuMessage.GuardBuy.Add(new Danmu.GuardBuyInfo()
{
GuardLevel = guardRenewEvent.GuardLevel,
GuradName = guardRenewEvent.GuardName,
Number = guardRenewEvent.Number,
Price = guardRenewEvent.Price,
Time = liveChatListener.TimeStopwatch.ElapsedMilliseconds / 1000.00,
Timestamp = guardRenewEvent.Timestamp,
UserId = guardRenewEvent.UserId,
UserName = guardRenewEvent.UserName
});
break;
}
case SendGiftEventArgs sendGiftEventArgs:
{
liveChatListener.DanmuMessage.Gift.Add(new Danmu.GiftInfo()
liveChatListener.DanmuMessage.GuardBuy.Add(new Danmu.GuardBuyInfo()
{
GuardLevel = guardRenewEvent.GuardLevel,
GuradName = guardRenewEvent.GuardName,
Number = guardRenewEvent.Number,
Price = guardRenewEvent.Price,
Time = liveChatListener.TimeStopwatch.ElapsedMilliseconds / 1000.00,
Timestamp = guardRenewEvent.Timestamp,
UserId = guardRenewEvent.UserId,
UserName = guardRenewEvent.UserName
});
break;
}
case SendGiftEventArgs sendGiftEventArgs:
{
Amount = sendGiftEventArgs.Amount,
GiftName = sendGiftEventArgs.GiftName,
Price = sendGiftEventArgs.GiftPrice,
Time = liveChatListener.TimeStopwatch.ElapsedMilliseconds / 1000.00,
Timestamp = sendGiftEventArgs.Timestamp,
UserId = sendGiftEventArgs.UserId,
UserName = sendGiftEventArgs.UserName
});
string[] BlockWords = Core.Config.Core_RunConfig._BlockBarrageList.Split('|');
if (BlockWords.Any(sendGiftEventArgs.GiftName.Contains))
{
return;
}
liveChatListener.DanmuMessage.Gift.Add(new Danmu.GiftInfo()
{
Amount = sendGiftEventArgs.Amount,
GiftName = sendGiftEventArgs.GiftName,
Price = sendGiftEventArgs.GiftPrice,
Time = liveChatListener.TimeStopwatch.ElapsedMilliseconds / 1000.00,
Timestamp = sendGiftEventArgs.Timestamp,
UserId = sendGiftEventArgs.UserId,
UserName = sendGiftEventArgs.UserName
});
break;
}
default:
break;
}
default:
break;
}
}

}


Expand Down
7 changes: 6 additions & 1 deletion Desktop/Views/Windows/DanmaOnlyWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void LiveChatListener_MessageReceived(object? sender, Core.LiveChat.Mess
string[] BlockWords = Core.Config.Core_RunConfig._BlockBarrageList.Split('|');
if (BlockWords.Any(Danmu.Message.Contains))
{
break;
return;
}
msg.Message = $"{Danmu.UserName}{Danmu.Message}";
break;
Expand All @@ -97,6 +97,11 @@ private void LiveChatListener_MessageReceived(object? sender, Core.LiveChat.Mess
}
case SendGiftEventArgs sendGiftEventArgs:
{
string[] BlockWords = Core.Config.Core_RunConfig._BlockBarrageList.Split('|');
if (BlockWords.Any(sendGiftEventArgs.GiftName.Contains))
{
return;
}
msg.Message = $"{sendGiftEventArgs.UserName}:赠送[{sendGiftEventArgs.GiftName}]礼物[{sendGiftEventArgs.Amount}]个";
break;
}
Expand Down
2 changes: 1 addition & 1 deletion Desktop/Views/Windows/VlcPlayWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private void LiveChatListener_MessageReceived(object? sender, Core.LiveChat.Mess
string[] BlockWords = Core.Config.Core_RunConfig._BlockBarrageList.Split('|');
if (BlockWords.Any(Danmu.Message.Contains))
{
break;
return;
}
AddDanmu(Danmu.Message, false, Danmu.UserId);
break;
Expand Down

0 comments on commit e2b3fae

Please sign in to comment.