Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.

Commit 0ce26ce

Browse files
committed
[Core] Implemented the recall poke
Co-authored-by: Decrabbityyy <99632363+Decrabbityyy@users.noreply.github.com> with co
1 parent 1fa68d1 commit 0ce26ce

File tree

21 files changed

+512
-73
lines changed

21 files changed

+512
-73
lines changed

Lagrange.Core/Common/Interface/Api/OperationExt.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,4 +313,11 @@ public static Task<string> FetchPrivateFSDownload(this BotContext bot, string fi
313313

314314
public static Task<bool> SendPoke(this BotContext bot, bool isGroup, uint peerUin, uint? targetUin = null)
315315
=> bot.ContextCollection.Business.OperationLogic.SendPoke(isGroup, peerUin, targetUin);
316+
317+
public static Task<(int Code, string Message)> GroupRecallPoke(this BotContext bot, ulong groupUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId)
318+
=> bot.ContextCollection.Business.OperationLogic.GroupRecallPoke(groupUin, messageSequence, messageTime, tipsSeqId);
319+
320+
public static Task<(int Code, string Message)> FriendRecallPoke(this BotContext bot, ulong groupUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId)
321+
=> bot.ContextCollection.Business.OperationLogic.FriendRecallPoke(groupUin, messageSequence, messageTime, tipsSeqId);
322+
316323
}

