public void Initialize(PokeBotRunner runner, PokeBotConfig cfg) { Runner = runner; Config = cfg; ReloadStatus(); L_Description.Text = string.Empty; }
public Main() { InitializeComponent(); PokeTradeBot.SeedChecker = new Z3SeedSearchHandler <PK8>(); if (File.Exists(ConfigPath)) { var lines = File.ReadAllText(ConfigPath); var prog = JsonConvert.DeserializeObject <ProgramConfig>(lines); RunningEnvironment = new PokeBotRunnerImpl(prog.Hub); foreach (var bot in prog.Bots) { bot.Initialize(); AddBot(bot); } } else { var hub = new PokeTradeHubConfig(); RunningEnvironment = new PokeBotRunnerImpl(hub); hub.Folder.CreateDefaults(WorkingDirectory); } LoadControls(); Task.Run(BotMonitor); }
private static bool AddBot(PokeBotRunner env, PokeBotConfig cfg) { if (!cfg.IsValidIP() && cfg.ConnectionType == ConnectionType.WiFi) { Console.WriteLine($"{cfg.IP}'s config is not valid."); return(false); } else if (!cfg.IsValidUSBIndex() && cfg.ConnectionType == ConnectionType.USB) { Console.WriteLine($"{cfg.UsbPortIndex}'s config is not valid."); return(false); } var newbot = env.CreateBotFromConfig(cfg); try { env.Add(newbot); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); return(false); } Console.WriteLine($"Added: {cfg.IP}: {cfg.InitialRoutine}"); return(true); }
public SysCord(PokeBotRunner <T> runner) { Runner = runner; Hub = runner.Hub; Manager = new DiscordManager(Hub.Config.Discord); SysCordSettings.Manager = Manager; SysCordSettings.HubConfig = Hub.Config; _client = new DiscordSocketClient(new DiscordSocketConfig { // How much logging do you want to see? LogLevel = LogSeverity.Info, // If you or another service needs to do anything with messages // (eg. checking Reactions, checking the content of edited/deleted messages), // you must set the MessageCacheSize. You may adjust the number as needed. MessageCacheSize = 100, AlwaysDownloadUsers = true, }); _commands = new CommandService(new CommandServiceConfig { // Again, log level: LogLevel = LogSeverity.Info, // This makes commands get run on the task thread pool instead on the websocket read thread. // This ensures long running logic can't block the websocket connection. DefaultRunMode = Hub.Config.Discord.AsyncCommands ? RunMode.Async : RunMode.Sync, // There's a few more properties you can set, // for example, case-insensitive commands. CaseSensitiveCommands = false, }); // Subscribe the logging handler to both the client and the CommandService. _client.Log += Log; _commands.Log += Log; // Setup your DI container. _services = ConfigureServices(); }