mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-06 15:33:11 +00:00
54 lines
1.8 KiB
C#
54 lines
1.8 KiB
C#
using BiblioTech.CodexChecking;
|
|
using BiblioTech.Options;
|
|
|
|
namespace BiblioTech.Commands
|
|
{
|
|
public class CheckUploadCommand : BaseCommand
|
|
{
|
|
private readonly CodexTwoWayChecker checker;
|
|
|
|
private readonly StringOption cidOption = new StringOption(
|
|
name: "cid",
|
|
description: "Codex Content-Identifier",
|
|
isRequired: false);
|
|
|
|
public CheckUploadCommand(CodexTwoWayChecker checker)
|
|
{
|
|
this.checker = checker;
|
|
}
|
|
|
|
public override string Name => "checkupload";
|
|
public override string StartingMessage => RandomBusyMessage.Get();
|
|
public override string Description => "Checks the upload connectivity of your Codex node.";
|
|
public override CommandOption[] Options => [cidOption];
|
|
|
|
protected override async Task Invoke(CommandContext context)
|
|
{
|
|
var user = context.Command.User;
|
|
var cid = await cidOption.Parse(context);
|
|
try
|
|
{
|
|
var handler = new CheckResponseHandler(context, user);
|
|
if (string.IsNullOrEmpty(cid))
|
|
{
|
|
await checker.StartUploadCheck(handler, user.Id);
|
|
}
|
|
else
|
|
{
|
|
await checker.VerifyUploadCheck(handler, user.Id, cid);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await RespondWithError(context, ex);
|
|
}
|
|
}
|
|
|
|
private async Task RespondWithError(CommandContext context, Exception ex)
|
|
{
|
|
await Program.AdminChecker.SendInAdminChannel("Exception during CheckUploadCommand: " + ex);
|
|
await context.Followup("I'm sorry to report something has gone wrong in an unexpected way. Error details are already posted in the admin channel.");
|
|
}
|
|
}
|
|
}
|