-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65ba880
commit ef74c5f
Showing
3 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
Lagrange.Core/Internal/Packets/Message/Component/Extra/GreyTipExtra.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Packets.Message.Component.Extra; | ||
|
||
[ProtoContract] | ||
internal class GreyTipExtra | ||
{ | ||
[ProtoMember(101)] public GreyTipExtraLayer1? Layer1 { get; set; } | ||
} | ||
|
||
[ProtoContract] | ||
internal class GreyTipExtraLayer1 | ||
{ | ||
[ProtoMember(1)] public GreyTipExtraInfo? Info { get; set; } | ||
} | ||
|
||
[ProtoContract] | ||
internal class GreyTipExtraInfo | ||
{ | ||
[ProtoMember(1)] public uint Type { get; set; } // 1 | ||
|
||
[ProtoMember(2)] public string Content { get; set; } = string.Empty; // "{\"gray_tip\":\"谨防兼职刷单、游戏交易、投资荐股、色情招嫖、仿冒公检法及客服人员的网络骗局,如有资金往来请谨慎操作。 \",\"object_type\":3,\"sub_type\":2,\"type\":4}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
using Lagrange.Core.Internal.Packets.Message.Component.Extra; | ||
using Lagrange.Core.Internal.Packets.Message.Element; | ||
using Lagrange.Core.Internal.Packets.Message.Element.Implementation; | ||
using Lagrange.Core.Utility.Extension; | ||
|
||
namespace Lagrange.Core.Message.Entity; | ||
|
||
public class GreyTipEntity : IMessageEntity | ||
{ | ||
public string GreyTip { get; } | ||
|
||
public GreyTipEntity(string greyTip) => GreyTip = greyTip; | ||
|
||
public GreyTipEntity() => GreyTip = string.Empty; | ||
|
||
IEnumerable<Elem> IMessageEntity.PackElement() | ||
{ | ||
var content = new GreyTipContent | ||
{ | ||
GrayTip = GreyTip, | ||
ObjectType = 3, | ||
SubType = 2, | ||
Type = 4 | ||
}; | ||
|
||
var extra = new GreyTipExtra | ||
{ | ||
Layer1 = new GreyTipExtraLayer1 | ||
{ | ||
Info = new GreyTipExtraInfo { Content = JsonSerializer.Serialize(content), Type = 1 } | ||
} | ||
}; | ||
|
||
return new Elem[] | ||
{ | ||
new() | ||
{ | ||
GeneralFlags = new GeneralFlags | ||
{ | ||
PbReserve = extra.Serialize().ToArray(), | ||
} | ||
} | ||
}; | ||
} | ||
|
||
IMessageEntity? IMessageEntity.UnpackElement(Elem elem) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public string ToPreviewString() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
private class GreyTipContent | ||
{ | ||
[JsonPropertyName("gray_tip")] public string GrayTip { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("object_type")] public uint ObjectType { get; set; } | ||
|
||
[JsonPropertyName("sub_type")] public uint SubType { get; set; } | ||
|
||
[JsonPropertyName("type")] public uint Type { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters