moves bot config for non docker to their own folder
this will allow you to setup adverts/relays per bot vs sharing for all bots
This commit is contained in:
parent
fd066cc5bd
commit
258f180009
7 changed files with 31 additions and 18 deletions
|
|
@ -44,12 +44,13 @@ namespace BetterSecondbot.Adverts
|
||||||
demoAdvert.hour = "12";
|
demoAdvert.hour = "12";
|
||||||
demoAdvert.min = "30";
|
demoAdvert.min = "30";
|
||||||
demoAdvert.notice = "false";
|
demoAdvert.notice = "false";
|
||||||
demoAdvert.enabled = "true";
|
demoAdvert.enabled = "false";
|
||||||
loadedAdverts.adverts = new advertConfig[] { demoAdvert };
|
loadedAdverts.adverts = new advertConfig[] { demoAdvert };
|
||||||
|
|
||||||
|
|
||||||
string targetfile = "adverts.json";
|
string targetfile = "adverts.json";
|
||||||
SimpleIO io = new SimpleIO();
|
SimpleIO io = new SimpleIO();
|
||||||
|
io.ChangeRoot(controler.getFolderUsed());
|
||||||
if (SimpleIO.FileType(targetfile, "json") == false)
|
if (SimpleIO.FileType(targetfile, "json") == false)
|
||||||
{
|
{
|
||||||
LogFormater.Status("Creating new adverts file", true);
|
LogFormater.Status("Creating new adverts file", true);
|
||||||
|
|
@ -75,7 +76,7 @@ namespace BetterSecondbot.Adverts
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
io.makeOld(targetfile);
|
io.MarkOld(targetfile);
|
||||||
io.WriteJsonAdverts(loadedAdverts, targetfile);
|
io.WriteJsonAdverts(loadedAdverts, targetfile);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,7 @@ namespace BetterSecondBot.BetterRelayService
|
||||||
};
|
};
|
||||||
string targetfile = "customrelays.json";
|
string targetfile = "customrelays.json";
|
||||||
SimpleIO io = new SimpleIO();
|
SimpleIO io = new SimpleIO();
|
||||||
|
io.ChangeRoot(controler.getFolderUsed());
|
||||||
if (SimpleIO.FileType(targetfile, "json") == false)
|
if (SimpleIO.FileType(targetfile, "json") == false)
|
||||||
{
|
{
|
||||||
io.WriteJsonRelays(LoadedRelays, targetfile);
|
io.WriteJsonRelays(LoadedRelays, targetfile);
|
||||||
|
|
@ -138,7 +139,7 @@ namespace BetterSecondBot.BetterRelayService
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
io.makeOld(targetfile);
|
io.MarkOld(targetfile);
|
||||||
io.WriteJsonRelays(LoadedRelays, targetfile);
|
io.WriteJsonRelays(LoadedRelays, targetfile);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ namespace BetterSecondBot
|
||||||
{
|
{
|
||||||
public bool Exited { get { return exitBot; } }
|
public bool Exited { get { return exitBot; } }
|
||||||
protected bool exitBot = false;
|
protected bool exitBot = false;
|
||||||
|
protected string use_folder = "";
|
||||||
protected SecondBot Bot = null;
|
protected SecondBot Bot = null;
|
||||||
protected BetterAtHome betterAtHomeService;
|
protected BetterAtHome betterAtHomeService;
|
||||||
protected BetterTracking betterTracking;
|
protected BetterTracking betterTracking;
|
||||||
|
|
@ -27,6 +28,11 @@ namespace BetterSecondBot
|
||||||
return Bot;
|
return Bot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string getFolderUsed()
|
||||||
|
{
|
||||||
|
return use_folder;
|
||||||
|
}
|
||||||
|
|
||||||
protected void keep_alive()
|
protected void keep_alive()
|
||||||
{
|
{
|
||||||
while (Bot.KillMe == false)
|
while (Bot.KillMe == false)
|
||||||
|
|
@ -66,9 +72,10 @@ namespace BetterSecondBot
|
||||||
betterTracking = new BetterTracking(this);
|
betterTracking = new BetterTracking(this);
|
||||||
datastorage = new Datastorage(this);
|
datastorage = new Datastorage(this);
|
||||||
}
|
}
|
||||||
public Cli(JsonConfig Config, bool as_docker, bool use_self_keep_alive)
|
public Cli(JsonConfig Config, bool as_docker, bool use_self_keep_alive, string loadingFromFolder)
|
||||||
{
|
{
|
||||||
exitBot = false;
|
exitBot = false;
|
||||||
|
use_folder = loadingFromFolder;
|
||||||
LogFormater.Info("Starting cli");
|
LogFormater.Info("Starting cli");
|
||||||
if (helpers.botRequired(Config) == true)
|
if (helpers.botRequired(Config) == true)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace BetterSecondBot
|
||||||
LogFormater.Status("-> Getting config from Docker");
|
LogFormater.Status("-> Getting config from Docker");
|
||||||
JsonConfig Config = MakeJsonConfig.FromENV();
|
JsonConfig Config = MakeJsonConfig.FromENV();
|
||||||
Config = MakeJsonConfig.Http_config_check(Config);
|
Config = MakeJsonConfig.Http_config_check(Config);
|
||||||
new Discord_super(Config,true);
|
new Discord_super(Config,true,"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,24 +15,26 @@ namespace BetterSecondBot
|
||||||
{
|
{
|
||||||
SimpleIO io = new SimpleIO();
|
SimpleIO io = new SimpleIO();
|
||||||
JsonConfig Config = new JsonConfig();
|
JsonConfig Config = new JsonConfig();
|
||||||
string json_file = "";
|
string loadFolder = "debug";
|
||||||
|
string json_file = "bot.json";
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
LogFormater.Status("Hardware/Debug version");
|
LogFormater.Debug("!! RUNNING IN DEBUG !!");
|
||||||
json_file = "debug.json";
|
|
||||||
#else
|
#else
|
||||||
LogFormater.Status("Hardware/Live version");
|
LogFormater.Status("Hardware config");
|
||||||
if(args.Length == 1)
|
if(args.Length == 1)
|
||||||
{
|
{
|
||||||
json_file = ""+args[0]+".json";
|
loadFolder = args[0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
json_file = "mybot.json";
|
loadFolder = "default";
|
||||||
LogFormater.Warn("Using: mybot.json as the config");
|
io.ChangeRoot("default");
|
||||||
|
LogFormater.Warn("Using: using default folder");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
if (SimpleIO.dir_exists("wiki") == false)
|
io.ChangeRoot(loadFolder);
|
||||||
|
if (SimpleIO.DirExists("wiki") == false)
|
||||||
{
|
{
|
||||||
LogFormater.Info("Basic Wiki [Creating]");
|
LogFormater.Info("Basic Wiki [Creating]");
|
||||||
new DebugModeCreateWiki(AssemblyInfo.GetGitHash(), io);
|
new DebugModeCreateWiki(AssemblyInfo.GetGitHash(), io);
|
||||||
|
|
@ -55,7 +57,7 @@ namespace BetterSecondBot
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LogFormater.Warn("Unable to read config file\n moving config to " + json_file + ".old and creating a empty config\nError was: " + e.Message + "");
|
LogFormater.Warn("Unable to read config file\n moving config to " + json_file + ".old and creating a empty config\nError was: " + e.Message + "");
|
||||||
io.makeOld(json_file);
|
io.MarkOld(json_file);
|
||||||
Config = new JsonConfig();
|
Config = new JsonConfig();
|
||||||
io.WriteJsonConfig(MakeJsonConfig.GetDefault(), json_file);
|
io.WriteJsonConfig(MakeJsonConfig.GetDefault(), json_file);
|
||||||
}
|
}
|
||||||
|
|
@ -79,7 +81,7 @@ namespace BetterSecondBot
|
||||||
if(ok_to_try_start == true)
|
if(ok_to_try_start == true)
|
||||||
{
|
{
|
||||||
Config = MakeJsonConfig.Http_config_check(Config);
|
Config = MakeJsonConfig.Http_config_check(Config);
|
||||||
new Discord_super(Config, false);
|
new Discord_super(Config, false, loadFolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,11 @@ namespace BetterSecondBot.DiscordSupervisor
|
||||||
Thread.Sleep(1500);
|
Thread.Sleep(1500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Discord_super(JsonConfig configfile, bool as_docker)
|
public Discord_super(JsonConfig configfile, bool as_docker, string readfromfolder)
|
||||||
{
|
{
|
||||||
myconfig = configfile;
|
myconfig = configfile;
|
||||||
running_as_docker = as_docker;
|
running_as_docker = as_docker;
|
||||||
|
use_folder = readfromfolder;
|
||||||
startService();
|
startService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,7 +84,7 @@ namespace BetterSecondBot.DiscordSupervisor
|
||||||
controler.getBot().KillMePlease();
|
controler.getBot().KillMePlease();
|
||||||
controler = null;
|
controler = null;
|
||||||
}
|
}
|
||||||
controler = new Cli(myconfig, running_as_docker, self_keep_alive);
|
controler = new Cli(myconfig, running_as_docker, self_keep_alive, use_folder);
|
||||||
controler.getBot().setDiscordClient(DiscordClient);
|
controler.getBot().setDiscordClient(DiscordClient);
|
||||||
relayService = new BetterRelay(controler, this, running_as_docker);
|
relayService = new BetterRelay(controler, this, running_as_docker);
|
||||||
attach_events();
|
attach_events();
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ namespace BetterSecondBot.DiscordSupervisor
|
||||||
protected bool exit_super = false;
|
protected bool exit_super = false;
|
||||||
protected Cli controler;
|
protected Cli controler;
|
||||||
protected bool running_as_docker = false;
|
protected bool running_as_docker = false;
|
||||||
|
protected string use_folder = "";
|
||||||
|
|
||||||
protected bool discord_group_relay;
|
protected bool discord_group_relay;
|
||||||
protected DiscordSocketClient DiscordClient;
|
protected DiscordSocketClient DiscordClient;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue