Exemplo n.º 1
0
        public void InstallAddon()
        {
            AddonLoader addon = new AddonLoader();

            addon.setFileListDisplay(10);
            try
            {
                addon.LoadAddon();
                if (!string.IsNullOrWhiteSpace(addon.getInstallOutcome()))
                {
                    GlobalFuncs.ConsolePrint("AddonLoader - " + addon.getInstallOutcome(), 3, ConsoleBox);
                }
            }
            catch (Exception)
            {
                if (!string.IsNullOrWhiteSpace(addon.getInstallOutcome()))
                {
                    GlobalFuncs.ConsolePrint("AddonLoader - " + addon.getInstallOutcome(), 2, ConsoleBox);
                }
            }

            if (!string.IsNullOrWhiteSpace(addon.getInstallOutcome()))
            {
                MessageBox.Show(addon.getInstallOutcome());
            }
        }
Exemplo n.º 2
0
        public void ReloadPlugins()
        {
            AddonLoader loader = AddonLoader.GetInstance(this);

            loader.Plugins.Clear();
            loader.LoadAddons(this);
        }
Exemplo n.º 3
0
        private async Task Client_Ready()
        {
            AddonLoader.Load(Client);
            Assembly[]  assemblies     = AppDomain.CurrentDomain.GetAssemblies();
            List <Type> commandClasses = new List <Type>();

            foreach (Assembly assembly in assemblies)
            {
                commandClasses.AddRange(assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(ModuleBase)) && !t.IsAbstract).ToList());
            }

            checkNewUserEntries();
            StatusNotifierService.InitializeService(Me);
            MusicCommands.Initialize(Client);
            RoleManagerService.InitializeHandler(Client, BotConfiguration);
            ApiRequestService.Initialize(BotConfiguration);
            UserManagerService.InitializeHandler(Client);
            await CommandHandlerService.InitializeHandler(Client, BotConfiguration, commandClasses, prefixDictionary, !CredentialManager.OptionalSettings.Contains("CleverApi"));

            CacheService.InitializeHandler();
            VoiceRewardService.InitializeHandler(Client, BotConfiguration, !CredentialManager.OptionalSettings.Contains("CleverApi"));
            switch (startValue)
            {
            case 0:
                //shutdown
                break;

            case 1:
                //restarting
                await Me.SendMessageAsync("I have restored and restarted successfully.");

                break;

            case 2:
                //updating
                //check if an update is nessasarry
                await Me.SendMessageAsync("I at all the new features and restarted successfully.");

                break;

            default:
                break;
            }
            if (!CredentialManager.OptionalSettings.Contains("WeatherApiKey"))
            {
                if (!CredentialManager.OptionalSettings.Contains("WeatherPlace"))
                {
                    MoodDictionary.InitializeMoodDictionary(Client, BotConfiguration);
                    await MoodHandlerService.InitializeHandler(Client, BotConfiguration);
                }
                WeatherSubscriptionService.InitializeWeatherSub(Client, BotConfiguration);
            }
        }
Exemplo n.º 4
0
        public MinecraftHandler(String rules, String kits, String banlist, String playerlist, String adminlist, String config)
        {
            _strRulesList  = rules;
            _strBanList    = banlist;
            _strPlayerList = playerlist;
            try
            {
                Config = XObject <Config> .Load(Config.ConfigFolder + Config.ConfigFile);
            }
            catch
            {
                Config = new Config();
            }
            try
            {
                PricedBlocks = BlockCollection.Load(Config.ConfigFolder + BlockCollection.PricedBlocksFile);
                if (PricedBlocks == null)
                {
                    PricedBlocks = new BlockCollection();
                }
            }
            catch
            {
                PricedBlocks = new BlockCollection();
            }
            String badBlocksFile = Path.Combine(Config.ConfigFolder, BlockCollection.BadBlocksFile);

            if (!File.Exists(badBlocksFile))
            {
                new BlockCollection().Save(badBlocksFile);
            }

            Plugins = AddonLoader.GetInstance(this).Plugins;
            timerCommandReader.Interval = 1000;
            timerCommandReader.Enabled  = true;
        }
Exemplo n.º 5
0
        private async Task Client_Ready()
        {
            IServiceProvider services = new ServiceCollection()
                                        .AddSingleton(Client)
                                        .AddSingleton <CleverbotApiHandler>()
                                        .AddSingleton <ColornamesApiHandler>()
                                        .AddSingleton <KonachanApiHandler>()
                                        .AddSingleton <WeatherApiHandler>()
                                        .AddSingleton <WikipediaApiHandler>()
                                        .AddSingleton(CredentialManager)
                                        .BuildServiceProvider();

            AddonLoader.Load(Client);
            Assembly[]  assemblies     = AppDomain.CurrentDomain.GetAssemblies();
            List <Type> commandClasses = new List <Type>();

            foreach (Assembly assembly in assemblies)
            {
                commandClasses.AddRange(assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(ModuleBase)) && !t.IsAbstract).ToList());
            }
            VoiceRewardService.InitializeHandler(Client, BotConfiguration, !CredentialManager.OptionalSettings.Contains("CleverApi"));
            checkNewUserEntries();
            StatusNotifierService.InitializeService(Me);
            MusicCommands.Initialize(Client);
            RoleManagerService.InitializeHandler(Client, BotConfiguration);
            UserManagerService.InitializeHandler(Client, fileLogger);
            await CommandHandlerService.InitializeHandler(Client, BotConfiguration, commandClasses, prefixDictionary, !CredentialManager.OptionalSettings.Contains("CleverApi"), fileLogger, services);

            CacheService.InitializeHandler();
            switch (startValue)
            {
            case 0:
                //shutdown
                break;

            case 1:
                //restarting
                await Me.SendMessageAsync("I have restored and restarted successfully.");

                break;

            case 2:
                //updating
                //check if an update is nessasarry
                await Me.SendMessageAsync("I at all the new features and restarted successfully.");

                break;

            default:
                break;
            }
            if (!CredentialManager.OptionalSettings.Contains("WeatherApiKey"))
            {
                if (!CredentialManager.OptionalSettings.Contains("WeatherPlace"))
                {
                    MoodDictionary.InitializeMoodDictionary(Client, BotConfiguration);
                    await MoodHandlerService.InitializeHandler(Client, BotConfiguration, services.GetRequiredService <WeatherApiHandler>(), fileLogger);
                }
                WeatherSubscriptionService.InitializeWeatherSub(Client, BotConfiguration, services.GetRequiredService <WeatherApiHandler>());
            }
            consoleLogger.Info($"Addons loaded: {AddonLoader.LoadedAddonsCount}");
            consoleLogger.Info($"User loaded: {DatabaseAccess.Instance.Users.Count}");
            consoleLogger.Info($"Registered guilds: {Client.Guilds.Count}");
            consoleLogger.Info($"Bot start up time: {(DateTime.Now - startTime).TotalSeconds} s");
        }