Skip to content

Commit

Permalink
[Core] Fill in the tag and message of Offline
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan authored and Linwenxuan committed Jan 26, 2024
1 parent e388d5b commit 92ab9fe
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
8 changes: 8 additions & 0 deletions Lagrange.Core/Event/EventArg/BotOfflineEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@ namespace Lagrange.Core.Event.EventArg;

public class BotOfflineEvent : EventBase
{
public string Tag { get; }

public string Message { get; }

public BotOfflineEvent(string tag, string message)
{
Tag = tag;
Message = message;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override async Task Incoming(ProtocolEvent e)
Collection.Log.LogFatal(Tag, "Bot will be offline in 5 seconds...");
await Task.Delay(5000);

Collection.Invoker.PostEvent(new BotOfflineEvent()); // TODO: Fill in the reason of offline
Collection.Invoker.PostEvent(new BotOfflineEvent(kick.Tag, kick.Message)); // TODO: Fill in the reason of offline
Collection.Scheduler.Dispose();
break;
}
Expand Down
11 changes: 9 additions & 2 deletions Lagrange.Core/Internal/Context/Uploader/FileUploader.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
using Lagrange.Core.Internal.Event.Message;
using Lagrange.Core.Message;
using Lagrange.Core.Message.Entity;

namespace Lagrange.Core.Internal.Context.Uploader;

[HighwayUploader(typeof(FileEntity))]
internal class FileUploader : IHighwayUploader
{
public Task UploadPrivate(ContextCollection context, MessageChain chain, IMessageEntity entity)
{
throw new NotImplementedException();
}

public Task UploadGroup(ContextCollection context, MessageChain chain, IMessageEntity entity)
public async Task UploadGroup(ContextCollection context, MessageChain chain, IMessageEntity entity)
{
throw new NotImplementedException();
if (entity is FileEntity { FileStream: not null } file)
{
var uploadEvent = GroupFSUploadEvent.Create(chain.GroupUin ?? 0, file);
var result = await context.Business.SendEvent(uploadEvent);
}
}
}
4 changes: 4 additions & 0 deletions Lagrange.Core/Internal/Context/Uploader/PttUploader.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using Lagrange.Core.Message;
using Lagrange.Core.Message.Entity;

namespace Lagrange.Core.Internal.Context.Uploader;

[HighwayUploader(typeof(RecordEntity))]

Check failure on line 6 in Lagrange.Core/Internal/Context/Uploader/PttUploader.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'RecordEntity' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 6 in Lagrange.Core/Internal/Context/Uploader/PttUploader.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'RecordEntity' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 6 in Lagrange.Core/Internal/Context/Uploader/PttUploader.cs

View workflow job for this annotation

GitHub Actions / Build (linux-arm64)

The type or namespace name 'RecordEntity' could not be found (are you missing a using directive or an assembly reference?)
internal class PttUploader : IHighwayUploader
{
private const string Tag = nameof(PttUploader);

public Task UploadPrivate(ContextCollection context, MessageChain chain, IMessageEntity entity)
{
throw new NotImplementedException();
Expand Down

0 comments on commit 92ab9fe

Please sign in to comment.