diff --git a/Lagrange.Core/Common/Interface/Api/OperationExt.cs b/Lagrange.Core/Common/Interface/Api/OperationExt.cs index cf3cefcbd..26d38f1ec 100644 --- a/Lagrange.Core/Common/Interface/Api/OperationExt.cs +++ b/Lagrange.Core/Common/Interface/Api/OperationExt.cs @@ -313,4 +313,11 @@ public static Task FetchPrivateFSDownload(this BotContext bot, string fi public static Task SendPoke(this BotContext bot, bool isGroup, uint peerUin, uint? targetUin = null) => bot.ContextCollection.Business.OperationLogic.SendPoke(isGroup, peerUin, targetUin); + + public static Task<(int Code, string Message)> GroupRecallPoke(this BotContext bot, ulong groupUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) + => bot.ContextCollection.Business.OperationLogic.GroupRecallPoke(groupUin, messageSequence, messageTime, tipsSeqId); + + public static Task<(int Code, string Message)> FriendRecallPoke(this BotContext bot, ulong peerUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) + => bot.ContextCollection.Business.OperationLogic.FriendRecallPoke(peerUin, messageSequence, messageTime, tipsSeqId); + } \ No newline at end of file diff --git a/Lagrange.Core/Event/EventArg/FriendPokeEvent.cs b/Lagrange.Core/Event/EventArg/FriendPokeEvent.cs index 54f0f7242..7eef690f0 100644 --- a/Lagrange.Core/Event/EventArg/FriendPokeEvent.cs +++ b/Lagrange.Core/Event/EventArg/FriendPokeEvent.cs @@ -3,23 +3,35 @@ namespace Lagrange.Core.Event.EventArg; public class FriendPokeEvent : EventBase { public uint OperatorUin { get; } - + public uint TargetUin { get; } - + public string Action { get; } - + public string Suffix { get; } public string ActionImgUrl { get; } - - public FriendPokeEvent(uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl) - { + + public ulong PeerUin { get; } + + public ulong MessageSequence { get; } + + public ulong MessageTime { get; } + + public ulong TipsSeqId { get; } + + public FriendPokeEvent(uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl, ulong peerUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) + { OperatorUin = operatorUin; TargetUin = targetUin; Action = action; Suffix = suffix; ActionImgUrl = actionImgUrl; - + PeerUin = peerUin; + MessageSequence = messageSequence; + MessageTime = messageTime; + TipsSeqId = tipsSeqId; + EventMessage = $"{nameof(FriendPokeEvent)}: OperatorUin: {OperatorUin} | TargetUin: {TargetUin} | Action: {Action} | Suffix: {Suffix} | ActionImgUrl: {ActionImgUrl}"; } } diff --git a/Lagrange.Core/Event/EventArg/FriendRecallPokeEvent.cs b/Lagrange.Core/Event/EventArg/FriendRecallPokeEvent.cs new file mode 100644 index 000000000..16213eeea --- /dev/null +++ b/Lagrange.Core/Event/EventArg/FriendRecallPokeEvent.cs @@ -0,0 +1,19 @@ +namespace Lagrange.Core.Event.EventArg; + +public class FriendRecallPokeEvent : EventBase +{ + public uint PeerUin { get; } + + public uint OperatorUin { get; } + + public ulong TipsSeqId { get; set; } + + public FriendRecallPokeEvent(uint peerUin, uint operatorUin, ulong tipsSeqId) + { + PeerUin = peerUin; + OperatorUin = operatorUin; + TipsSeqId = tipsSeqId; + + EventMessage = $"[FriendRecallPoke] Peer: {PeerUin} | Operator: {OperatorUin} | TipsSeqId: {TipsSeqId}"; + } +} \ No newline at end of file diff --git a/Lagrange.Core/Event/EventArg/GroupPokeEvent.cs b/Lagrange.Core/Event/EventArg/GroupPokeEvent.cs index ea41cc1f5..aefb79048 100644 --- a/Lagrange.Core/Event/EventArg/GroupPokeEvent.cs +++ b/Lagrange.Core/Event/EventArg/GroupPokeEvent.cs @@ -3,18 +3,24 @@ namespace Lagrange.Core.Event.EventArg; public class GroupPokeEvent : EventBase { public uint GroupUin { get; } - + public uint OperatorUin { get; } - + public uint TargetUin { get; } - + public string Action { get; } - + public string Suffix { get; } - + public string ActionImgUrl { get; } - - public GroupPokeEvent(uint groupUin, uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl) + + public ulong MessageSequence { get; } + + public ulong MessageTime { get; } + + public ulong TipsSeqId { get; } + + public GroupPokeEvent(uint groupUin, uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl, ulong messageSequence, ulong messageTime, ulong tipsSeqId) { GroupUin = groupUin; OperatorUin = operatorUin; @@ -22,7 +28,10 @@ public GroupPokeEvent(uint groupUin, uint operatorUin, uint targetUin, string ac Action = action; Suffix = suffix; ActionImgUrl = actionImgUrl; - + MessageSequence = messageSequence; + MessageTime = messageTime; + TipsSeqId = tipsSeqId; + EventMessage = $"{nameof(GroupPokeEvent)}: GroupUin: {GroupUin} | OperatorUin: {OperatorUin} | TargetUin: {TargetUin} | Action: {Action} | Suffix: {Suffix} | ActionImgUrl: {ActionImgUrl}"; } } diff --git a/Lagrange.Core/Event/EventArg/GroupRecallPokeEvent.cs b/Lagrange.Core/Event/EventArg/GroupRecallPokeEvent.cs new file mode 100644 index 000000000..ca102f0a0 --- /dev/null +++ b/Lagrange.Core/Event/EventArg/GroupRecallPokeEvent.cs @@ -0,0 +1,19 @@ +namespace Lagrange.Core.Event.EventArg; + +public class GroupRecallPokeEvent : EventBase +{ + public uint GroupUin { get; } + + public uint OperatorUin { get; } + + public ulong TipsSeqId { get; set; } + + public GroupRecallPokeEvent(uint groupUin, uint operatorUin, ulong tipsSeqId) + { + GroupUin = groupUin; + OperatorUin = operatorUin; + TipsSeqId = tipsSeqId; + + EventMessage = $"[GroupRecallPoke] Group: {GroupUin} | Operator: {OperatorUin} | TipsSeqId: {TipsSeqId}"; + } +} \ No newline at end of file diff --git a/Lagrange.Core/Event/EventInvoker.Events.cs b/Lagrange.Core/Event/EventInvoker.Events.cs index c5725b17c..357202af4 100644 --- a/Lagrange.Core/Event/EventInvoker.Events.cs +++ b/Lagrange.Core/Event/EventInvoker.Events.cs @@ -59,4 +59,8 @@ public partial class EventInvoker public event LagrangeEvent? OnGroupMemberEnterEvent; public event LagrangeEvent? OnPinChangedEvent; + + public event LagrangeEvent? OnGroupRecallPokeEvent; + + public event LagrangeEvent? OnFriendRecallPokeEvent; } \ No newline at end of file diff --git a/Lagrange.Core/Event/EventInvoker.cs b/Lagrange.Core/Event/EventInvoker.cs index a025ca755..9e49c8766 100644 --- a/Lagrange.Core/Event/EventInvoker.cs +++ b/Lagrange.Core/Event/EventInvoker.cs @@ -43,6 +43,8 @@ internal EventInvoker(BotContext context) RegisterEvent((GroupTodoEvent e) => OnGroupTodoEvent?.Invoke(context, e)); RegisterEvent((GroupMemberEnterEvent e) => OnGroupMemberEnterEvent?.Invoke(context, e)); RegisterEvent((PinChangedEvent e) => OnPinChangedEvent?.Invoke(context, e)); + RegisterEvent((GroupRecallPokeEvent e) => OnGroupRecallPokeEvent?.Invoke(context, e)); + RegisterEvent((FriendRecallPokeEvent e) => OnFriendRecallPokeEvent?.Invoke(context, e)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/Lagrange.Core/Internal/Context/Logic/Implementation/MessagingLogic.cs b/Lagrange.Core/Internal/Context/Logic/Implementation/MessagingLogic.cs index c1ee0d47b..34e0dedb9 100644 --- a/Lagrange.Core/Internal/Context/Logic/Implementation/MessagingLogic.cs +++ b/Lagrange.Core/Internal/Context/Logic/Implementation/MessagingLogic.cs @@ -48,6 +48,8 @@ namespace Lagrange.Core.Internal.Context.Logic.Implementation; [EventSubscribe(typeof(SysPinChangedEvent))] [EventSubscribe(typeof(FetchPinsEvent))] [EventSubscribe(typeof(SetPinFriendEvent))] +[EventSubscribe(typeof(GroupSysRecallPokeEvent))] +[EventSubscribe(typeof(FriendSysRecallPokeEvent))] [BusinessLogic("MessagingLogic", "Manage the receiving and sending of messages and notifications")] internal class MessagingLogic : LogicBase { @@ -160,7 +162,17 @@ public override async Task Incoming(ProtocolEvent e) } case GroupSysPokeEvent poke: { - var pokeArgs = new GroupPokeEvent(poke.GroupUin, poke.OperatorUin, poke.TargetUin, poke.Action, poke.Suffix, poke.ActionImgUrl); + var pokeArgs = new GroupPokeEvent( + poke.GroupUin, + poke.OperatorUin, + poke.TargetUin, + poke.Action, + poke.Suffix, + poke.ActionImgUrl, + poke.MessageSequence, + poke.MessageTime, + poke.TipsSeqId + ); Collection.Invoker.PostEvent(pokeArgs); break; } @@ -246,7 +258,17 @@ public override async Task Incoming(ProtocolEvent e) } case FriendSysPokeEvent poke: { - var pokeArgs = new FriendPokeEvent(poke.OperatorUin, poke.TargetUin, poke.Action, poke.Suffix, poke.ActionImgUrl); + var pokeArgs = new FriendPokeEvent( + poke.OperatorUin, + poke.TargetUin, + poke.Action, + poke.Suffix, + poke.ActionImgUrl, + poke.PeerUin, + poke.MessageSequence, + poke.MessageTime, + poke.TipsSeqId + ); Collection.Invoker.PostEvent(pokeArgs); break; } @@ -296,6 +318,21 @@ public override async Task Incoming(ProtocolEvent e) break; } + case GroupSysRecallPokeEvent recall: + { + uint operatorUin = await Collection.Business.CachingLogic.ResolveUin(null, recall.OperatorUid) ?? 0; + var @event = new GroupRecallPokeEvent(recall.GroupUin, operatorUin, recall.TipsSeqId); + Collection.Invoker.PostEvent(@event); + break; + } + case FriendSysRecallPokeEvent recall: + { + uint peerUin = await Collection.Business.CachingLogic.ResolveUin(null, recall.PeerUid) ?? 0; + uint operatorUin = await Collection.Business.CachingLogic.ResolveUin(null, recall.OperatorUid) ?? 0; + var @event = new FriendRecallPokeEvent(peerUin, operatorUin, recall.TipsSeqId); + Collection.Invoker.PostEvent(@event); + break; + } } } diff --git a/Lagrange.Core/Internal/Context/Logic/Implementation/OperationLogic.cs b/Lagrange.Core/Internal/Context/Logic/Implementation/OperationLogic.cs index d98b29cc3..c299c4783 100644 --- a/Lagrange.Core/Internal/Context/Logic/Implementation/OperationLogic.cs +++ b/Lagrange.Core/Internal/Context/Logic/Implementation/OperationLogic.cs @@ -933,4 +933,24 @@ public async Task UploadImage(ImageEntity image) var result = (MediaDownloadEvent)results[0]; return (result.ResultCode, result.Message, result.Url); } + + public async Task<(int Code, string Message)> GroupRecallPoke(ulong groupUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) + { + var @event = RecallPokeEvent.Create(isGroup: true, groupUin, messageSequence, messageTime, tipsSeqId); + var results = await Collection.Business.SendEvent(@event); + if (results.Count == 0) return (-1, "No Result"); + + var result = (RecallPokeEvent)results[0]; + return (result.ResultCode, result.Message); + } + + public async Task<(int Code, string Message)> FriendRecallPoke(ulong peerUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) + { + var @event = RecallPokeEvent.Create(isGroup: false, peerUin, messageSequence, messageTime, tipsSeqId); + var results = await Collection.Business.SendEvent(@event); + if (results.Count == 0) return (-1, "No Result"); + + var result = (RecallPokeEvent)results[0]; + return (result.ResultCode, result.Message); + } } \ No newline at end of file diff --git a/Lagrange.Core/Internal/Event/Message/RecallPokeEvent.cs b/Lagrange.Core/Internal/Event/Message/RecallPokeEvent.cs new file mode 100644 index 000000000..90ce77992 --- /dev/null +++ b/Lagrange.Core/Internal/Event/Message/RecallPokeEvent.cs @@ -0,0 +1,35 @@ + +namespace Lagrange.Core.Internal.Event.Message; + +internal class RecallPokeEvent : ProtocolEvent +{ + public bool IsGroup { get; init; } + public ulong Uin { get; init; } + public ulong MessageSequence { get; init; } + public ulong MessageTime { get; init; } + public ulong TipsSeqId { get; internal set; } + + public string Message { get; set; } + + private RecallPokeEvent(bool isGroup, ulong uin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) : base(true) + { + IsGroup = isGroup; + Uin = uin; + MessageSequence = messageSequence; + MessageTime = messageTime; + TipsSeqId = tipsSeqId; + + Message = null!; + } + + private RecallPokeEvent(int retcode, string message) : base(retcode) + { + Message = message; + } + + public static RecallPokeEvent Create(bool isGroup, ulong uin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) + => new(isGroup, uin, messageSequence, messageTime, tipsSeqId); + + public static RecallPokeEvent Result(int retcode, string message) + => new(retcode, message); +} \ No newline at end of file diff --git a/Lagrange.Core/Internal/Event/Notify/FriendSysPokeEvent.cs b/Lagrange.Core/Internal/Event/Notify/FriendSysPokeEvent.cs index bdd877588..7678b8bce 100644 --- a/Lagrange.Core/Internal/Event/Notify/FriendSysPokeEvent.cs +++ b/Lagrange.Core/Internal/Event/Notify/FriendSysPokeEvent.cs @@ -3,24 +3,36 @@ namespace Lagrange.Core.Internal.Event.Notify; internal class FriendSysPokeEvent : ProtocolEvent { public uint OperatorUin { get; } - + public uint TargetUin { get; } public string Action { get; } - + public string Suffix { get; } - + public string ActionImgUrl { get; } - - private FriendSysPokeEvent(uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl) : base(0) + + public ulong PeerUin { get; } + + public ulong MessageSequence { get; } + + public ulong MessageTime { get; } + + public ulong TipsSeqId { get; } + + private FriendSysPokeEvent(uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl, ulong peerUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) : base(0) { OperatorUin = operatorUin; TargetUin = targetUin; Action = action; Suffix = suffix; ActionImgUrl = actionImgUrl; + PeerUin = peerUin; + MessageSequence = messageSequence; + MessageTime = messageTime; + TipsSeqId = tipsSeqId; } - - public static FriendSysPokeEvent Result(uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl) - => new(operatorUin, targetUin, action, suffix, actionImgUrl); + + public static FriendSysPokeEvent Result(uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl, ulong peerUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) + => new(operatorUin, targetUin, action, suffix, actionImgUrl, peerUin, messageSequence, messageTime, tipsSeqId); } diff --git a/Lagrange.Core/Internal/Event/Notify/FriendSysRecallPokeEvent.cs b/Lagrange.Core/Internal/Event/Notify/FriendSysRecallPokeEvent.cs new file mode 100644 index 000000000..09e02b68b --- /dev/null +++ b/Lagrange.Core/Internal/Event/Notify/FriendSysRecallPokeEvent.cs @@ -0,0 +1,20 @@ +namespace Lagrange.Core.Internal.Event.Notify; + +internal class FriendSysRecallPokeEvent : ProtocolEvent +{ + public string PeerUid { get; } + + public string OperatorUid { get; } + + public ulong TipsSeqId { get; set; } + + private FriendSysRecallPokeEvent(string peerUid, string operatorUid, ulong tipsSeqId) : base(0) + { + PeerUid = peerUid; + OperatorUid = operatorUid; + TipsSeqId = tipsSeqId; + } + + public static FriendSysRecallPokeEvent Result(string peerUid, string operatorUid, ulong tipsSeqId) + => new(peerUid, operatorUid, tipsSeqId); +} diff --git a/Lagrange.Core/Internal/Event/Notify/GroupSysPokeEvent.cs b/Lagrange.Core/Internal/Event/Notify/GroupSysPokeEvent.cs index cb9f48a23..faffef259 100644 --- a/Lagrange.Core/Internal/Event/Notify/GroupSysPokeEvent.cs +++ b/Lagrange.Core/Internal/Event/Notify/GroupSysPokeEvent.cs @@ -3,18 +3,24 @@ namespace Lagrange.Core.Internal.Event.Notify; internal class GroupSysPokeEvent : ProtocolEvent { public uint GroupUin { get; } - + public uint OperatorUin { get; } - + public uint TargetUin { get; } public string Action { get; } - + public string Suffix { get; } - + public string ActionImgUrl { get; } - - private GroupSysPokeEvent(uint groupUin, uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl) : base(0) + + public ulong MessageSequence { get; set; } + + public ulong MessageTime { get; set; } + + public ulong TipsSeqId { get; set; } + + private GroupSysPokeEvent(uint groupUin, uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl, ulong messageSequence, ulong messageTime, ulong tipsSeqId) : base(0) { GroupUin = groupUin; OperatorUin = operatorUin; @@ -22,8 +28,11 @@ private GroupSysPokeEvent(uint groupUin, uint operatorUin, uint targetUin, strin Action = action; Suffix = suffix; ActionImgUrl = actionImgUrl; + MessageSequence = messageSequence; + MessageTime = messageTime; + TipsSeqId = tipsSeqId; } - - public static GroupSysPokeEvent Result(uint groupUin, uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl) - => new(groupUin, operatorUin, targetUin, action, suffix, actionImgUrl); + + public static GroupSysPokeEvent Result(uint groupUin, uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl, ulong messageSequence, ulong messageTime, ulong tipsSeqId) + => new(groupUin, operatorUin, targetUin, action, suffix, actionImgUrl, messageSequence, messageTime, tipsSeqId); } diff --git a/Lagrange.Core/Internal/Event/Notify/GroupSysRecallPokeEvent.cs b/Lagrange.Core/Internal/Event/Notify/GroupSysRecallPokeEvent.cs new file mode 100644 index 000000000..fe210696c --- /dev/null +++ b/Lagrange.Core/Internal/Event/Notify/GroupSysRecallPokeEvent.cs @@ -0,0 +1,20 @@ +namespace Lagrange.Core.Internal.Event.Notify; + +internal class GroupSysRecallPokeEvent : ProtocolEvent +{ + public uint GroupUin { get; } + + public string OperatorUid { get; } + + public ulong TipsSeqId { get; set; } + + private GroupSysRecallPokeEvent(uint groupUin, string operatorUid, ulong tipsSeqId) : base(0) + { + GroupUin = groupUin; + OperatorUid = operatorUid; + TipsSeqId = tipsSeqId; + } + + public static GroupSysRecallPokeEvent Result(uint groupUin, string operatorUid, ulong tipsSeqId) + => new(groupUin, operatorUid, tipsSeqId); +} diff --git a/Lagrange.Core/Internal/Packets/Message/Notify/GroupRecallPoke.cs b/Lagrange.Core/Internal/Packets/Message/Notify/GroupRecallPoke.cs new file mode 100644 index 000000000..27e109d97 --- /dev/null +++ b/Lagrange.Core/Internal/Packets/Message/Notify/GroupRecallPoke.cs @@ -0,0 +1,17 @@ +using ProtoBuf; + +namespace Lagrange.Core.Internal.Packets.Message.Notify; + +#pragma warning disable CS8618 + +[ProtoContract] +public class GroupRecallPoke +{ + [ProtoMember(1)] public string OperatorUid { get; set; } + + [ProtoMember(3)] public uint GroupUin { get; set; } + + [ProtoMember(4)] public ulong BusiId { get; set; } + + [ProtoMember(5)] public ulong TipsSeqId { get; set; } +} diff --git a/Lagrange.Core/Internal/Packets/Message/Notify/NotifyMessageBody.cs b/Lagrange.Core/Internal/Packets/Message/Notify/NotifyMessageBody.cs index 067abbd88..05f3848f7 100644 --- a/Lagrange.Core/Internal/Packets/Message/Notify/NotifyMessageBody.cs +++ b/Lagrange.Core/Internal/Packets/Message/Notify/NotifyMessageBody.cs @@ -11,52 +11,80 @@ namespace Lagrange.Core.Internal.Packets.Message.Notify; internal class NotifyMessageBody { [ProtoMember(1)] public uint Type { get; set; } - + [ProtoMember(4)] public uint GroupUin { get; set; } - + [ProtoMember(5)] public byte[]? EventParam { get; set; } - + [ProtoMember(11)] public GroupRecall Recall { get; set; } - + [ProtoMember(13)] public uint? Field13 { get; set; } - + [ProtoMember(21)] public string OperatorUid { get; set; } - + [ProtoMember(26)] public GeneralGrayTipInfo GeneralGrayTip { get; set; } [ProtoMember(33)] public EssenceMessage EssenceMessage; - + [ProtoMember(37)] public uint MsgSequence { get; set; } - + [ProtoMember(39)] public uint Field39 { get; set; } - + + [ProtoMember(40)] public GroupRecallPoke GroupRecallPoke { get; set; } + [ProtoMember(44)] public GroupReactionData0 Reaction { get; set; } + + [ProtoMember(50)] public ulong TipsSeqId { get; set; } } [ProtoContract] internal class GeneralGrayTipInfo { [ProtoMember(1)] public ulong BusiType { get; set; } - + [ProtoMember(2)] public ulong BusiId { get; set; } - + [ProtoMember(3)] public uint CtrlFlag { get; set; } - + [ProtoMember(4)] public uint C2CType { get; set; } - + [ProtoMember(5)] public uint ServiceType { get; set; } - + [ProtoMember(6)] public ulong TemplId { get; set; } - + [ProtoMember(7)] public TemplParam[] MsgTemplParam { get; set; } - + [ProtoMember(8)] public string Content { get; set; } + + [ProtoMember(10)] public ulong TipsSeqId { get; set; } + + [ProtoMember(100)] public GrayTipMsgInfo MsgInfo { get; set; } +} + +[ProtoContract] +internal class GrayTipMsgInfo +{ + [ProtoMember(6)] public ulong Sequence { get; set; } } [ProtoContract] internal class TemplParam { [ProtoMember(1)] public string Name { get; set; } - + [ProtoMember(2)] public string Value { get; set; } +} + +[ProtoContract] +internal class FriendRecallPokeInfo +{ + [ProtoMember(1)] public string SelfUid { get; set; } + + [ProtoMember(2)] public string PeerUid { get; set; } + + [ProtoMember(3)] public string OperatorUid { get; set; } + + [ProtoMember(4)] public ulong BusiId { get; set; } + + [ProtoMember(5)] public ulong TipsSeqId { get; set; } } \ No newline at end of file diff --git a/Lagrange.Core/Internal/Packets/Service/Oidb/Request/OidbSvcTrpcTcp0xF51_1.cs b/Lagrange.Core/Internal/Packets/Service/Oidb/Request/OidbSvcTrpcTcp0xF51_1.cs new file mode 100644 index 000000000..0d53898d0 --- /dev/null +++ b/Lagrange.Core/Internal/Packets/Service/Oidb/Request/OidbSvcTrpcTcp0xF51_1.cs @@ -0,0 +1,70 @@ +using ProtoBuf; + +namespace Lagrange.Core.Internal.Service.Message; + +#pragma warning disable CS8618 + +[ProtoContract] +internal class OidbSvcTrpcTcp0xF51_1 +{ + [ProtoMember(1)] + public OidbSvcTrpcTcp0xF51_1C2CMsgInfo? C2CMsgInfo { get; set; } + + [ProtoMember(2)] + public OidbSvcTrpcTcp0xF51_1GroupMsgInfo? GroupMsgInfo { get; set; } + + [ProtoMember(3)] + public OidbSvcTrpcTcp0xF51_1CommGrayTipsInfo CommGrayTipsInfo { get; set; } +} + + +[ProtoContract] +internal class OidbSvcTrpcTcp0xF51_1C2CMsgInfo +{ + [ProtoMember(1)] + public ulong AioUin { get; set; } + + [ProtoMember(2)] + public ulong MsgType { get; set; } + + [ProtoMember(3)] + public ulong MsgSeq { get; set; } + + [ProtoMember(4)] + public ulong MsgTime { get; set; } + + [ProtoMember(5)] + public ulong MsgUid { get; set; } +} + +[ProtoContract] +internal class OidbSvcTrpcTcp0xF51_1GroupMsgInfo +{ + [ProtoMember(1)] + public ulong GroupCode { get; set; } + + [ProtoMember(2)] + public ulong MsgType { get; set; } + + [ProtoMember(3)] + public ulong MsgSeq { get; set; } + + [ProtoMember(4)] + public ulong MsgTime { get; set; } + + [ProtoMember(5)] + public ulong MsgUid { get; set; } + + [ProtoMember(6)] + public ulong MsgId { get; set; } +} + +[ProtoContract] +internal class OidbSvcTrpcTcp0xF51_1CommGrayTipsInfo +{ + [ProtoMember(1)] + public ulong BusiId { get; set; } + + [ProtoMember(2)] + public ulong TipsSeqId { get; set; } +} \ No newline at end of file diff --git a/Lagrange.Core/Internal/Service/Message/PushMessageService.cs b/Lagrange.Core/Internal/Service/Message/PushMessageService.cs index 0c28affda..e936069d2 100644 --- a/Lagrange.Core/Internal/Service/Message/PushMessageService.cs +++ b/Lagrange.Core/Internal/Service/Message/PushMessageService.cs @@ -207,20 +207,37 @@ private static void ProcessEvent0x2DC(Span payload, PushMsg msg, List(proto.AsSpan()); - var essenceMsg = essence.EssenceMessage; - var groupEssenceEvent = GroupSysEssenceEvent.Result(essenceMsg.GroupUin, essenceMsg.MsgSequence, - essenceMsg.Random, essenceMsg.SetFlag, essenceMsg.MemberUin, essenceMsg.OperatorUin); - extraEvents.Add(groupEssenceEvent); + var greytip = Serializer.Deserialize(proto.AsSpan()); + + if (greytip.Type == 27) // essence + { + var essenceMsg = greytip.EssenceMessage; + var groupEssenceEvent = GroupSysEssenceEvent.Result(essenceMsg.GroupUin, essenceMsg.MsgSequence, + essenceMsg.Random, essenceMsg.SetFlag, essenceMsg.MemberUin, essenceMsg.OperatorUin); + extraEvents.Add(groupEssenceEvent); + break; + } + + if (greytip.Type == 32) // recall poke + { + var recallPoke = greytip.GroupRecallPoke; + var @event = GroupSysRecallPokeEvent.Result( + recallPoke.GroupUin, + recallPoke.OperatorUid, + recallPoke.TipsSeqId + ); + extraEvents.Add(@event); + } + break; } - case Event0x2DCSubType.GroupGreyTipNotice when msg.Message.Body?.MsgContent is { } content: + case Event0x2DCSubType.GroupGreyTipNotice20 when msg.Message.Body?.MsgContent is { } content: { using var packet = new BinaryPacket(content); uint groupUin = packet.ReadUint(); // group uin @@ -237,7 +254,17 @@ private static void ProcessEvent0x2DC(Span payload, PushMsg msg, List payload, PushMsg msg, List(content.AsSpan()); + extraEvents.Add(FriendSysRecallPokeEvent.Result(recall.PeerUid, recall.OperatorUid, recall.TipsSeqId)); break; } default: @@ -366,8 +404,8 @@ private enum Event0x2DCSubType GroupMuteNotice = 12, SubType16 = 16, GroupRecallNotice = 17, - GroupEssenceNotice = 21, - GroupGreyTipNotice = 20, + GroupGreyTipNotice21 = 21, + GroupGreyTipNotice20 = 20, } private enum Event0x2DCSubType16Field13 diff --git a/Lagrange.Core/Internal/Service/Message/RecallPokeService.cs b/Lagrange.Core/Internal/Service/Message/RecallPokeService.cs new file mode 100644 index 000000000..756df639c --- /dev/null +++ b/Lagrange.Core/Internal/Service/Message/RecallPokeService.cs @@ -0,0 +1,64 @@ +using Lagrange.Core.Common; +using Lagrange.Core.Internal.Event; +using Lagrange.Core.Internal.Event.Message; +using Lagrange.Core.Internal.Packets.Service.Oidb; +using Lagrange.Core.Utility.Extension; +using ProtoBuf; + +namespace Lagrange.Core.Internal.Service.Message; + +[EventSubscribe(typeof(RecallPokeEvent))] +[Service("OidbSvcTrpcTcp.0xf51_1")] +internal class RecallPokeService : BaseService +{ + protected override bool Build(RecallPokeEvent input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, out Span output, out List>? extraPackets) + { + // I didn't find out how to get it, but a random number is feasible + long random = !input.IsGroup + ? Random.Shared.NextInt64(7500000000000000000, 7509999999999999999) + : Random.Shared.NextInt64(7580000000000000000, 7580099999999999999); + + + var packet = new OidbSvcTrpcTcpBase( + new OidbSvcTrpcTcp0xF51_1 + { + C2CMsgInfo = !input.IsGroup ? new OidbSvcTrpcTcp0xF51_1C2CMsgInfo + { + AioUin = input.Uin, + MsgType = 5, + MsgSeq = input.MessageSequence, + MsgTime = input.MessageTime, + MsgUid = (ulong)random, + } : null, + GroupMsgInfo = input.IsGroup ? new OidbSvcTrpcTcp0xF51_1GroupMsgInfo + { + GroupCode = input.Uin, + MsgType = 5, + MsgSeq = input.MessageSequence, + MsgTime = input.MessageTime, + MsgUid = (ulong)random, + MsgId = (ulong)random, + } : null, + CommGrayTipsInfo = new OidbSvcTrpcTcp0xF51_1CommGrayTipsInfo + { + BusiId = 1061, + TipsSeqId = input.TipsSeqId, + } + }, + 0xf51, 1 + ); + + output = packet.Serialize(); + extraPackets = null; + + return true; + } + + protected override bool Parse(Span input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, out RecallPokeEvent output, out List? extraEvents) + { + var payload = Serializer.Deserialize>(input); + output = RecallPokeEvent.Result((int)payload.ErrorCode, payload.ErrorMsg); + extraEvents = null; + return true; + } +} diff --git a/Lagrange.Core/Utility/Extension/ByteExtension.cs b/Lagrange.Core/Utility/Extension/ByteExtension.cs index 13e699530..a1e29331e 100644 --- a/Lagrange.Core/Utility/Extension/ByteExtension.cs +++ b/Lagrange.Core/Utility/Extension/ByteExtension.cs @@ -63,7 +63,7 @@ public static string Md5(this byte[] bytes, bool lower = false) { return MD5.HashData(bytes).Hex(lower); } - + public static async Task Md5Async(this byte[] bytes, bool lower = false) { using var md5 = MD5.Create(); @@ -76,8 +76,8 @@ public static async Task Md5Async(this byte[] bytes, bool lower = false) [MethodImpl(MethodImplOptions.AggressiveInlining)] private static uint ToCharsBuffer(byte value, uint casing = 0) { - uint difference = BitConverter.IsLittleEndian - ? ((uint)value >> 4) + ((value & 0x0Fu) << 16) - 0x890089u + uint difference = BitConverter.IsLittleEndian + ? ((uint)value >> 4) + ((value & 0x0Fu) << 16) - 0x890089u : ((value & 0xF0u) << 12) + (value & 0x0Fu) - 0x890089u; uint packedResult = ((((uint)-(int)difference & 0x700070u) >> 4) + difference + 0xB900B9u) | casing; return packedResult; diff --git a/Lagrange.Core/Utility/Generator/StringGen.cs b/Lagrange.Core/Utility/Generator/StringGen.cs index bed0d5bd9..25237bf61 100644 --- a/Lagrange.Core/Utility/Generator/StringGen.cs +++ b/Lagrange.Core/Utility/Generator/StringGen.cs @@ -9,16 +9,16 @@ internal static class StringGen public static string GenerateTrace() { var sb = new StringBuilder(55); - + sb.Append(0.ToString("X2")); // 2 chars sb.Append('-'); // 1 char - + for (var i = 0; i < 32; i++) sb.Append(Hex[Random.Shared.Next(0, Hex.Length)]); // 32 chars sb.Append('-'); // 1 char - + for (var i = 0; i < 16; i++) sb.Append(Hex[Random.Shared.Next(0, Hex.Length)]); // 16 chars sb.Append('-'); // 1 char - + sb.Append(01.ToString("X2")); // 2 chars return sb.ToString(); diff --git a/Lagrange.Core/Utility/Network/Http.cs b/Lagrange.Core/Utility/Network/Http.cs index b720e21fd..a35bd731d 100644 --- a/Lagrange.Core/Utility/Network/Http.cs +++ b/Lagrange.Core/Utility/Network/Http.cs @@ -6,18 +6,18 @@ namespace Lagrange.Core.Utility.Network; internal static class Http { private static readonly HttpClient Client = new(); - + public static async Task GetAsync(string url, Dictionary? param = null) { var uriBuilder = new UriBuilder(url); - + var query = HttpUtility.ParseQueryString(uriBuilder.Query); if (param != null) { foreach (var (key, value) in param) query[key] = value; - } + } uriBuilder.Query = query.ToString(); - + var response = await Client.GetAsync(uriBuilder.Uri); return await response.Content.ReadAsStringAsync(); } @@ -34,7 +34,7 @@ public static async Task PostAsync(string url, Dictionary PostAsync(string url, byte[] payload, string content) { var contentData = new ByteArrayContent(payload);