Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Lagrange.Core/Common/Interface/Api/OperationExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,11 @@ public static Task<string> FetchPrivateFSDownload(this BotContext bot, string fi

public static Task<bool> 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);
Comment on lines +317 to +318
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Public API extension methods lack XML documentation comments; consider adding summaries to explain purpose and parameters.

Suggested change
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);
/// <summary>
/// Recalls a poke message in a group chat.
/// </summary>
/// <param name="bot">The target <see cref="BotContext"/> instance.</param>
/// <param name="groupUin">The unique identifier of the group.</param>
/// <param name="messageSequence">The sequence number of the message to recall.</param>
/// <param name="messageTime">The timestamp of the message to recall.</param>
/// <param name="tipsSeqId">The sequence ID of the tips associated with the poke.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains a tuple with a status code and a message.</returns>
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);

Copilot uses AI. Check for mistakes.

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);

}
26 changes: 19 additions & 7 deletions Lagrange.Core/Event/EventArg/FriendPokeEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
}
}
19 changes: 19 additions & 0 deletions Lagrange.Core/Event/EventArg/FriendRecallPokeEvent.cs
Original file line number Diff line number Diff line change
@@ -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 groupUin, uint operatorUin, ulong tipsSeqId)
{
PeerUin = groupUin;
OperatorUin = operatorUin;
TipsSeqId = tipsSeqId;

EventMessage = $"[FriendRecallPoke] Peer: {PeerUin} | Operator: {OperatorUin} | TipsSeqId: {TipsSeqId}";
}
}
25 changes: 17 additions & 8 deletions Lagrange.Core/Event/EventArg/GroupPokeEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,35 @@ 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;
TargetUin = targetUin;
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}";
}
}
19 changes: 19 additions & 0 deletions Lagrange.Core/Event/EventArg/GroupRecallPokeEvent.cs
Original file line number Diff line number Diff line change
@@ -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}";
}
}
4 changes: 4 additions & 0 deletions Lagrange.Core/Event/EventInvoker.Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ public partial class EventInvoker
public event LagrangeEvent<GroupMemberEnterEvent>? OnGroupMemberEnterEvent;

public event LagrangeEvent<PinChangedEvent>? OnPinChangedEvent;

public event LagrangeEvent<GroupRecallPokeEvent>? OnGroupRecallPokeEvent;

public event LagrangeEvent<FriendRecallPokeEvent>? OnFriendRecallPokeEvent;
}
2 changes: 2 additions & 0 deletions Lagrange.Core/Event/EventInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -933,4 +933,24 @@ public async Task<string> 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);
}
}
35 changes: 35 additions & 0 deletions Lagrange.Core/Internal/Event/Message/RecallPokeEvent.cs
Original file line number Diff line number Diff line change
@@ -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);
}
28 changes: 20 additions & 8 deletions Lagrange.Core/Internal/Event/Notify/FriendSysPokeEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
20 changes: 20 additions & 0 deletions Lagrange.Core/Internal/Event/Notify/FriendSysRecallPokeEvent.cs
Original file line number Diff line number Diff line change
@@ -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);
}
Loading