コード例 #1
0
ファイル: TestAddon.cs プロジェクト: qvazzler/Lyralei
        public CommandRuleSets DefineCommandSchemas()
        {
            CommandRuleSets ruleSets = new CommandRuleSets();
            CommandParameterGroupListWithRules cmds = new CommandParameterGroupListWithRules();

            // This is a command with params
            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);

            // This is a command with params
            CommandParameterGroupWithRules cmdKickall = new CommandParameterGroupWithRules();

            cmdKickall.Add(new CommandParameterWithRules("kickall")
            {
                IsBaseCommand = true
            });
            cmds.Add(cmdKickall);

            ruleSets.Add(new CommandRuleSet(this.Name, cmds, Test));
            return(ruleSets);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: CoreManager.cs プロジェクト: qvazzler/Lyralei
        private void onBotCommandAttempt(object sender, TS3QueryLib.Core.CommandHandling.CommandParameterGroup cmd, TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs e)
        {
            try
            {
                CommandParameterGroupWithRules theCmd = null;
                var theSchema = commands.SingleOrDefault(x => x.Commands.Any(y => (theCmd = (CommandParameterGroupWithRules)y).First().Name == cmd.First().Name));

                if (theSchema != null)
                {
                    // Find owner addon
                    var addon = CoreList.SingleOrDefault(a => a.Name == theSchema.CoreName);

                    // Validate command data
                    theCmd.ValidateAddData(cmd);

                    // Invoke defined method linked to command
                    theSchema.Method.Invoke(new BotCommandEventArgs(theCmd, e));
                }

                // Notify parent
                //onBotCommand.Invoke(sender, new BotCommandEventArgs(theCmd, e));
            }
            catch (Exception ex)
            {
                logger.Warn(ex, "Command failed to execute");

                if (onFailedBotCommand != null)
                {
                    onFailedBotCommand.Invoke(sender, new FailedBotCommandEventArgs(cmd, e));
                }
            }
        }
コード例 #4
0
ファイル: ChannelManager.cs プロジェクト: qvazzler/Lyralei
        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);
        }
コード例 #5
0
 public BotCommandEventArgs(CommandParameterGroupWithRules command, MessageReceivedEventArgs message)
 {
     this.CommandInfo = command;
     this.MessageInfo = message;
 }