Skip to content

Commit

Permalink
[All] GroupRecallEvent add tip (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkRRb authored Aug 29, 2024
1 parent 50a5653 commit 8bbcc19
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 28 deletions.
19 changes: 11 additions & 8 deletions Lagrange.Core/Event/EventArg/GroupRecallEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@ namespace Lagrange.Core.Event.EventArg;
public class GroupRecallEvent : EventBase
{
public uint GroupUin { get; }

public uint AuthorUin { get; }

public uint OperatorUin { get; }

public uint Sequence { get; }

public uint Time { get; }

public uint Random { get; }

public GroupRecallEvent(uint groupUin, uint authorUin, uint operatorUin, uint sequence, uint time, uint random)
public string Tip { get; }

public GroupRecallEvent(uint groupUin, uint authorUin, uint operatorUin, uint sequence, uint time, uint random, string tip)
{
GroupUin = groupUin;
AuthorUin = authorUin;
OperatorUin = operatorUin;
Sequence = sequence;
Time = time;
Random = random;

EventMessage = $"{nameof(GroupRecallEvent)}: {GroupUin} | {AuthorUin} | {OperatorUin} | ({Sequence} | {Time} | {Random})";
Tip = tip;

EventMessage = $"{nameof(GroupRecallEvent)}: {GroupUin} | {AuthorUin} | {OperatorUin} | ({Sequence} | {Time} | {Random} | {Tip})";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public override async Task Incoming(ProtocolEvent e)
uint authorUin = await Collection.Business.CachingLogic.ResolveUin(recall.GroupUin, recall.AuthorUid) ?? 0;
uint operatorUin = 0;
if (recall.OperatorUid != null) operatorUin = await Collection.Business.CachingLogic.ResolveUin(recall.GroupUin, recall.OperatorUid) ?? 0;
var recallArgs = new GroupRecallEvent(recall.GroupUin, authorUin, operatorUin, recall.Sequence, recall.Time, recall.Random);
var recallArgs = new GroupRecallEvent(recall.GroupUin, authorUin, operatorUin, recall.Sequence, recall.Time, recall.Random, recall.Tip);
Collection.Invoker.PostEvent(recallArgs);
break;
}
Expand Down
19 changes: 11 additions & 8 deletions Lagrange.Core/Internal/Event/Notify/GroupSysRecallEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,30 @@ namespace Lagrange.Core.Internal.Event.Notify;
internal class GroupSysRecallEvent : ProtocolEvent
{
public uint GroupUin { get; }

public string AuthorUid { get; }

public string? OperatorUid { get; }

public uint Sequence { get; }

public uint Time { get; }

public uint Random { get; }

private GroupSysRecallEvent(uint groupUin, string authorUid, string? operatorUid, uint sequence, uint time, uint random) : base(0)
public string Tip { get; }

private GroupSysRecallEvent(uint groupUin, string authorUid, string? operatorUid, uint sequence, uint time, uint random, string tip) : base(0)
{
GroupUin = groupUin;
AuthorUid = authorUid;
OperatorUid = operatorUid;
Sequence = sequence;
Time = time;
Random = random;
Tip = tip;
}

public static GroupSysRecallEvent Result(uint groupUin, string authorUid, string? operatorUid, uint sequence, uint time, uint random)
=> new(groupUin, authorUid, operatorUid, sequence, time, random);
public static GroupSysRecallEvent Result(uint groupUin, string authorUid, string? operatorUid, uint sequence, uint time, uint random, string tip)
=> new(groupUin, authorUid, operatorUid, sequence, time, random, tip);
}
24 changes: 16 additions & 8 deletions Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,36 @@ namespace Lagrange.Core.Internal.Packets.Message.Notify;
internal class GroupRecall
{
[ProtoMember(1)] public string? OperatorUid { get; set; }

[ProtoMember(3)] public List<RecallMessage> RecallMessages { get; set; }

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

[ProtoMember(6)] public int GroupType { get; set; }

[ProtoMember(7)] public int OpType { get; set; }

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

[ProtoContract]
internal class RecallMessage
{
[ProtoMember(1)] public uint Sequence { get; set; }

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

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

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

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

[ProtoMember(6)] public string AuthorUid { get; set; }
}

[ProtoContract]

Check failure on line 39 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build

Duplicate 'ProtoContract' attribute

Check failure on line 39 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build

Duplicate 'ProtoContract' attribute

Check failure on line 39 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (linux-x64)

Duplicate 'ProtoContract' attribute

Check failure on line 39 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm)

Duplicate 'ProtoContract' attribute

Check failure on line 39 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm64)

Duplicate 'ProtoContract' attribute

Check failure on line 39 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (osx-x64)

Duplicate 'ProtoContract' attribute

Check failure on line 39 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (osx-arm64)

Duplicate 'ProtoContract' attribute

Check failure on line 39 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (linux-musl-x64)

Duplicate 'ProtoContract' attribute

Check failure on line 39 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (linux-musl-arm)

Duplicate 'ProtoContract' attribute

Check failure on line 39 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (linux-musl-arm64)

Duplicate 'ProtoContract' attribute
internal class TipInfo

Check failure on line 40 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build

The namespace 'Lagrange.Core.Internal.Packets.Message.Notify' already contains a definition for 'TipInfo'

Check failure on line 40 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build

The namespace 'Lagrange.Core.Internal.Packets.Message.Notify' already contains a definition for 'TipInfo'

Check failure on line 40 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (linux-x64)

The namespace 'Lagrange.Core.Internal.Packets.Message.Notify' already contains a definition for 'TipInfo'

Check failure on line 40 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm)