Lagrange.Core/Event/EventArg/FriendPokeEvent.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,35 @@ namespace Lagrange.Core.Event.EventArg;
33
public class FriendPokeEvent : EventBase
44
{
55
public uint OperatorUin { get; }
6-
6+
77
public uint TargetUin { get; }
8-
8+
99
public string Action { get; }
10-
10+
1111
public string Suffix { get; }
1212

1313
public string ActionImgUrl { get; }
14-
15-
public FriendPokeEvent(uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl)
16-
{
14+
15+
public ulong PeerUin { get; }
16+
17+
public ulong MessageSequence { get; }
18+
19+
public ulong MessageTime { get; }
20+
21+
public ulong TipsSeqId { get; }
22+
23+
public FriendPokeEvent(uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl, ulong peerUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId)
24+
{
1725
OperatorUin = operatorUin;
1826
TargetUin = targetUin;
1927
Action = action;
2028
Suffix = suffix;
2129
ActionImgUrl = actionImgUrl;
22-
30+
PeerUin = peerUin;
31+
MessageSequence = messageSequence;
32+
MessageTime = messageTime;
33+
TipsSeqId = tipsSeqId;
34+
2335
EventMessage = $"{nameof(FriendPokeEvent)}: OperatorUin: {OperatorUin} | TargetUin: {TargetUin} | Action: {Action} | Suffix: {Suffix} | ActionImgUrl: {ActionImgUrl}";
2436
}
2537
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace Lagrange.Core.Event.EventArg;
2+
3+
public class FriendRecallPokeEvent : EventBase
4+
{
5+
public uint PeerUin { get; }
6+
7+
public uint OperatorUin { get; }
8+
9+
public ulong TipsSeqId { get; set; }
10+
11+
public FriendRecallPokeEvent(uint groupUin, uint operatorUin, ulong tipsSeqId)
12+
{
13+
PeerUin = groupUin;
14+
OperatorUin = operatorUin;
15+
TipsSeqId = tipsSeqId;
16+
17+
EventMessage = $"[FriendRecallPoke] Peer: {PeerUin} | Operator: {OperatorUin} | TipsSeqId: {TipsSeqId}";
18+
}
19+
}

Lagrange.Core/Event/EventArg/GroupPokeEvent.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,35 @@ namespace Lagrange.Core.Event.EventArg;
33
public class GroupPokeEvent : EventBase
44
{
55
public uint GroupUin { get; }
6-
6+
77
public uint OperatorUin { get; }
8-
8+
99
public uint TargetUin { get; }
10-
10+
1111
public string Action { get; }
12-
12+
1313
public string Suffix { get; }
14-
14+
1515
public string ActionImgUrl { get; }
16-
17-
public GroupPokeEvent(uint groupUin, uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl)
16+
17+
public ulong MessageSequence { get; }
18+
19+
public ulong MessageTime { get; }
20+
21+
public ulong TipsSeqId { get; }
22+
23+
public GroupPokeEvent(uint groupUin, uint operatorUin, uint targetUin, string action, string suffix, string actionImgUrl, ulong messageSequence, ulong messageTime, ulong tipsSeqId)
1824
{
1925
GroupUin = groupUin;
2026
OperatorUin = operatorUin;
2127
TargetUin = targetUin;
2228
Action = action;
2329
Suffix = suffix;
2430
ActionImgUrl = actionImgUrl;
25-
31+
MessageSequence = messageSequence;
32+
MessageTime = messageTime;
33+
TipsSeqId = tipsSeqId;
34+
2635
EventMessage = $"{nameof(GroupPokeEvent)}: GroupUin: {GroupUin} | OperatorUin: {OperatorUin} | TargetUin: {TargetUin} | Action: {Action} | Suffix: {Suffix} | ActionImgUrl: {ActionImgUrl}";
2736
}
2837
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace Lagrange.Core.Event.EventArg;
2+
3+
public class GroupRecallPokeEvent : EventBase
4+
{
5+
public uint GroupUin { get; }
6+
7+
public uint OperatorUin { get; }
8+
9+
public ulong TipsSeqId { get; set; }
10+
11+
public GroupRecallPokeEvent(uint groupUin, uint operatorUin, ulong tipsSeqId)
12+
{
13+
GroupUin = groupUin;
14+
OperatorUin = operatorUin;
15+
TipsSeqId = tipsSeqId;
16+
17+
EventMessage = $"[GroupRecallPoke] Group: {GroupUin} | Operator: {OperatorUin} | TipsSeqId: {TipsSeqId}";
18+
}
19+
}

Lagrange.Core/Event/EventInvoker.Events.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,8 @@ public partial class EventInvoker
5959
public event LagrangeEvent<GroupMemberEnterEvent>? OnGroupMemberEnterEvent;
6060

6161
public event LagrangeEvent<PinChangedEvent>? OnPinChangedEvent;
62+
63+
public event LagrangeEvent<GroupRecallPokeEvent>? OnGroupRecallPokeEvent;
64+
65+
public event LagrangeEvent<FriendRecallPokeEvent>? OnFriendRecallPokeEvent;
6266
}

Lagrange.Core/Event/EventInvoker.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ internal EventInvoker(BotContext context)
4343
RegisterEvent((GroupTodoEvent e) => OnGroupTodoEvent?.Invoke(context, e));
4444
RegisterEvent((GroupMemberEnterEvent e) => OnGroupMemberEnterEvent?.Invoke(context, e));
4545
RegisterEvent((PinChangedEvent e) => OnPinChangedEvent?.Invoke(context, e));
46+
RegisterEvent((GroupRecallPokeEvent e) => OnGroupRecallPokeEvent?.Invoke(context, e));
47+
RegisterEvent((FriendRecallPokeEvent e) => OnFriendRecallPokeEvent?.Invoke(context, e));
4648
}
4749

4850
[MethodImpl(MethodImplOptions.AggressiveInlining)]

Lagrange.Core/Internal/Context/Logic/Implementation/MessagingLogic.cs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ namespace Lagrange.Core.Internal.Context.Logic.Implementation;
4848
[EventSubscribe(typeof(SysPinChangedEvent))]
4949
[EventSubscribe(typeof(FetchPinsEvent))]
5050
[EventSubscribe(typeof(SetPinFriendEvent))]
51+
[EventSubscribe(typeof(GroupSysRecallPokeEvent))]
52+
[EventSubscribe(typeof(FriendSysRecallPokeEvent))]
5153
[BusinessLogic("MessagingLogic", "Manage the receiving and sending of messages and notifications")]
5254
internal class MessagingLogic : LogicBase
5355
{
@@ -160,7 +162,17 @@ public override async Task Incoming(ProtocolEvent e)
160162
}
161163
case GroupSysPokeEvent poke:
162164
{
163-
var pokeArgs = new GroupPokeEvent(poke.GroupUin, poke.OperatorUin, poke.TargetUin, poke.Action, poke.Suffix, poke.ActionImgUrl);
165+
var pokeArgs = new GroupPokeEvent(
166+
poke.GroupUin,
167+
poke.OperatorUin,
168+
poke.TargetUin,
169+
poke.Action,
170+
poke.Suffix,
171+
poke.ActionImgUrl,
172+
poke.MessageSequence,
173+
poke.MessageTime,
174+
poke.TipsSeqId
175+
);
164176
Collection.Invoker.PostEvent(pokeArgs);
165177
break;
166178
}
@@ -246,7 +258,17 @@ public override async Task Incoming(ProtocolEvent e)
246258
}
247259
case FriendSysPokeEvent poke:
248260
{
249-
var pokeArgs = new FriendPokeEvent(poke.OperatorUin, poke.TargetUin, poke.Action, poke.Suffix, poke.ActionImgUrl);
261+
var pokeArgs = new FriendPokeEvent(
262+
poke.OperatorUin,
263+
poke.TargetUin,
264+
poke.Action,
265+
poke.Suffix,
266+
poke.ActionImgUrl,
267+
poke.PeerUin,
268+
poke.MessageSequence,
269+
poke.MessageTime,
270+
poke.TipsSeqId
271+
);
250272
Collection.Invoker.PostEvent(pokeArgs);
251273
break;
252274
}
@@ -296,6 +318,21 @@ public override async Task Incoming(ProtocolEvent e)
296318

