diff --git a/Lagrange.Core/Internal/Service/Message/ImageGroupUploadService.cs b/Lagrange.Core/Internal/Service/Message/ImageGroupUploadService.cs index 141557f57..9c05e75b4 100644 --- a/Lagrange.Core/Internal/Service/Message/ImageGroupUploadService.cs +++ b/Lagrange.Core/Internal/Service/Message/ImageGroupUploadService.cs @@ -20,10 +20,10 @@ protected override bool Build(ImageGroupUploadEvent input, BotKeystore keystore, BotDeviceInfo device, out Span output, out List>? extraPackets) { if (input.Entity.ImageStream is null) throw new Exception(); - + string md5 = input.Entity.ImageStream.Value.Md5(true); string sha1 = input.Entity.ImageStream.Value.Sha1(true); - + var buffer = new byte[1024]; // parse image header int _ = input.Entity.ImageStream.Value.Read(buffer.AsSpan()); var type = ImageResolver.Resolve(buffer, out var size); @@ -39,6 +39,7 @@ protected override bool Build(ImageGroupUploadEvent input, BotKeystore keystore, }; input.Entity.ImageStream.Value.Position = 0; + string subType = input.Entity.SubType.ToString("X2"); var packet = new OidbSvcTrpcTcpBase(new NTV2RichMediaReq { ReqHead = new MultiMediaReqHead @@ -76,8 +77,8 @@ protected override bool Build(ImageGroupUploadEvent input, BotKeystore keystore, VideoFormat = 0, VoiceFormat = 0 }, - Width = (uint)size.X, - Height = (uint)size.Y, + Width = input.Entity.W == 0 ?(uint)size.X : input.Entity.W, + Height = input.Entity.H == 0 ?(uint)size.Y : input.Entity.H, Time = 0, Original = 1 }, @@ -92,8 +93,9 @@ protected override bool Build(ImageGroupUploadEvent input, BotKeystore keystore, { Pic = new PicExtBizInfo { + BizType = (uint)input.Entity.SubType, TextSummary = input.Entity.Summary!, - BytesPbReserveTroop = "0800180020004a00500062009201009a0100aa010c080012001800200028003a00".UnHex() + BytesPbReserveTroop = $"08{subType}180020004a00500062009201009a0100aa010c080012001800200028003a00".UnHex() }, Video = new VideoExtBizInfo { BytesPbReserve = Array.Empty() }, Ptt = new PttExtBizInfo @@ -107,7 +109,7 @@ protected override bool Build(ImageGroupUploadEvent input, BotKeystore keystore, NoNeedCompatMsg = false } }, 0x11c4, 100, false, true); - + output = packet.Serialize(); extraPackets = null; return true; @@ -119,7 +121,7 @@ protected override bool Parse(Span input, BotKeystore keystore, BotAppInfo var packet = Serializer.Deserialize>(input); var upload = packet.Body.Upload; var compat = Serializer.Deserialize(upload.CompatQMsg.AsSpan()); - + output = ImageGroupUploadEvent.Result((int)packet.ErrorCode, upload.MsgInfo, upload.UKey, upload.IPv4s, upload.SubFileInfos, compat); extraEvents = null; return true; diff --git a/Lagrange.Core/Message/Entity/ImageEntity.cs b/Lagrange.Core/Message/Entity/ImageEntity.cs index bc4924771..b69ba378f 100644 --- a/Lagrange.Core/Message/Entity/ImageEntity.cs +++ b/Lagrange.Core/Message/Entity/ImageEntity.cs @@ -40,6 +40,9 @@ public class ImageEntity : IMessageEntity internal string? Summary { get; set; } + internal uint H { get; set; } + internal uint W { get; set; } + public int SubType { get; set; } internal bool IsGroup => GroupUin.HasValue; diff --git a/Lagrange.OneBot/Message/Entity/ImageSegment.cs b/Lagrange.OneBot/Message/Entity/ImageSegment.cs index 52db1c270..1c552b097 100644 --- a/Lagrange.OneBot/Message/Entity/ImageSegment.cs +++ b/Lagrange.OneBot/Message/Entity/ImageSegment.cs @@ -5,19 +5,23 @@ namespace Lagrange.OneBot.Message.Entity; [Serializable] -public partial class ImageSegment(string url, string filename, string summary = "[图片]", int subType = 0) +public partial class ImageSegment(string url, string filename, string summary = "[图片]", int subType = 0, uint height = 0, uint width = 0) { public ImageSegment() : this("", "") { } - [JsonPropertyName("file")] [CQProperty] public string File { get; set; } = url; - + [JsonPropertyName("file")][CQProperty] public string File { get; set; } = url; + [JsonPropertyName("filename")] public string Filename { get; set; } = filename; - - [JsonPropertyName("url")] public string Url { get; set; } = url; + + [JsonPropertyName("url")] public string Url { get; set; } = url; [JsonPropertyName("summary")] public string Summary { get; set; } = summary; - + [JsonPropertyName("subType")] public int SubType { get; set; } = subType; + + [JsonPropertyName("height")] public uint Height { get; set; } = height; + + [JsonPropertyName("width")] public uint Width { get; set; } = width; } [SegmentSubscriber(typeof(ImageEntity), "image")] @@ -32,7 +36,9 @@ public override void Build(MessageBuilder builder, SegmentBase segment) FilePath = imageSegment.Filename, ImageStream = new Lazy(stream), Summary = imageSegment.Summary, - SubType = imageSegment.SubType + SubType = imageSegment.SubType, + H = imageSegment.Height, + W = imageSegment.Width }); } }