Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sisi0318 committed Sep 5, 2024
2 parents 903b99b + 1da89c8 commit 396080b
Show file tree
Hide file tree
Showing 52 changed files with 325 additions and 162 deletions.
6 changes: 3 additions & 3 deletions Lagrange.Core/Common/Interface/Api/GroupExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ public static Task<List<IBotFSEntry>> FetchGroupFSList(this BotContext bot, uint
public static Task<string> FetchGroupFSDownload(this BotContext bot, uint groupUin, string fileId)
=> bot.ContextCollection.Business.OperationLogic.FetchGroupFSDownload(groupUin, fileId);

public static Task<bool> GroupFSMove(this BotContext bot, uint groupUin, string fileId, string parentDirectory, string targetDirectory)
public static Task<(int, string)> GroupFSMove(this BotContext bot, uint groupUin, string fileId, string parentDirectory, string targetDirectory)
=> bot.ContextCollection.Business.OperationLogic.GroupFSMove(groupUin, fileId, parentDirectory, targetDirectory);

public static Task<bool> GroupFSDelete(this BotContext bot, uint groupUin, string fileId)
public static Task<(int, string)> GroupFSDelete(this BotContext bot, uint groupUin, string fileId)
=> bot.ContextCollection.Business.OperationLogic.GroupFSDelete(groupUin, fileId);

public static Task<(int, string)> GroupFSCreateFolder(this BotContext bot, uint groupUin, string name)
Expand Down
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})";
}
}
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 @@ -35,6 +35,7 @@ namespace Lagrange.Core.Internal.Context.Logic.Implementation;
[EventSubscribe(typeof(FriendSysRequestEvent))]
[EventSubscribe(typeof(FriendSysPokeEvent))]
[EventSubscribe(typeof(LoginNotifyEvent))]
[EventSubscribe(typeof(MultiMsgDownloadEvent))]
[BusinessLogic("MessagingLogic", "Manage the receiving and sending of messages and notifications")]
internal class MessagingLogic : LogicBase
{
Expand Down Expand Up @@ -165,7 +166,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 Expand Up @@ -194,7 +195,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 All @@ -210,6 +211,18 @@ public override async Task Incoming(ProtocolEvent e)
Collection.Invoker.PostEvent(deviceArgs);
break;
}
case MultiMsgDownloadEvent multi:
{
if (multi.Chains != null)
{
foreach (var chain in multi.Chains)
{
if (chain.Count == 0) return;
await ResolveIncomingChain(chain);
}
}
break;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,22 @@ public async Task<string> FetchGroupFSDownload(uint groupUin, string fileId)
return $"{((GroupFSDownloadEvent)events[0]).FileUrl}{fileId}";
}

public async Task<bool> GroupFSMove(uint groupUin, string fileId, string parentDirectory, string targetDirectory)
public async Task<(int, string)> GroupFSMove(uint groupUin, string fileId, string parentDirectory, string targetDirectory)
{
var groupFSMoveEvent = GroupFSMoveEvent.Create(groupUin, fileId, parentDirectory, targetDirectory);
var events = await Collection.Business.SendEvent(groupFSMoveEvent);
return events.Count != 0 && ((GroupFSMoveEvent)events[0]).ResultCode == 0;
var retCode = events.Count > 0 ? ((GroupFSMoveEvent)events[0]).ResultCode : -1;
var retMsg = events.Count > 0 ? ((GroupFSMoveEvent)events[0]).RetMsg : "";
return new(retCode, retMsg);
}

public async Task<bool> GroupFSDelete(uint groupUin, string fileId)
public async Task<(int, string)> GroupFSDelete(uint groupUin, string fileId)
{
var groupFSDeleteEvent = GroupFSDeleteEvent.Create(groupUin, fileId);
var events = await Collection.Business.SendEvent(groupFSDeleteEvent);
return events.Count != 0 && ((GroupFSDeleteEvent)events[0]).ResultCode == 0;
var retCode = events.Count > 0 ? ((GroupFSDeleteEvent)events[0]).ResultCode : -1;
var retMsg = events.Count > 0 ? ((GroupFSDeleteEvent)events[0]).RetMsg : "";
return new(retCode, retMsg);
}

public async Task<(int, string)> GroupFSCreateFolder(uint groupUin, string name)
Expand Down Expand Up @@ -258,7 +262,7 @@ public async Task<bool> RecallGroupMessage(MessageChain chain)
var events = await Collection.Business.SendEvent(fetchRequestsEvent);
if (events.Count == 0) return null;

var resolved = ((FetchGroupRequestsEvent)events[0]).Events;
var resolved = events.Cast<FetchGroupRequestsEvent>().SelectMany(e => e.Events).ToList();
var results = new List<BotGroupRequest>();