297319
break;
298320
}
321+
case GroupSysRecallPokeEvent recall:
322+
{
323+
uint operatorUin = await Collection.Business.CachingLogic.ResolveUin(null, recall.OperatorUid) ?? 0;
324+
var @event = new GroupRecallPokeEvent(recall.GroupUin, operatorUin, recall.TipsSeqId);
325+
Collection.Invoker.PostEvent(@event);
326+
break;
327+
}
328+
case FriendSysRecallPokeEvent recall:
329+
{
330+
uint peerUin = await Collection.Business.CachingLogic.ResolveUin(null, recall.PeerUid) ?? 0;
331+
uint operatorUin = await Collection.Business.CachingLogic.ResolveUin(null, recall.OperatorUid) ?? 0;
332+
var @event = new FriendRecallPokeEvent(peerUin, operatorUin, recall.TipsSeqId);
333+
Collection.Invoker.PostEvent(@event);
334+
break;
335+
}
299336
}
300337
}
301338

Lagrange.Core/Internal/Context/Logic/Implementation/OperationLogic.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,4 +933,24 @@ public async Task<string> UploadImage(ImageEntity image)
933933
var result = (MediaDownloadEvent)results[0];
934934
return (result.ResultCode, result.Message, result.Url);
935935
}
936+
937+
public async Task<(int Code, string Message)> GroupRecallPoke(ulong groupUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId)
938+
{
939+
var @event = RecallPokeEvent.Create(isGroup: true, groupUin, messageSequence, messageTime, tipsSeqId);
940+
var results = await Collection.Business.SendEvent(@event);
941+
if (results.Count == 0) return (-1, "No Result");
942+
943+
var result = (RecallPokeEvent)results[0];
944+
return (result.ResultCode, result.Message);
945+
}
946+
947+
public async Task<(int Code, string Message)> FriendRecallPoke(ulong groupUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId)
948+
{
949+
var @event = RecallPokeEvent.Create(isGroup: false, groupUin, messageSequence, messageTime, tipsSeqId);
950+
var results = await Collection.Business.SendEvent(@event);
951+
if (results.Count == 0) return (-1, "No Result");
952+
953+
var result = (RecallPokeEvent)results[0];
954+
return (result.ResultCode, result.Message);
955+
}
936956
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
namespace Lagrange.Core.Internal.Event.Message;
3+
4+
internal class RecallPokeEvent : ProtocolEvent
5+
{
6+
public bool IsGroup { get; init; }
7+
public ulong Uin { get; init; }
8+
public ulong MessageSequence { get; init; }
9+
public ulong MessageTime { get; init; }
10+
public ulong TipsSeqId { get; internal set; }
11+
12+
public string Message { get; set; }
13+
14+
private RecallPokeEvent(bool isGroup, ulong uin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) : base(true)
15+
{
16+
IsGroup = isGroup;
17+
Uin = uin;
18+
MessageSequence = messageSequence;
19+
MessageTime = messageTime;
20+
TipsSeqId = tipsSeqId;
21+
22+
Message = null!;
23+
}
24+
25+
private RecallPokeEvent(int retcode, string message) : base(retcode)
26+
{
27+
Message = message;
28+
}
29+
30+
public static RecallPokeEvent Create(bool isGroup, ulong uin, ulong messageSequence, ulong messageTime, ulong tipsSeqId)
31+
=> new(isGroup, uin, messageSequence, messageTime, tipsSeqId);
32+
33+
public static RecallPokeEvent Result(int retcode, string message)
34+
=> new(retcode, message);
35+
}

0 commit comments

Comments
 (0)