Adds no-discord debug option to discord bot.
This commit is contained in:
parent
ad2181db0b
commit
22cf82b99b
|
@ -3,7 +3,7 @@ using Logging;
|
|||
using NUnit.Framework;
|
||||
using Utils;
|
||||
|
||||
namespace CodexTests.ScalabilityTests
|
||||
namespace CodexTests.UtilityTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ClusterDiscSpeedTests : DistTest
|
||||
|
@ -18,7 +18,7 @@ namespace CodexTests.ScalabilityTests
|
|||
)
|
||||
{
|
||||
long targetSize = (long)(1024 * 1024 * 1024) * 2;
|
||||
long bufferSizeBytes = ((long)bufferSizeKb) * 1024;
|
||||
long bufferSizeBytes = (long)bufferSizeKb * 1024;
|
||||
|
||||
var filename = nameof(DiscSpeedTest);
|
||||
|
||||
|
|
|
@ -34,28 +34,12 @@ namespace BiblioTech
|
|||
[Uniform("mint-tt", "mt", "MINTTT", true, "Amount of TestTokens minted by the mint command.")]
|
||||
public int MintTT { get; set; } = 1073741824;
|
||||
|
||||
public string EndpointsPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(DataPath, "endpoints");
|
||||
}
|
||||
}
|
||||
[Uniform("no-discord", "nd", "NODISCORD", false, "For debugging: Bypasses all Discord API calls.")]
|
||||
public int NoDiscord { get; set; } = 0;
|
||||
|
||||
public string UserDataPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(DataPath, "users");
|
||||
}
|
||||
}
|
||||
|
||||
public string LogPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(DataPath, "logs");
|
||||
}
|
||||
}
|
||||
public string EndpointsPath => Path.Combine(DataPath, "endpoints");
|
||||
public string UserDataPath => Path.Combine(DataPath, "users");
|
||||
public string LogPath => Path.Combine(DataPath, "logs");
|
||||
public bool DebugNoDiscord => NoDiscord == 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
using BiblioTech.Rewards;
|
||||
using DiscordRewards;
|
||||
using Logging;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BiblioTech
|
||||
{
|
||||
public class LoggingRoleDriver : IDiscordRoleDriver
|
||||
{
|
||||
private readonly ILog log;
|
||||
|
||||
public LoggingRoleDriver(ILog log)
|
||||
{
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
public async Task GiveRewards(GiveRewardsCommand rewards)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
log.Log(JsonConvert.SerializeObject(rewards, Formatting.None));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -41,6 +41,32 @@ namespace BiblioTech
|
|||
public async Task MainAsync(string[] args)
|
||||
{
|
||||
Log.Log("Starting Codex Discord Bot...");
|
||||
if (Config.DebugNoDiscord)
|
||||
{
|
||||
Log.Log("Debug option is set. Discord connection disabled!");
|
||||
RoleDriver = new LoggingRoleDriver(Log);
|
||||
}
|
||||
else
|
||||
{
|
||||
await StartDiscordBot();
|
||||
}
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.WebHost.ConfigureKestrel((context, options) =>
|
||||
{
|
||||
options.ListenAnyIP(Config.RewardApiPort);
|
||||
});
|
||||
builder.Services.AddControllers();
|
||||
var app = builder.Build();
|
||||
app.MapControllers();
|
||||
|
||||
Log.Log("Running...");
|
||||
await app.RunAsync();
|
||||
await Task.Delay(-1);
|
||||
}
|
||||
|
||||
private async Task StartDiscordBot()
|
||||
{
|
||||
client = new DiscordSocketClient();
|
||||
client.Log += ClientLog;
|
||||
|
||||
|
@ -60,19 +86,6 @@ namespace BiblioTech
|
|||
await client.LoginAsync(TokenType.Bot, Config.ApplicationToken);
|
||||
await client.StartAsync();
|
||||
AdminChecker = new AdminChecker();
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.WebHost.ConfigureKestrel((context, options) =>
|
||||
{
|
||||
options.ListenAnyIP(Config.RewardApiPort);
|
||||
});
|
||||
builder.Services.AddControllers();
|
||||
var app = builder.Build();
|
||||
app.MapControllers();
|
||||
|
||||
Log.Log("Running...");
|
||||
await app.RunAsync();
|
||||
await Task.Delay(-1);
|
||||
}
|
||||
|
||||
private static void PrintHelp()
|
||||
|
|
Loading…
Reference in New Issue