示例#1
0
        public async Task ServerAction([Remainder] string stringcommand)
        {
            await _shield.Protect(Context, async() =>
            {
                var textChannel = Context.Channel;

                Command?command = await ParseStringCommand(stringcommand, textChannel);

                if (command.HasValue)
                {
                    ResCommand responce = await SendCommand(command.Value);
                    await textChannel.SendMessageAsync($"Server {command.Value.Server.Name} is {responce.action.status}");
                }
            });
        }
示例#2
0
        public static string TestCommandWn(string winname, int Width, int Heigth, string Command, string Arg)
        {
            object ResCommand;
            string txtRes = "";

            // ejecutamos el comando con o sín parámetros
            if (Arg == "")
            {
                try {
                    ResCommand = RunCommand(Command);
                } catch (Exception ex) {
                    Console.WriteLine(ex);
                    return("");
                }
            }
            else
            {
                string[] _args = new string[Arg.Split(';').Length];
                _args = Arg.Split(';');
                //this.textview1.Buffer.Text =(string) hGestorModulo.RunCommand (_Comm, args);
                //object[] Args = new string[1];
                //Args[0] = Arg;
                try {
                    ResCommand = RunCommand(Command, _args);
                } catch (Exception ex) {
                    //horizonte.LogEx.CatchEx (ex,"TestCommand","");
                    return("");
                }
            }
            // intentamos mostrar el resultado
            // puede ser que el método sea void
            String _resType;

            try {
                _resType = ResCommand.GetType().ToString();
            } catch (Exception ex) {
                //horizonte.LogEx.CatchEx (ex,"TestCommand","");
                _resType = "";
            }

            switch (_resType)
            {
            case "":
            case "System.void":
                txtRes = Tr.Catalog.GetString("Cadena vacia");
                break;

            case "System.String":
            case "System.Boolean":
            case "System.Int16":
            case "System.Int32":
            case "System.Int64":
                txtRes = ResCommand.ToString();
                break;

            default:                     // probamos mostrarlo en una ventana
                try {
                    //comprobamos el tamaño de la venta
                    if (Width == 0 || Heigth == 0)
                    {
                        Width  = (ResCommand as Widget).SizeRequest().Width;
                        Heigth = (ResCommand as Widget).SizeRequest().Height;
                    }
                    Gtk.Window _Wres = new horizonte.WidgetWindow((Widget)ResCommand, winname);
                    _Wres.SetSizeRequest(Width, Heigth);
                    _Wres.SetPosition(WindowPosition.Center);

                    (ResCommand as Widget).Show();
                    _Wres.ShowAll();
                    txtRes = "Gtk.Widget";
                } catch (Exception ex) {
                    //horizonte.LogEx.CatchEx (ex,"TestCommand","");
                }
                break;
            }


            return(txtRes);
        }