Skip to content

Commit 92ab9fe

Browse files
LinwenxuanLinwenxuan
authored andcommitted
[Core] Fill in the tag and message of Offline
1 parent e388d5b commit 92ab9fe

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

Lagrange.Core/Event/EventArg/BotOfflineEvent.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,13 @@ namespace Lagrange.Core.Event.EventArg;
22

33
public class BotOfflineEvent : EventBase
44
{
5+
public string Tag { get; }
56

7+
public string Message { get; }
8+
9+
public BotOfflineEvent(string tag, string message)
10+
{
11+
Tag = tag;
12+
Message = message;
13+
}
614
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public override async Task Incoming(ProtocolEvent e)
4444
Collection.Log.LogFatal(Tag, "Bot will be offline in 5 seconds...");
4545
await Task.Delay(5000);
4646

47-
Collection.Invoker.PostEvent(new BotOfflineEvent()); // TODO: Fill in the reason of offline
47+
Collection.Invoker.PostEvent(new BotOfflineEvent(kick.Tag, kick.Message)); // TODO: Fill in the reason of offline
4848
Collection.Scheduler.Dispose();
4949
break;
5050
}
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1+
using Lagrange.Core.Internal.Event.Message;
12
using Lagrange.Core.Message;
3+
using Lagrange.Core.Message.Entity;
24

35
namespace Lagrange.Core.Internal.Context.Uploader;
46

7+
[HighwayUploader(typeof(FileEntity))]
58
internal class FileUploader : IHighwayUploader
69
{
710
public Task UploadPrivate(ContextCollection context, MessageChain chain, IMessageEntity entity)
811
{
912
throw new NotImplementedException();
1013
}
1114

12-
public Task UploadGroup(ContextCollection context, MessageChain chain, IMessageEntity entity)
15+
public async Task UploadGroup(ContextCollection context, MessageChain chain, IMessageEntity entity)
1316
{
14-
throw new NotImplementedException();
17+
if (entity is FileEntity { FileStream: not null } file)
18+
{
19+
var uploadEvent = GroupFSUploadEvent.Create(chain.GroupUin ?? 0, file);
20+
var result = await context.Business.SendEvent(uploadEvent);
21+
}
1522
}
1623
}

Lagrange.Core/Internal/Context/Uploader/PttUploader.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
using Lagrange.Core.Message;
2+
using Lagrange.Core.Message.Entity;
23

34
namespace Lagrange.Core.Internal.Context.Uploader;
45

6+
[HighwayUploader(typeof(RecordEntity))]
57
internal class PttUploader : IHighwayUploader
68
{
9+
private const string Tag = nameof(PttUploader);
10+
711
public Task UploadPrivate(ContextCollection context, MessageChain chain, IMessageEntity entity)
812
{
913
throw new NotImplementedException();

0 commit comments

Comments
 (0)