Implemented Recall others
This commit is contained in:
parent
c2909e11f6
commit
7902cad675
5 changed files with 19 additions and 4 deletions
|
@ -25,4 +25,7 @@ public static class OperationExt
|
|||
|
||||
public static Task<bool> RecallGroupMessage(this BotContext bot, uint groupUin, MessageResult result)
|
||||
=> bot.ContextCollection.Business.OperationLogic.RecallGroupMessage(groupUin, result);
|
||||
|
||||
public static Task<bool> RecallGroupMessage(this BotContext bot, MessageChain chain)
|
||||
=> bot.ContextCollection.Business.OperationLogic.RecallGroupMessage(chain);
|
||||
}
|
||||
|
|
|
@ -98,10 +98,20 @@ internal class OperationLogic : LogicBase
|
|||
{
|
||||
if (result.Sequence == null) return false;
|
||||
|
||||
var recallMessageEvent = RecallGroupMessageEvent.Create(groupUin, (uint)result.Sequence);
|
||||
var recallMessageEvent = RecallGroupMessageEvent.Create(groupUin, result.Sequence.Value);
|
||||
var events = await Collection.Business.SendEvent(recallMessageEvent);
|
||||
return events.Count != 0 && ((RecallGroupMessageEvent)events[0]).ResultCode == 0;
|
||||
}
|
||||
|
||||
public async Task<bool> RecallGroupMessage(MessageChain chain)
|
||||
{
|
||||
if (chain.GroupUin == null) return false;
|
||||
|
||||
var recallMessageEvent = RecallGroupMessageEvent.Create(chain.GroupUin.Value, chain.Sequence);
|
||||
var events = await Collection.Business.SendEvent(recallMessageEvent);
|
||||
return events.Count != 0 && ((RecallGroupMessageEvent)events[0]).ResultCode == 0;
|
||||
}
|
||||
|
||||
|
||||
private static int CalculateBkn(string sKey) =>
|
||||
(int)sKey.Aggregate<char, long>(5381, (current, t) => current + (current << 5) + t) & int.MaxValue;
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
<Version>0.0.5-alpha</Version>
|
||||
<Copyright>Linwenxuan04 2023</Copyright>
|
||||
<RepositoryUrl>https://github.com/Linwenxuan05/Lagrange.Core</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<IsPublishable>true</IsPublishable>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -39,11 +39,11 @@ public sealed class MessageChain : List<IMessageEntity>
|
|||
Elements = new List<Elem>();
|
||||
}
|
||||
|
||||
internal MessageChain(uint groupUin, uint friendUin)
|
||||
internal MessageChain(uint groupUin, uint friendUin, uint sequence)
|
||||
{
|
||||
GroupUin = groupUin;
|
||||
FriendUin = friendUin;
|
||||
Sequence = 0; // unuseful at there
|
||||
Sequence = sequence;
|
||||
Uid = null;
|
||||
IsGroup = true;
|
||||
Elements = new List<Elem>();
|
||||
|
|
|
@ -161,6 +161,6 @@ internal class MessagePacker
|
|||
{
|
||||
return message.ResponseHead.Grp == null
|
||||
? new MessageChain(message.ResponseHead.FromUin,message.ResponseHead.ToUid ?? string.Empty ,message.ResponseHead.FromUid ?? string.Empty)
|
||||
: new MessageChain(message.ResponseHead.Grp.GroupUin, message.ResponseHead.FromUin);
|
||||
: new MessageChain(message.ResponseHead.Grp.GroupUin, message.ResponseHead.FromUin, (uint)(message.ContentHead.MsgSe ?? 0));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue