コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context_name"></param>
        /// <param name="stringCodeReader"></param>
        /// <returns></returns>
        public override object Read(string context_name, System.IO.TextReader stringCodeReader, OutputDelegate WritResulteLine)
        {
            CmdResult res  = null;
            int       line = 0;

            while (stringCodeReader.Peek() != -1)
            {
                line++;
                res = BotClient.ExecuteCommand(stringCodeReader.ReadLine(), context_name, WriteLine, CMDFLAGS.ForceCompletion);
            }
            return(res);
        } // method: Read
コード例 #2
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length < 1)
            {
                return(ShowUsage());
            }
            string cmd = args.GetString("command");

            //return ClientManager.DoCommandAll()
            // Make an immutable copy of the Clients dictionary to safely iterate over
            int[] completed   = { 0 };
            var   BotClients  = ClientManager.BotClients;
            int   count       = BotClients.Count;
            var   fromAgentID = args.CallerAgent;

            if (count == 0)
            {
                return(ClientManager.ExecuteSystemCommand(cmd, fromAgentID, WriteLine, args.CmdFlags));
            }
            CmdResult[] results   = new CmdResult[count];
            int[]       clientNum = { 0 };
            foreach (BotClient client in BotClients)
            {
                clientNum[0]++;
                ThreadPool.QueueUserWorkItem(
                    (WaitCallback)
                    delegate(object state)
                {
                    BotClient testClient  = (BotClient)state;
                    results[clientNum[0]] = testClient.ExecuteCommand(cmd, fromAgentID, WriteLine, args.CmdFlags);
                    ++completed[0];
                },
                    client);
            }
            while (completed[0] < count)
            {
                Thread.Sleep(50);
            }
            foreach (var r in results)
            {
                if (r != null)
                {
                    return(r);
                }
            }
            return(results[0]);
        }
コード例 #3
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length < 2)
            {
                return(ShowUsage());
            }
            BotClient oBotClient = ClientManager.GetBotByName(args.GetString("avatar"));

            if (oBotClient != TheBotClient)
            {
                return(Success("not for me"));
            }
            string botcmd = args.GetString("command");

            return
                (Success("tobot " + oBotClient + " " +
                         oBotClient.ExecuteCommand(botcmd, args.CallerAgent, args.Output, args.CmdFlags)));
        }
コード例 #4
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            //base.acceptInput(verb, args);

            BotClient Client   = TheBotClient;
            string    onlyShow = "";

            args.SetValue("--kill", true);
            bool thread   = args.IsTrue("--thread");
            bool queue    = args.IsTrue("--queue");
            bool all      = args.IsTrue("--all");
            bool current  = args.IsTrue("--current");
            bool movement = args.IsTrue("--movement");
            bool pointing = args.IsTrue("--pointing");

            ThreadCommand.ExecuteRequestProc(args, this);
            if (all)
            {
                current  = true;
                movement = true;
                pointing = true;
            }
            if (current && TheSimAvatar.CurrentAction != null)
            {
                WriteLine("Killing " + TheSimAvatar.CurrentAction);
                TheSimAvatar.CurrentAction = null;
                IncrResult("killed", 1);
            }
            if (movement)
            {
                WriteLine("Killing movement");
                WorldSystem.TheSimAvatar.StopMoving();
            }
            if (pointing)
            {
                Client.ExecuteCommand("pointat", args.CallerAgent, WriteLine, CMDFLAGS.Backgrounded);
            }
            return(Success("Stopped " + base.ResultValue("killed")));
        }
コード例 #5
0
        private void btnSay_Click(object sender, EventArgs e)
        {
            string    s  = cbxInput.Text;
            BotClient bc = CogbotGUI.BotClientFor(this.instance);

            if (bc != null)
            {
                WriteLine("cogbot> " + s);
                WriteLine("" + bc.ExecuteCommand(s, e, WriteLine, CMDFLAGS.Foregrounded));
                ClearChatInput();
                return;
            }
            WorldObjects gm = GridMaster;

            if (gm != null)
            {
                WriteLine("gridmaster> " + s);
                WriteLine("" + gm.client.ExecuteCommand(s, e, WriteLine, CMDFLAGS.Foregrounded));
                ClearChatInput();
                return;
            }
            WriteLine("Too early: Could not do " + s);
        }
コード例 #6
0
        public string EvaluateCommand(string cmd)
        {
            String lowerCmd = cmd.ToLower().Trim();

            if (lowerCmd == "bye")
            {
                quitRequested = true;
                return("goodbye");
            }
            if (lowerCmd == "currentevents")
            {
                Server.GetWhileAwayAndClear(tcpStreamWriter);
                return("");
            }
            if (lowerCmd == "hideon")
            {
                EventsEnabled = false;
            }
            if (lowerCmd == "hideoff")
            {
                EventsEnabled = true;
            }
            if (lowerCmd == "filters")
            {
                foreach (var c in filter.Never)
                {
                    tcpStreamWriter.WriteLine("never +" + c);
                }
                foreach (var c in filter.Always)
                {
                    tcpStreamWriter.WriteLine("always +" + c);
                }
                return("use: [always|never] [+|-]Verb");
            }
            if (lowerCmd.StartsWith("always"))
            {
                lowerCmd = lowerCmd.Substring(6).TrimStart();
                if (lowerCmd.StartsWith("+"))
                {
                    lowerCmd = lowerCmd.Substring(1).TrimStart();
                    filter.Always.Add(lowerCmd);
                    return("added to always: " + lowerCmd);
                }
                if (lowerCmd.StartsWith("-"))
                {
                    lowerCmd = lowerCmd.Substring(1).TrimStart();
                    filter.Always.Remove(lowerCmd);
                    return("removed from always: " + lowerCmd);
                }
            }
            if (lowerCmd.StartsWith("never"))
            {
                lowerCmd = lowerCmd.Substring(6).TrimStart();
                if (lowerCmd.StartsWith("+"))
                {
                    lowerCmd = lowerCmd.Substring(1).TrimStart();
                    filter.Never.Add(lowerCmd);
                    return("added to never: " + lowerCmd);
                }
                if (lowerCmd.StartsWith("-"))
                {
                    lowerCmd = lowerCmd.Substring(1).TrimStart();
                    filter.Never.Remove(lowerCmd);
                    return("removed from never: " + lowerCmd);
                }
            }
            using (StringWriter wl = new StringWriter())
            {
                CmdResult s = botclient.ExecuteCommand(cmd, this, wl.WriteLine, CMDFLAGS.Foregrounded);
                return(wl.ToString() + s);
            }
        }
コード例 #7
0
 private void ExecuteCommand(string text)
 {
     new Thread(() => WriteLine(client.ExecuteCommand(text, this, WriteLine, CMDFLAGS.Foregrounded).ToString())).
     Start();
 }