Esempio n. 1
0
        public CliDocker()
        {
            Thread.Sleep(3000);
            LogFormater.Status("-> Getting config from Docker");
            JsonConfig Config = MakeJsonConfig.FromENV();

            Config = MakeJsonConfig.Http_config_check(Config);
            new Discord_super(Config, true, "");
        }
Esempio n. 2
0
        public CliDocker()
        {
            Thread.Sleep(3000);
            ConsoleLog.Status("-> Getting config from Docker");
            JsonConfig Config = MakeJsonConfig.FromENV();

            Config = MakeJsonConfig.http_config_check(Config);
            new CliExitOnLogout(Config);
        }
Esempio n. 3
0
 public static bool botRequired(JsonConfig test)
 {
     if (helpers.notempty(test.userName) && helpers.notempty(test.password) && helpers.notempty(test.master) && helpers.notempty(test.code))
     {
         // required values are set
         MakeJsonConfig Testing             = new MakeJsonConfig();
         string[]       testingfor          = new[] { "userName", "password", "code" };
         bool           default_value_found = false;
         foreach (string a in testingfor)
         {
             if (Testing.GetCommandArgTypes(a).First() == Testing.GetProp(test, a))
             {
                 ConsoleLog.Warn("" + a + " is currently set to the default");
                 default_value_found = true;
                 break;
             }
         }
         if (default_value_found == false)
         {
             ConsoleLog.Status("User => " + test.userName);
             ConsoleLog.Status("Master => " + test.master);
         }
         return(!default_value_found);
     }
     else
     {
         if (helpers.notempty(test.userName) == false)
         {
             ConsoleLog.Warn("Username is null or empty");
         }
         if (helpers.notempty(test.password) == false)
         {
             ConsoleLog.Warn("Password is null or empty");
         }
         if (helpers.notempty(test.master) == false)
         {
             ConsoleLog.Warn("Master is null or empty");
         }
         if (helpers.notempty(test.code) == false)
         {
             ConsoleLog.Warn("Code is null or empty");
         }
         return(false);
     }
 }
Esempio n. 4
0
 public static bool botRequired(JsonConfig test)
 {
     if (helpers.notempty(test.Basic_BotUserName) && helpers.notempty(test.Basic_BotPassword) && helpers.notempty(test.Security_MasterUsername) && helpers.notempty(test.Security_SignedCommandkey))
     {
         // required values are set
         MakeJsonConfig Testing             = new MakeJsonConfig();
         string[]       testingfor          = new[] { "Basic_BotUserName", "Basic_BotPassword", "Security_SignedCommandkey", "Security_WebUIKey" };
         bool           default_value_found = false;
         foreach (string a in testingfor)
         {
             if (Testing.GetCommandArgTypes(a).First() == MakeJsonConfig.GetProp(test, a))
             {
                 ConsoleLog.Warn("" + a + " is currently set to the default");
                 default_value_found = true;
                 break;
             }
         }
         if (default_value_found == false)
         {
             ConsoleLog.Status("User => " + test.Basic_BotUserName);
             ConsoleLog.Status("Master => " + test.Security_MasterUsername);
         }
         return(!default_value_found);
     }
     else
     {
         if (helpers.notempty(test.Basic_BotUserName) == false)
         {
             ConsoleLog.Warn("Basic_BotUserName is null or empty");
         }
         if (helpers.notempty(test.Basic_BotPassword) == false)
         {
             ConsoleLog.Warn("Basic_BotPassword is null or empty");
         }
         if (helpers.notempty(test.Security_MasterUsername) == false)
         {
             ConsoleLog.Warn("Security_MasterUsername is null or empty");
         }
         if (helpers.notempty(test.Security_SignedCommandkey) == false)
         {
             ConsoleLog.Warn("Security_SignedCommandkey is null or empty");
         }
         return(false);
     }
 }
Esempio n. 5
0
        public DebugModeCreateWiki(string Version, SimpleIO shareio)
        {
            io           = shareio;
            buildVersion = Version;
            html_header  = helpers.ReadResourceFile(Assembly.GetExecutingAssembly(), "wiki_header.txt");
            html_footer  = helpers.ReadResourceFile(Assembly.GetExecutingAssembly(), "wiki_footer.txt");
            io.ChangeRoot("wiki");
            io.ChangeRoot("wiki/files");

            // JSONcfg
            MakeJsonConfig defaultJson = new MakeJsonConfig();

            api_reports.Add("JSON", new KeyValuePair <int, string>(defaultJson.ApiCommandsCount, "Ready"));
            InterfaceWiki("JSON", defaultJson);

            // HTTP
            HTTPWiki();

            io.ChangeRoot("wiki");
            io.WriteFile("index.html", CreateRoot());
        }
