2023-10-24 07:51:29 +00:00
|
|
|
|
using Core;
|
|
|
|
|
using KubernetesWorkflow;
|
2023-11-12 09:07:23 +00:00
|
|
|
|
using KubernetesWorkflow.Types;
|
2023-10-24 07:51:29 +00:00
|
|
|
|
|
|
|
|
|
namespace CodexDiscordBotPlugin
|
|
|
|
|
{
|
|
|
|
|
public class CodexDiscordBotPlugin : IProjectPlugin, IHasLogPrefix, IHasMetadata
|
|
|
|
|
{
|
|
|
|
|
private readonly IPluginTools tools;
|
|
|
|
|
|
|
|
|
|
public CodexDiscordBotPlugin(IPluginTools tools)
|
|
|
|
|
{
|
|
|
|
|
this.tools = tools;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string LogPrefix => "(DiscordBot) ";
|
|
|
|
|
|
|
|
|
|
public void Announce()
|
|
|
|
|
{
|
|
|
|
|
tools.GetLog().Log($"Codex DiscordBot (BiblioTech) loaded.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddMetadata(IAddMetadata metadata)
|
|
|
|
|
{
|
2023-10-24 11:48:24 +00:00
|
|
|
|
metadata.Add("codexdiscordbotid", new DiscordBotContainerRecipe().Image);
|
2023-10-24 07:51:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Decommission()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-07 10:17:20 +00:00
|
|
|
|
public RunningContainers Deploy(DiscordBotStartupConfig config)
|
2023-10-24 07:51:29 +00:00
|
|
|
|
{
|
2023-10-24 08:06:07 +00:00
|
|
|
|
var workflow = tools.CreateWorkflow();
|
2023-10-24 11:48:24 +00:00
|
|
|
|
return StartContainer(workflow, config);
|
2023-10-24 08:17:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-31 16:52:02 +00:00
|
|
|
|
public RunningContainers DeployRewarder(RewarderBotStartupConfig config)
|
|
|
|
|
{
|
|
|
|
|
var workflow = tools.CreateWorkflow();
|
|
|
|
|
return StartRewarderContainer(workflow, config);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-07 10:17:20 +00:00
|
|
|
|
private RunningContainers StartContainer(IStartupWorkflow workflow, DiscordBotStartupConfig config)
|
2023-10-24 08:17:57 +00:00
|
|
|
|
{
|
2023-10-24 08:06:07 +00:00
|
|
|
|
var startupConfig = new StartupConfig();
|
|
|
|
|
startupConfig.NameOverride = config.Name;
|
|
|
|
|
startupConfig.Add(config);
|
2023-11-07 10:17:20 +00:00
|
|
|
|
return workflow.Start(1, new DiscordBotContainerRecipe(), startupConfig);
|
2023-10-24 08:17:57 +00:00
|
|
|
|
}
|
2024-01-31 16:52:02 +00:00
|
|
|
|
|
|
|
|
|
private RunningContainers StartRewarderContainer(IStartupWorkflow workflow, RewarderBotStartupConfig config)
|
|
|
|
|
{
|
|
|
|
|
var startupConfig = new StartupConfig();
|
|
|
|
|
startupConfig.Add(config);
|
|
|
|
|
return workflow.Start(1, new RewarderBotContainerRecipe(), startupConfig);
|
|
|
|
|
}
|
2023-10-24 07:51:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|