foreach (var result in resolved)
Expand Down
1 change: 0 additions & 1 deletion Lagrange.Core/Internal/Context/Uploader/FileUploader.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Lagrange.Core.Internal.Event.Message;
using Lagrange.Core.Internal.Event.System;
using Lagrange.Core.Internal.Packets.Service.Highway;
using Lagrange.Core.Message;
using Lagrange.Core.Message.Entity;
Expand Down
2 changes: 0 additions & 2 deletions Lagrange.Core/Internal/Context/Uploader/ImageUploader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Lagrange.Core.Internal.Event.Message;
using Lagrange.Core.Internal.Event.System;
using Lagrange.Core.Internal.Packets.Service.Highway;
using Lagrange.Core.Message;
using Lagrange.Core.Message.Entity;
using Lagrange.Core.Utility.Extension;
Expand Down
3 changes: 0 additions & 3 deletions Lagrange.Core/Internal/Context/Uploader/PttUploader.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Lagrange.Core.Internal.Event.Message;
using Lagrange.Core.Internal.Event.System;
using Lagrange.Core.Internal.Packets.Service.Highway;
using Lagrange.Core.Internal.Packets.Service.Oidb.Common;
using Lagrange.Core.Message;
using Lagrange.Core.Message.Entity;
using Lagrange.Core.Utility.Extension;
Expand Down
1 change: 0 additions & 1 deletion Lagrange.Core/Internal/Context/Uploader/VideoUploader.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Lagrange.Core.Internal.Event.Message;
using Lagrange.Core.Internal.Packets.Service.Highway;
using Lagrange.Core.Message;
using Lagrange.Core.Message.Entity;
using Lagrange.Core.Utility.Extension;
Expand Down
10 changes: 7 additions & 3 deletions Lagrange.Core/Internal/Event/Action/GroupFSDeleteEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ internal class GroupFSDeleteEvent : GroupFSOperationEvent
{
public string FileId { get; set; }

public string RetMsg { get; set; } = string.Empty;

public GroupFSDeleteEvent(uint groupUin, string fileId) : base(groupUin)
{
FileId = fileId;
}

public GroupFSDeleteEvent(int resultCode) : base(resultCode) { }
public GroupFSDeleteEvent(int resultCode, string retMsg) : base(resultCode)
{
RetMsg = retMsg;
}

public static GroupFSDeleteEvent Create(uint groupUin, string fileId)
=> new(groupUin, fileId);

public static GroupFSDeleteEvent Result(int resultCode)
=> new(resultCode);
public static GroupFSDeleteEvent Result(int resultCode, string retMsg) => new(resultCode, retMsg);
}
12 changes: 8 additions & 4 deletions Lagrange.Core/Internal/Event/Action/GroupFSMoveEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ internal class GroupFSMoveEvent : GroupFSOperationEvent

public string TargetDirectory { get; set; }

public string RetMsg { get; set; } = string.Empty;

private GroupFSMoveEvent(uint groupUin, string fileId, string parentDirectory, string targetDirectory) : base(groupUin)
{
FileId = fileId;
ParentDirectory = parentDirectory;
TargetDirectory = targetDirectory;
}

private GroupFSMoveEvent(int resultCode) : base(resultCode) { }

private GroupFSMoveEvent(int resultCode, string retMsg) : base(resultCode)
{
RetMsg = retMsg;
}

public static GroupFSMoveEvent Create(uint groupUin, string fileId, string parentDirectory, string targetDirectory)
=> new(groupUin, fileId, parentDirectory, targetDirectory);

public static GroupFSMoveEvent Result(int resultCode)
=> new(resultCode);
public static GroupFSMoveEvent Result(int resultCode, string retMsg) => new(resultCode, retMsg);
}
1 change: 0 additions & 1 deletion Lagrange.Core/Internal/Event/Message/ImageUploadEvent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Lagrange.Core.Internal.Packets.Message.Component;
using Lagrange.Core.Internal.Packets.Message.Element.Implementation;
using Lagrange.Core.Internal.Packets.Service.Oidb.Common;
using Lagrange.Core.Message.Entity;
Expand Down
1 change: 0 additions & 1 deletion Lagrange.Core/Internal/Event/Message/VideoUploadEvent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Lagrange.Core.Internal.Packets.Message.Component;
using Lagrange.Core.Internal.Packets.Message.Element.Implementation;
using Lagrange.Core.Internal.Packets.Service.Oidb.Common;
using Lagrange.Core.Message.Entity;
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);
}
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);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Lagrange.Core.Utility.Binary;
using static Lagrange.Core.Utility.Binary.BinaryPacket;

namespace Lagrange.Core.Internal.Packets.Login.NTLogin.Plain.Body;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Lagrange.Core.Internal.Packets.Message.Element.Implementation.Extra;
using ProtoBuf;

// ReSharper disable InconsistentNaming
Expand Down
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 FriendRecallTipInfo TipInfo { get; set; }
}

[ProtoContract]
internal class FriendRecallTipInfo
{
[ProtoMember(2)] public string? Tip { get; set; }
}
Loading

0 comments on commit 396080b

Please sign in to comment.