The namespace 'Lagrange.Core.Internal.Packets.Message.Notify' already contains a definition for 'TipInfo'

Check failure on line 40 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm64)

The namespace 'Lagrange.Core.Internal.Packets.Message.Notify' already contains a definition for 'TipInfo'

Check failure on line 40 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (osx-x64)

The namespace 'Lagrange.Core.Internal.Packets.Message.Notify' already contains a definition for 'TipInfo'

Check failure on line 40 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (osx-arm64)

The namespace 'Lagrange.Core.Internal.Packets.Message.Notify' already contains a definition for 'TipInfo'

Check failure on line 40 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (linux-musl-x64)

The namespace 'Lagrange.Core.Internal.Packets.Message.Notify' already contains a definition for 'TipInfo'

Check failure on line 40 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (linux-musl-arm)

The namespace 'Lagrange.Core.Internal.Packets.Message.Notify' already contains a definition for 'TipInfo'

Check failure on line 40 in Lagrange.Core/Internal/Packets/Message/Notify/GroupRecall.cs

View workflow job for this annotation

GitHub Actions / build (linux-musl-arm64)

The namespace 'Lagrange.Core.Internal.Packets.Message.Notify' already contains a definition for 'TipInfo'
{
[ProtoMember(2)] public string Tip { get; set; }
}
12 changes: 10 additions & 2 deletions Lagrange.Core/Internal/Service/Message/PushMessageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,15 @@ private static void ProcessEvent0x2DC(Span<byte> payload, PushMsg msg, List<Prot
var proto = packet.ReadBytes(Prefix.Uint16 | Prefix.LengthOnly);
var recall = Serializer.Deserialize<NotifyMessageBody>(proto);
var meta = recall.Recall.RecallMessages[0];
var groupRecallEvent = GroupSysRecallEvent.Result(recall.GroupUin, meta.AuthorUid, recall.Recall.OperatorUid, meta.Sequence, meta.Time, meta.Random);
var groupRecallEvent = GroupSysRecallEvent.Result(
recall.GroupUin,
meta.AuthorUid,
recall.Recall.OperatorUid,
meta.Sequence,
meta.Time,
meta.Random,
recall?.Recall.TipInfo?.Tip ?? ""
);
extraEvents.Add(groupRecallEvent);
break;
}
Expand Down Expand Up @@ -204,7 +212,7 @@ private static void ProcessEvent0x2DC(Span<byte> payload, PushMsg msg, List<Prot
actionStr = string.Empty;
}
}

if (greyTip.GeneralGrayTip.BusiType == 12) // poke
{
var groupPokeEvent = GroupSysPokeEvent.Result(groupUin, uint.Parse(templates["uin_str1"]), uint.Parse(templates["uin_str2"]), actionStr, templates["suffix_str"], templates["action_img_url"]);
Expand Down
2 changes: 2 additions & 0 deletions Lagrange.OneBot/Core/Entity/Notify/OneBotGroupRecall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ public class OneBotGroupRecall(uint selfId) : OneBotNotify(selfId, "group_recall
[JsonPropertyName("message_id")] public int MessageId { get; set; }

[JsonPropertyName("operator_id")] public uint OperatorId { get; set; }

[JsonPropertyName("tip")] public string Tip { get; set; } = string.Empty;
}
3 changes: 2 additions & 1 deletion Lagrange.OneBot/Core/Notify/NotifyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ await service.SendJsonAsync(new OneBotGroupRecall(bot.BotUin)
GroupId = @event.GroupUin,
UserId = @event.AuthorUin,
MessageId = MessageRecord.CalcMessageHash(@event.Random, @event.Sequence),
OperatorId = @event.OperatorUin
OperatorId = @event.OperatorUin,
Tip = @event.Tip
});
};

Expand Down

0 comments on commit 8bbcc19

Please sign in to comment.