Skip to content

Commit

Permalink
[All] FriendRecallEvent add tip (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkRRb authored Aug 29, 2024
1 parent ef62e57 commit 50a5653
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 23 deletions.
9 changes: 6 additions & 3 deletions Lagrange.Core/Event/EventArg/FriendRecallEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ public class FriendRecallEvent : EventBase

public uint Random { get; }

public FriendRecallEvent(uint friendUin, uint sequence, uint time, uint random)
public string Tip { get; }

public FriendRecallEvent(uint friendUin, uint sequence, uint time, uint random, string tip)
{
FriendUin = friendUin;
Sequence = sequence;
Time = time;
Random = random;

EventMessage = $"{nameof(FriendRecallEvent)}: {FriendUin} | ({Sequence} | {Time} | {Random})";
Tip = tip;

EventMessage = $"{nameof(FriendRecallEvent)}: {FriendUin} | ({Sequence} | {Time} | {Random} | {Tip})";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public override async Task Incoming(ProtocolEvent e)
case FriendSysRecallEvent recall:
{
uint fromUin = await Collection.Business.CachingLogic.ResolveUin(null, recall.FromUid) ?? 0;
var recallArgs = new FriendRecallEvent(fromUin, recall.Sequence, recall.Time, recall.Random);
var recallArgs = new FriendRecallEvent(fromUin, recall.Sequence, recall.Time, recall.Random, recall.Tip);
Collection.Invoker.PostEvent(recallArgs);
break;
}
Expand Down
17 changes: 10 additions & 7 deletions Lagrange.Core/Internal/Event/Notify/FriendSysRecallEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@ namespace Lagrange.Core.Internal.Event.Notify;
internal class FriendSysRecallEvent : ProtocolEvent
{
public string FromUid { get; }

public uint Sequence { get; }

public uint Time { get; }

public uint Random { get; }

private FriendSysRecallEvent(string fromUid, uint sequence, uint time, uint random) : base(0)

public string Tip { get; }

private FriendSysRecallEvent(string fromUid, uint sequence, uint time, uint random, string tip) : base(0)
{
FromUid = fromUid;
Sequence = sequence;
Time = time;
Random = random;
Tip = tip;
}

public static FriendSysRecallEvent Result(string fromUid, uint sequence, uint time, uint random)
=> new(fromUid, sequence, time, random);
public static FriendSysRecallEvent Result(string fromUid, uint sequence, uint time, uint random, string tip)
=> new(fromUid, sequence, time, random, tip);
}
30 changes: 19 additions & 11 deletions Lagrange.Core/Internal/Packets/Message/Notify/FriendRecall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,42 @@ namespace Lagrange.Core.Internal.Packets.Message.Notify;
internal class FriendRecall
{
[ProtoMember(1)] public FriendRecallInfo Info { get; set; }

[ProtoMember(2)] public uint InstId { get; set; }

[ProtoMember(3)] public uint AppId { get; set; }

[ProtoMember(4)] public uint LongMessageFlag { get; set; }

[ProtoMember(5)] public byte[] Reserved { get; set; }
}

[ProtoContract]
internal class FriendRecallInfo
{
[ProtoMember(1)] public string FromUid { get; set; }

[ProtoMember(2)] public string ToUid { get; set; }

[ProtoMember(3)] public uint Sequence { get; set; }

[ProtoMember(4)] public ulong NewId { get; set; }

[ProtoMember(5)] public uint Time { get; set; }

[ProtoMember(6)] public uint Random { get; set; }

[ProtoMember(7)] public uint PkgNum { get; set; }

[ProtoMember(8)] public uint PkgIndex { get; set; }

[ProtoMember(9)] public uint DivSeq { get; set; }

[ProtoMember(13)] public TipInfo TipInfo { get; set; }
}

[ProtoContract]
internal class TipInfo
{
[ProtoMember(2)] public string? Tip { get; set; }
}
8 changes: 7 additions & 1 deletion Lagrange.Core/Internal/Service/Message/PushMessageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,13 @@ private static void ProcessEvent0x210(Span<byte> payload, PushMsg msg, List<Prot
case Event0x210SubType.FriendRecallNotice when msg.Message.Body?.MsgContent is { } content:
{
var recall = Serializer.Deserialize<FriendRecall>(content.AsSpan());
var recallEvent = FriendSysRecallEvent.Result(recall.Info.FromUid, recall.Info.Sequence, recall.Info.Time, recall.Info.Random);
var recallEvent = FriendSysRecallEvent.Result(
recall.Info.FromUid,
recall.Info.Sequence,
recall.Info.Time,
recall.Info.Random,
recall.Info.TipInfo.Tip ?? ""
);
extraEvents.Add(recallEvent);
break;
}
Expand Down
2 changes: 2 additions & 0 deletions Lagrange.OneBot/Core/Entity/Notify/OneBotFriendRecall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ public class OneBotFriendRecall(uint selfId) : OneBotNotify(selfId, "friend_reca
[JsonPropertyName("user_id")] public uint UserId { get; set; }

[JsonPropertyName("message_id")] public int MessageId { get; set; }

[JsonPropertyName("tip")] public string Tip { get; set; } = string.Empty;
}
1 change: 1 addition & 0 deletions Lagrange.OneBot/Core/Notify/NotifyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ await service.SendJsonAsync(new OneBotFriendRecall(bot.BotUin)
{
UserId = @event.FriendUin,
MessageId = MessageRecord.CalcMessageHash(@event.Random, @event.Sequence),
Tip = @event.Tip
});
};

Expand Down

0 comments on commit 50a5653

Please sign in to comment.