public CommandRuleSets DefineCommandSchemas() { CommandRuleSets ruleSets = new CommandRuleSets(); CommandParameterGroupListWithRules cmds = new CommandParameterGroupListWithRules(); CommandParameterGroupWithRules cmdCool = new CommandParameterGroupWithRules(); cmdCool.Add(new CommandParameterWithRules("serverquery") { IsBaseCommand = true }); cmdCool.Add(new CommandParameterWithRules("register") { NameValueSetting = NameValueSetting.NameOnly, }); cmdCool.Add(new CommandParameterWithRules("username") { NameValueSetting = NameValueSetting.ValueOrValueAndName, Required = true, Help = "Your ServerQuery username", Nullable = false, }); cmdCool.Add(new CommandParameterWithRules("password") { NameValueSetting = NameValueSetting.ValueOrValueAndName, Required = true, Help = "Your ServerQuery password", Nullable = false, }); cmds.Add(cmdCool); ruleSets.Add(new CommandRuleSet(this.Name, cmds, ServerQueryUserRegistrationCommand)); return(ruleSets); }
public CommandRuleSets DefineCommandSchemas() { CommandRuleSets ruleSets = new CommandRuleSets(); CommandParameterGroupListWithRules cmdsToSortSubChannels = new CommandParameterGroupListWithRules(); CommandParameterGroupListWithRules cmdsToStoreChannels = new CommandParameterGroupListWithRules(); CommandParameterGroupListWithRules cmdsToPopChannels = new CommandParameterGroupListWithRules(); // Sort channels based on parent channel CommandParameterGroupWithRules cmdSortSubChannels = new CommandParameterGroupWithRules(); cmdSortSubChannels.Add(new CommandParameterWithRules("sort") { IsBaseCommand = true }); //cmdCool.Add(new CommandParameterWithRules("someparam") //{ // NameValueSetting = NameValueSetting.ValueOrValueAndName, // ValueType = TS3_Objects.Entities.ValueType.Integer, //}); cmdsToSortSubChannels.Add(cmdSortSubChannels); // Store a channel CommandParameterGroupWithRules cmdStoreChannel = new CommandParameterGroupWithRules(); cmdStoreChannel.Add(new CommandParameterWithRules("store") { IsBaseCommand = true }); cmdsToStoreChannels.Add(cmdStoreChannel); // Pop a channel CommandParameterGroupWithRules cmdPopChannel = new CommandParameterGroupWithRules(); cmdPopChannel.Add(new CommandParameterWithRules("pop") { IsBaseCommand = true }); cmdsToPopChannels.Add(cmdPopChannel); ruleSets.Add(new CommandRuleSet(this.Name, cmdsToSortSubChannels, UserSortRequest)); ruleSets.Add(new CommandRuleSet(this.Name, cmdsToStoreChannels, UserStoreChannelRequest)); ruleSets.Add(new CommandRuleSet(this.Name, cmdsToPopChannels, UserPopChannelRequest)); return(ruleSets); }
public CommandRuleSets DefineCommandSchemas() { CommandRuleSets ruleSets = new CommandRuleSets(); CommandParameterGroupListWithRules cmds = new CommandParameterGroupListWithRules(); CommandParameterGroupWithRules cmdCool = new CommandParameterGroupWithRules(); cmdCool.Add(new CommandParameterWithRules("coolcommand") { IsBaseCommand = true }); cmdCool.Add(new CommandParameterWithRules("someparam") { NameValueSetting = NameValueSetting.ValueOrValueAndName, ValueType = TS3_Objects.Entities.ValueType.Integer, }); cmds.Add(cmdCool); ruleSets.Add(new CommandRuleSet(this.Name, cmds, Test)); return(ruleSets); }
public void GetSchemas() { // Get command schemas from addons for (int addonIndex = 0; addonIndex < CoreList.Count; addonIndex++) { try { CommandRuleSets cmds = CoreList[addonIndex].DefineCommandSchemas(); if (cmds != null) { foreach (var cmd in cmds) { commands.ValidateAddSchema(cmd); } } } catch (Exception ex) { logger.Error(ex, "addon {0}: Failed to load command schemas", CoreList[addonIndex].Name); } } }
public void UserInitialize(AddonInjections CoreList) { this.ServerQueryConnection = CoreList[typeof(ServerQueryConnection.ServerQueryConnection).Name] as ServerQueryConnection.ServerQueryConnection; ServerQueryConnection.BotCommandAttempt += onBotCommandAttempt; // Hard-coded for now.. //addons.Add(new Core.InputOwner.InputOwnerAddon()); //addons.Add(new Core.Test.TestAddon()); //addons.Add(new Core.ServerQuery.ServerQueryAddon()); List <IAddon> failedAddons = new List <IAddon>(); // Configure each addon with the basic stuff for (int addonIndex = 0; addonIndex < addons.Count; addonIndex++) { try { addons[addonIndex].Configure(this.Subscriber, this.ServerQueryConnection); } catch (Exception) { logger.Error("Removing addon {0}: failed to load during configuration", addons[addonIndex].CoreName); addons.RemoveAt(addonIndex); } } // Wire up any injection requests by the addons to addon manager foreach (IAddon addon in addons) { addon.InjectionRequest += onInjectionRequest; } // Initialize each addon for (int addonIndex = 0; addonIndex < addons.Count; addonIndex++) { try { addons[addonIndex].Initialize(); } catch (Exception ex) { logger.Error(ex, "Removing addon {0}: failed to load during initialization", addons[addonIndex].CoreName); addons.RemoveAt(addonIndex); } } // Let addons define their dependencies for (int addonIndex = 0; addonIndex < addons.Count; addonIndex++) { try { addons[addonIndex].DefineDependencies(); } catch (Exception ex) { logger.Error(ex, "Removing addon {0}: failed to load during dependency definitions", addons[addonIndex].CoreName); addons.RemoveAt(addonIndex); } } // Initialize the dependencies for (int addonIndex = 0; addonIndex < addons.Count; addonIndex++) { try { addons[addonIndex].InitializeDependencies(); } catch (Exception ex) { logger.Error(ex, "Removing addon {0}: failed to load during dependency initialization", addons[addonIndex].CoreName); addons.RemoveAt(addonIndex); } } // Get command schemas from addons for (int addonIndex = 0; addonIndex < addons.Count; addonIndex++) { try { CommandRuleSets cmds = addons[addonIndex].DefineCommandSchemas(); if (cmds != null) { foreach (var cmd in cmds) { commands.ValidateAddSchema(cmd); } } } catch (Exception ex) { logger.Warn(ex, "addon {0}: Could not load command schemas", addons[addonIndex].CoreName); } } }