The bot is running on the main Thread now
This commit is contained in:
@@ -5,6 +5,7 @@ using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
|
||||
using PluginManager;
|
||||
using PluginManager.Bot;
|
||||
@@ -43,7 +44,7 @@ public class Program
|
||||
Installer.GenerateStartupConfig();
|
||||
}
|
||||
|
||||
HandleInput(args).Wait();
|
||||
HandleInput(args.ToList()).Wait();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -120,7 +121,7 @@ public class Program
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Config.Logger.Log(ex.ToString(),"Bot",TextType.ERROR);
|
||||
Config.Logger.Log(ex.ToString(), "Bot", TextType.ERROR);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -129,20 +130,21 @@ public class Program
|
||||
/// Handle user input arguments from the startup of the application
|
||||
/// </summary>
|
||||
/// <param name="args">The arguments</param>
|
||||
private static async Task HandleInput(string[] args)
|
||||
private static async Task HandleInput(List<string> args)
|
||||
{
|
||||
var len = args.Length;
|
||||
|
||||
Console.WriteLine("Loading Core ...");
|
||||
|
||||
var b = await StartNoGui();
|
||||
consoleCommandsHandler = new ConsoleCommandsHandler(b.client);
|
||||
|
||||
var mainThread = new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Launching core functions ...");
|
||||
if(args.Contains("--gui"))
|
||||
{
|
||||
// GUI not implemented yet
|
||||
Console.WriteLine("GUI not implemented yet");
|
||||
return;
|
||||
}
|
||||
NoGUI();
|
||||
}
|
||||
catch (IOException ex)
|
||||
@@ -152,11 +154,10 @@ public class Program
|
||||
if (Config.Data.ContainsKey("LaunchMessage"))
|
||||
Config.Data.Add("LaunchMessage",
|
||||
"An error occured while closing the bot last time. Please consider closing the bot using the &rsd&c method !\nThere is a risk of losing all data or corruption of the save file, which in some cases requires to reinstall the bot !");
|
||||
Config.Logger.Log("An error occured while closing the bot last time. Please consider closing the bot using the &rsd&c method !\nThere is a risk of losing all data or corruption of the save file, which in some cases requires to reinstall the bot !","Bot",TextType.ERROR);
|
||||
Config.Logger.Log("An error occured while closing the bot last time. Please consider closing the bot using the &rsd&c method !\nThere is a risk of losing all data or corruption of the save file, which in some cases requires to reinstall the bot !", "Bot", TextType.ERROR);
|
||||
}
|
||||
}
|
||||
});
|
||||
mainThread.Start();
|
||||
return;
|
||||
}
|
||||
|
||||
private static async Task PreLoadComponents(string[] args)
|
||||
@@ -199,7 +200,7 @@ public class Program
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Config.Logger.Log(ex.ToString(),"Bot",TextType.ERROR);
|
||||
Config.Logger.Log(ex.ToString(), "Bot", TextType.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +284,7 @@ public class Program
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Config.Logger.Log(ex.Message,"Updater", TextType.ERROR);
|
||||
Config.Logger.Log(ex.Message, "Updater", TextType.ERROR);
|
||||
if (ex.Message.Contains("Access de"))
|
||||
Config.Logger.Log("Please run the bot as root.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user