Esempio n. 6
0
        public CliHardware(string[] args)
        {
            SimpleIO   io = new SimpleIO();
            JsonConfig Config;
            string     json_file = "";

#if DEBUG
            ConsoleLog.Status("Hardware/Debug version");
            json_file = "debug.json";
#else
            ConsoleLog.Status("Hardware/Live version");
            Parser.Default.ParseArguments <Options>(args).WithParsed <Options>(o =>
            {
                json_file = o.Json;
            });
#endif
            if (SimpleIO.dir_exists("wiki") == false)
            {
                ConsoleLog.Info("Basic Wiki [Creating]");
                new DebugModeCreateWiki(AssemblyInfo.GetGitHash(), io);
                ConsoleLog.Info("Basic Wiki [Ready]");
                io = new SimpleIO();
            }
            Config = MakeJsonConfig.GetDefault();
            if (helpers.notempty(json_file) == false)
            {
                json_file = "mybot.json";
                ConsoleLog.Warn("Using: mybot.json as the config");
            }
            bool ok_to_try_start = false;
            if (SimpleIO.FileType(json_file, "json") == true)
            {
                if (io.Exists(json_file))
                {
                    string json = io.ReadFile(json_file);
                    if (json.Length > 0)
                    {
                        try
                        {
                            Config          = JsonConvert.DeserializeObject <JsonConfig>(json);
                            ok_to_try_start = true;
                        }
                        catch (Exception e)
                        {
                            ConsoleLog.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);
                            Config = new JsonConfig();
                            io.WriteJsonConfig(MakeJsonConfig.GetDefault(), json_file);
                        }
                    }
                    else
                    {
                        ConsoleLog.Warn("Json config is empty creating an empty one for you");
                        io.WriteJsonConfig(MakeJsonConfig.GetDefault(), json_file);
                    }
                }
                else
                {
                    ConsoleLog.Warn("Json config does not Exist creating it for you");
                    io.WriteJsonConfig(MakeJsonConfig.GetDefault(), json_file);
                }
            }
            else
            {
                ConsoleLog.Crit("you must select a .json file for config!");
            }
            if (ok_to_try_start == true)
            {
                Config = MakeJsonConfig.http_config_check(Config);
                if (Config.HttpAsCnC == true)
                {
                    new HttpCnC(Config);
                }
                else
                {
                    new CliExitOnLogout(Config);
                }
            }
        }
Esempio n. 7
0
        public CliHardware(string[] args)
        {
            SimpleIO   io         = new SimpleIO();
            JsonConfig Config     = new JsonConfig();
            string     loadFolder = "debug";
            string     json_file  = "bot.json";

#if DEBUG
            LogFormater.Debug("!! RUNNING IN DEBUG !!");
#else
            LogFormater.Status("Hardware config");
            if (args.Length == 1)
            {
                loadFolder = args[0];
            }
            else
            {
                loadFolder = "default";
                io.ChangeRoot("default");
                LogFormater.Warn("Using: using default folder");
            }
#endif
            io.ChangeRoot(loadFolder);
            if (SimpleIO.DirExists("wiki") == false)
            {
                LogFormater.Info("Basic Wiki [Creating]");
                new DebugModeCreateWiki(AssemblyInfo.GetGitHash(), io);
                LogFormater.Info("Basic Wiki [Ready]");
                io = new SimpleIO();
            }
            bool ok_to_try_start = false;
            if (SimpleIO.FileType(json_file, "json") == true)
            {
                if (io.Exists(json_file))
                {
                    string json = io.ReadFile(json_file);
                    if (json.Length > 0)
                    {
                        try
                        {
                            Config          = JsonConvert.DeserializeObject <JsonConfig>(json);
                            ok_to_try_start = true;
                        }
                        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 + "");
                            io.MarkOld(json_file);
                            Config = new JsonConfig();
                            io.WriteJsonConfig(MakeJsonConfig.GetDefault(), json_file);
                        }
                    }
                    else
                    {
                        LogFormater.Warn("Json config is empty creating an empty one for you");
                        io.WriteJsonConfig(MakeJsonConfig.GetDefault(), json_file);
                    }
                }
                else
                {
                    LogFormater.Warn("Json config does not Exist creating it for you");
                    io.WriteJsonConfig(MakeJsonConfig.GetDefault(), json_file);
                }
            }
            else
            {
                LogFormater.Crit("you must select a .json file for config! example \"BetterSecondBot.exe mybot\" will use the mybot.json file!");
            }
            if (ok_to_try_start == true)
            {
                Config = MakeJsonConfig.Http_config_check(Config);
                new Discord_super(Config, false, loadFolder);
            }
        }