private void ServerQueryConnection_BotCommandReceived(object sender, TS3QueryLib.Core.CommandHandling.CommandParameterGroup cmd, TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs e) { logger.Info("Command objects are tricky business! This command was: {0}", cmd[0].Name); if (cmd[0].Name.ToLower() == "kickall") { ServerQueryConnection.QueryRunner.PokeClient(e.InvokerClientId, "Go away, that's dangerous"); ServerQueryConnection.QueryRunner.KickClient(e.InvokerClientId, KickReason.Server); logger.Warn("That's some dangerous stuff, you better leave."); } else if (cmd[0].Name.ToLower() == "coolcommand") { // Both lines below do the same thing, but ServerQueryConnection.TextReply from the AddonBase class tries to make it more convenient for replies :-) //this.ServerQueryConnection.queryRunner.SendTextMessage(MessageTarget.Client, e.InvokerClientId, "That's a nice test you have there.."); ServerQueryConnection.TextReply(e, "That's a nice test you have there.."); CommandParameter someparam = null; if (cmd.Exists(c => (someparam = c).Name == "someparam")) { ServerQueryConnection.TextReply(e, String.Format("Nice, a parameter! BTW, If you encode it, it will look like this: {0}", someparam.EncodedValue)); } } }
public Command(string Name, CommandParameterGroup commandWithParams) { if (commandWithParams == null) { throw new ArgumentException("commandWithParams is null or emtpy", "commandWithParams"); } this.Name = Name; ParameterGroups = commandWithParams; Options = new List <string>(); }
public Command(CommandParameterGroup commandWithParams) { if (commandWithParams == null) { throw new ArgumentException("commandWithParams is null or emtpy", "commandWithParams"); } Name = commandWithParams[0].Name.ToLower(); commandWithParams.RemoveAt(0); ParameterGroups = commandWithParams; Options = new List <string>(); }
public Command(string commandName, params string[] options) { if (commandName.IsNullOrTrimmedEmpty()) { throw new ArgumentException("commandName is null or emtpy", "commandName"); } Name = commandName; ParameterGroups = new CommandParameterGroup(); Options = new List <string>(); if (options != null && options.Length > 0) { foreach (string option in options) { AddOption(option); } } }