public CmdResult ExecuteCommand(string text, CMDFLAGS needResult) { // done inside the callee InvokeJoin("ExecuteCommand " + text); OutputDelegate WriteLine = DisplayNotificationInChat; return(ExecuteCommand(text, this, WriteLine, needResult)); }
static public CmdResult DoCmdAct(Command command, string verb, string args, object callerSession, OutputDelegate del, CMDFLAGS needResult) { string cmdStr = "ExecuteActBotCommand " + verb + " " + args; callerSession = SessionToCallerId(callerSession); var cmdr = new CmdRequest(verb, args, callerSession, del, command.GetCmdInfo()); return(DoCmdAct(command, () => command.ExecuteRequestSyn(cmdr), cmdr, cmdStr, needResult) ?? cmdr); }
public void ExecuteCommand(ConsoleWriteLine WriteLine, object session, string cmdline) { while (cmdline.StartsWith("/")) { cmdline = cmdline.Substring(1); } OutputDelegate newOutputDelegate = new OutputDelegate(WriteLine); CmdResult result; var botClient = BotClient; CMDFLAGS needResult = CMDFLAGS.Inherit | CMDFLAGS.IsConsole; try { if (botClient == null) { result = clientManager.ExecuteCommand(cmdline, session, newOutputDelegate, needResult); } else { result = botClient.ExecuteCommand(cmdline, session, newOutputDelegate, needResult); } if (result != null) { WriteLine(result.ToString()); } else { WriteLine("No result returned: {0}", cmdline); } } catch (NoSuchCommand nsc) { WriteLine("NoSuchCommand: {0} => {1}", cmdline, nsc); } catch (Exception nsc) { WriteLine("Exception: {0} => {1}", cmdline, nsc); } }
static public CmdResult DoCmdAct(Command command, Func<CmdResult> task, CmdRequest req, string debugStr, CMDFLAGS flags) { BotClient robot = command._mClient; string sync = command.TaskQueueNameOrNull; bool needResult = (flags & CMDFLAGS.ForceResult) != 0; bool isConsole = (flags & CMDFLAGS.IsConsole) != 0; bool forceAsync = (flags & CMDFLAGS.ForceAsync) != 0; bool forceCompletion = (flags & CMDFLAGS.ForceCompletion) != 0; bool inherit = (flags & CMDFLAGS.Inherit) != 0; bool scriptMode = robot != null && robot.InScriptMode; bool cmdRequestsSync = command.ImpliesSync; bool invokeJoin = scriptMode || cmdRequestsSync; if (needResult) { invokeJoin = true; } if (forceCompletion) { forceAsync = false; } if (forceAsync) { sync = null; needResult = false; invokeJoin = false; } if (invokeJoin) { if (!needResult) { } else { if (robot != null) robot.InvokeJoin(debugStr); } } req.CmdFlags |= flags; if (sync != null) { CmdResult[] res = new CmdResult[1]; ManualResetEvent mre = new ManualResetEvent(false); Abortable tq = null; if (robot == null) { tq = Cogbot.ClientManager.OneAtATimeQueue; } else { tq = robot.GetTaskQueueHandler(sync, true); } tq.Enqueue(() => { try { res[0] = task(); } finally { if (needResult) mre.Set(); } }); if (needResult) mre.WaitOne(); return res[0]; } else { return task(); } //robot.OneAtATimeQueue.Enqueue(cmdStr, () => command.acceptInputWrapper(verb, args, callerID, del)); }
static public CmdResult DoCmdAct(Command command, string verb, string args, object callerSession, OutputDelegate del, CMDFLAGS needResult) { string cmdStr = "ExecuteActBotCommand " + verb + " " + args; callerSession = SessionToCallerId(callerSession); var cmdr = new CmdRequest(verb, args, callerSession, del, command.GetCmdInfo()); return DoCmdAct(command, () => command.ExecuteRequestSyn(cmdr), cmdr, cmdStr, needResult) ?? cmdr; }
public CmdResult ExecuteBotCommand(string text, object session, OutputDelegate WriteLine, CMDFLAGS needResult) { text = ClientManager.GetCommandText(text); try { if (text.StartsWith("(")) { InvokeJoin("ExecuteBotCommand " + text); return ACmdResult.Complete("evalLispString", evalLispString(text).ToString(), true); } text = text.Replace("\"", "").Replace(" ", " "); string verb = text.Split(' ')[0]; verb = verb.ToLower(); Command act = GetCommand(verb, false); if (act != null) { if (act is GridMasterCommand) { if (!WorldSystem.IsGridMaster) { throw new NoSuchCommand("I am not gridMaster " + text + "."); return null; } } if (act is RegionMasterCommand) { if (!IsRegionMaster) { throw new NoSuchCommand("I am not regionMaster " + text + "."); return null; } } try { string args = (text.Length > verb.Length) ? text.Substring(verb.Length + 1) : ""; return DoCmdAct(act, verb, args, session, WriteLine, needResult); } catch (Exception e) { if (e is NoSuchCommand) throw e; LogException("ExecuteBotCommand Command " + text, e); return ACmdResult.Complete("ExecuteBotCommand", "ExecuteBotCommand " + text + "cuased " + e, false); } } else { if (WorldSystem == null || WorldSystem.SimAssetSystem == null) return ACmdResult.Complete(verb, "no world yet for gesture", false); UUID assetID = WorldSystem.SimAssetSystem.GetAssetUUID(text, AssetType.Gesture); if (assetID != UUID.Zero) return ExecuteBotCommand("play " + assetID, session, WriteLine, needResult); assetID = WorldSystem.SimAssetSystem.GetAssetUUID(text, AssetType.Unknown); if (assetID != UUID.Zero) return ExecuteBotCommand("play " + assetID, session, WriteLine, needResult); throw new NoSuchCommand(verb); } } catch (Exception e) { if (e is NoSuchCommand) throw e; LogException("ExecuteBotCommand " + text, e); return null; } }
public CmdResult ExecuteCommand(string text, object session, OutputDelegate WriteLine, CMDFLAGS needResult) { text = ClientManager.GetCommandText(text); try { return ExecuteBotCommand(text, session, WriteLine, needResult); } catch (NoSuchCommand) { } try { return ClientManager.ExecuteSystemCommand(text, session, WriteLine, needResult); } catch (NoSuchCommand) { } string verb = Parser.ParseArguments(text)[0]; Command act = GetCommand(verb, false); if (act != null) { if (act is GridMasterCommand) { if (!WorldSystem.IsGridMaster) { throw new NoSuchCommand("I am not gridMaster " + text + "."); return null; } } if (act is RegionMasterCommand) { if (!IsRegionMaster) { WriteLine("I am not regionMaster " + text + "."); } } string pargs = (text.Length > verb.Length) ? text.Substring(verb.Length + 1) : ""; return BotClient.DoCmdAct(act, verb, pargs, BotClient.SessionToCallerId(session), WriteLine, needResult); } throw new NoSuchCommand("I don't understand the ExecuteCommand " + text + "."); }
public CmdResult ExecuteSystemCommand(string text, object session, OutputDelegate WriteLine, CMDFLAGS needResult) { text = GetCommandText(text); try { { string verb = Parser.ParseArguments(text)[0]; var cmd = GetCommand(verb, false); if (cmd!=null) { string pargs = (text.Length > verb.Length) ? text.Substring(verb.Length + 1) : ""; return BotClient.DoCmdAct(cmd, verb, pargs, BotClient.SessionToCallerId(session), WriteLine, needResult); } throw new NoSuchCommand(verb); } } catch (Exception e) { if (e is NoSuchCommand) throw e; string newVariable = "ClientManager: " + text + " caused " + e; WriteLine(newVariable); return ACmdResult.Complete(text, newVariable, false); } }
private CmdResult ExecuteBotsCommand(string text, object session, OutputDelegate WriteLine, CMDFLAGS needResult) { text = GetCommandText(text); var OnlyOneCurrentBotClient = GetCurrentBotClient(WriteLine); if (OnlyOneCurrentBotClient != null) { return OnlyOneCurrentBotClient.ExecuteBotCommand(text, session, WriteLine, needResult); } var BotClients = this.BotClients; string res = null; int success = 0; int failure = 0; string verb = text; foreach (BotClient currentClient in BotClients) if (currentClient != null) { CmdResult t = currentClient.ExecuteBotCommand(text, session, WriteLine, needResult); if (BotClients.Count < 2) return t; if (t == null) continue; if (t.Success) { success++; } else { failure++; } res += t.ToString(); if (!string.IsNullOrEmpty(res)) { res += "\n"; } } if (success == 0) { return ACmdResult.Complete(verb, res + " " + failure + " failures ", false); } if (failure > 0) { return ACmdResult.Complete(verb, res + " " + failure + " failures and " + success + " successes", false); } return ACmdResult.Complete(verb, res + " " + success + " successes", true); }
public CmdResult ExecuteCommand(string text, object session, OutputDelegate WriteLine, CMDFLAGS needResult) { text = ClientManager.GetCommandText(text); try { return(ExecuteBotCommand(text, session, WriteLine, needResult)); } catch (NoSuchCommand) { } try { return(ClientManager.ExecuteSystemCommand(text, session, WriteLine, needResult)); } catch (NoSuchCommand) { } string verb = Parser.ParseArguments(text)[0]; Command act = GetCommand(verb, false); if (act != null) { if (act is GridMasterCommand) { if (!WorldSystem.IsGridMaster) { throw new NoSuchCommand("I am not gridMaster " + text + "."); return(null); } } if (act is RegionMasterCommand) { if (!IsRegionMaster) { WriteLine("I am not regionMaster " + text + "."); } } string pargs = (text.Length > verb.Length) ? text.Substring(verb.Length + 1) : ""; return(BotClient.DoCmdAct(act, verb, pargs, BotClient.SessionToCallerId(session), WriteLine, needResult)); } throw new NoSuchCommand("I don't understand the ExecuteCommand " + text + "."); }
public static CmdResult ExecuteRequestProc(CmdRequest args, Command thizcmd) { var TheBotClient = thizcmd.TheBotClient; OutputDelegate WriteLine = thizcmd.WriteLine; bool thread = args.IsTrue("--thread"); bool queue = args.IsTrue("--queue"); bool all = args.IsTrue("--all"); bool kill = args.IsTrue("--kill"); bool asyc = args.IsTrue("--async") || thread; TimeSpan wait; ManualResetEvent mre = null; if (args.TryGetValue("--wait", out wait)) { mre = new ManualResetEvent(false); } bool newDebug = args.IsTrue("--debug"); bool changeDebug = newDebug || args.IsTrue("--nodebug"); bool createFresh = false; string id = args.Length == 0 ? "list" : GetTaskID(args, out createFresh); id = (id == "list") ? "" : id; int n = 0; int found = 0; if (id == "" || kill || changeDebug) { List <string> list = new List <string>(); lock (TaskQueueHandler.TaskQueueHandlers) { var atq = TheBotClient != null ? TheBotClient.AllTaskQueues() : ClientManager.SingleInstance.AllTaskQueues(); foreach (var queueHandler in atq) { if (!queueHandler.MatchesId(id)) { continue; } bool isQueue = queueHandler.Impl == queueHandler; if (isQueue) { found++; } else { n++; } if (changeDebug) { queueHandler.DebugQueue = newDebug; } if (queueHandler.IsAlive) { string str = queueHandler.ToDebugString(true); if (kill) { if (!all) { if (!isQueue && !thread || isQueue && !queue) { WriteLine("Not killing " + str); continue; } } queueHandler.Abort(); str = "Killing " + str; thizcmd.IncrResult("killed", 1); } WriteLine(str); } else { list.Add(queueHandler.ToDebugString(true)); } } } foreach (var s in list) { WriteLine(s); } } if (kill && createFresh) { return(thizcmd.Failure("Cannot create and kill in the same operation")); } string[] cmdS; args.TryGetValue("command", out cmdS); thizcmd.IncrResult("taskqueues", found); thizcmd.IncrResult("threads", n); if (cmdS == null || cmdS.Length == 0) { return(thizcmd.Success("TaskQueueHandlers: " + found + ", threads: " + n)); } /// task is killed if request.. now making a new one string cmd = Parser.Rejoin(cmdS, 0); bool needResult = mre != null; CmdResult[] result = null; if (createFresh) { needResult = false; } if (needResult) { result = new CmdResult[1]; } CMDFLAGS flags = needResult ? CMDFLAGS.ForceResult : CMDFLAGS.Inherit; if (asyc) { flags |= CMDFLAGS.ForceAsync; } ThreadStart task = () => { try { var res = TheBotClient.ExecuteCommand(cmd, args.CallerAgent, args.Output, flags); if (result != null) { result[0] = res; } } catch (Exception) { throw; } }; string message = TheBotClient.CreateTask(id, task, cmd, createFresh, false, mre, WriteLine); thizcmd.SetResult("taskid", id); if (mre != null) { if (!mre.WaitOne(wait)) { return(thizcmd.Failure("Timeout: " + message)); } if (result == null) { return(thizcmd.Success(message)); } return(result[0] ?? thizcmd.Success(message)); } return(thizcmd.Success(message)); }
public CmdResult ExecuteCommand(string s, object session, OutputDelegate outputDelegate, CMDFLAGS needResult) { string verb = GetType().Name; StringWriter sw = new StringWriter(); if (s == null) { return(ACmdResult.Complete(verb, "null cmd", false)); } s = s.Trim(); if (s == "") { return(ACmdResult.Complete(verb, "empty cmd", false)); } if (TheBot.useServitor) { TheBot.updateRTP2Sevitor(); string input = s; string res = ""; input = input.Replace("aiml @withuser null -", ""); input = input.Replace("withuser null", ""); input = input.Replace("aiml @", ""); input = input.Replace("- ?", ""); bool r = true; TheBot.servitor.curBot.saySapi = true; TheBot.servitor.curBot.sayProcessor = new sayProcessorDelegate(webSayResponse); if (input.Length > 1) { res = TheBot.servitor.respondToChat(input, TheBot.LastUser); if ((res != null) && (res.Length > 0)) { responseQueue.Enqueue(res); } res = ""; // Give the servitor a chance to do something; int ticks = 0; while ((ticks < 25) && (responseQueue.Count == 0)) { Thread.Sleep(200); ticks++; } while (responseQueue.Count > 0) { res += responseQueue.Dequeue() + " "; } if (outputDelegate != null) { outputDelegate(res); } WriteLine(res); TheBot.updateServitor2RTP(); } else { res = ""; // Give the servitor a chance to do something; int ticks = 0; while ((ticks < 3) && (responseQueue.Count == 0)) { Thread.Sleep(200); ticks++; } while (responseQueue.Count > 0) { res += responseQueue.Dequeue() + " "; } if (outputDelegate != null) { outputDelegate(res); } WriteLine(res); } return(ACmdResult.Complete(verb, res, r)); } else { if (s.StartsWith("aiml")) { s = s.Substring(4).Trim(); if (s.StartsWith("@ ")) { s = "@withuser" + s.Substring(1); } } if (!s.StartsWith("@")) { s = "@" + s; } // sw.WriteLine("AIMLTRACE " + s); User myUser = null;// TheBot.LastUser; //OutputDelegate del = outputDelegate ?? sw.WriteLine; bool r = TheBot.BotDirective(myUser, s, sw.WriteLine); sw.Flush(); string res = sw.ToString(); // for now legacy //res = res.Replace("menevalue=", "mene value="); if (outputDelegate != null) { outputDelegate(res); } WriteLine(res); return(ACmdResult.Complete(verb, res, r)); } }
static public CmdResult DoCmdAct(Command command, Func <CmdResult> task, CmdRequest req, string debugStr, CMDFLAGS flags) { BotClient robot = command._mClient; string sync = command.TaskQueueNameOrNull; bool needResult = (flags & CMDFLAGS.ForceResult) != 0; bool isConsole = (flags & CMDFLAGS.IsConsole) != 0; bool forceAsync = (flags & CMDFLAGS.ForceAsync) != 0; bool forceCompletion = (flags & CMDFLAGS.ForceCompletion) != 0; bool inherit = (flags & CMDFLAGS.Inherit) != 0; bool scriptMode = robot != null && robot.InScriptMode; bool cmdRequestsSync = command.ImpliesSync; bool invokeJoin = scriptMode || cmdRequestsSync; if (needResult) { invokeJoin = true; } if (forceCompletion) { forceAsync = false; } if (forceAsync) { sync = null; needResult = false; invokeJoin = false; } if (invokeJoin) { if (!needResult) { } else { if (robot != null) { robot.InvokeJoin(debugStr); } } } req.CmdFlags |= flags; if (sync != null) { CmdResult[] res = new CmdResult[1]; ManualResetEvent mre = new ManualResetEvent(false); Abortable tq = null; if (robot == null) { tq = Cogbot.ClientManager.OneAtATimeQueue; } else { tq = robot.GetTaskQueueHandler(sync, true); } tq.Enqueue(() => { try { res[0] = task(); } finally { if (needResult) { mre.Set(); } } }); if (needResult) { mre.WaitOne(); } return(res[0]); } else { return(task()); } //robot.OneAtATimeQueue.Enqueue(cmdStr, () => command.acceptInputWrapper(verb, args, callerID, del)); }
public CmdResult ExecuteBotCommand(string text, object session, OutputDelegate WriteLine, CMDFLAGS needResult) { text = ClientManager.GetCommandText(text); try { if (text.StartsWith("(")) { InvokeJoin("ExecuteBotCommand " + text); return(ACmdResult.Complete("evalLispString", evalLispString(text).ToString(), true)); } text = text.Replace("\"", "").Replace(" ", " "); string verb = text.Split(' ')[0]; verb = verb.ToLower(); Command act = GetCommand(verb, false); if (act != null) { if (act is GridMasterCommand) { if (!WorldSystem.IsGridMaster) { throw new NoSuchCommand("I am not gridMaster " + text + "."); return(null); } } if (act is RegionMasterCommand) { if (!IsRegionMaster) { throw new NoSuchCommand("I am not regionMaster " + text + "."); return(null); } } try { string args = (text.Length > verb.Length) ? text.Substring(verb.Length + 1) : ""; return(DoCmdAct(act, verb, args, session, WriteLine, needResult)); } catch (Exception e) { if (e is NoSuchCommand) { throw e; } LogException("ExecuteBotCommand Command " + text, e); return(ACmdResult.Complete("ExecuteBotCommand", "ExecuteBotCommand " + text + "cuased " + e, false)); } } else { if (WorldSystem == null || WorldSystem.SimAssetSystem == null) { return(ACmdResult.Complete(verb, "no world yet for gesture", false)); } UUID assetID = WorldSystem.SimAssetSystem.GetAssetUUID(text, AssetType.Gesture); if (assetID != UUID.Zero) { return(ExecuteBotCommand("play " + assetID, session, WriteLine, needResult)); } assetID = WorldSystem.SimAssetSystem.GetAssetUUID(text, AssetType.Unknown); if (assetID != UUID.Zero) { return(ExecuteBotCommand("play " + assetID, session, WriteLine, needResult)); } throw new NoSuchCommand(verb); } } catch (Exception e) { if (e is NoSuchCommand) { throw e; } LogException("ExecuteBotCommand " + text, e); return(null); } }
public CmdResult ExecuteCommand(string text, CMDFLAGS needResult) { // done inside the callee InvokeJoin("ExecuteCommand " + text); OutputDelegate WriteLine = DisplayNotificationInChat; return ExecuteCommand(text, this, WriteLine, needResult); }
private void Self_OnMessage(string FromAgentName, UUID FromAgentID, UUID ToAgentID, string Message, UUID IMSessionID, bool GroupIM, UUID RegionID, Vector3 Position, InstantMessageDialog Dialog, ChatType Type, EventArgs origin) { if (Dialog == InstantMessageDialog.GroupNotice) { GroupIM = true; } BotPermissions perms = GetSecurityLevel(FromAgentID, FromAgentName); // Received an IM from someone that is authenticated if (Type == ChatType.OwnerSay) { perms |= BotPermissions.Owner; } bool displayedMessage = false; if (origin is ChatEventArgs && Message.Length > 0 && Dialog == InstantMessageDialog.MessageFromAgent) { WriteLine(String.Format("{0} says, \"{1}\".", FromAgentName, Message)); PosterBoard["/posterboard/onchat"] = Message; if (FromAgentName == Self.Name) { PosterBoard["/posterboard/onchat-said"] = Message; } else { PosterBoard["/posterboard/onchat-heard"] = Message; } } bool groupIM = GroupIM && GroupMembers != null && GroupMembers.ContainsKey(FromAgentID) ? true : false; switch (Dialog) { case InstantMessageDialog.MessageBox: break; case InstantMessageDialog.GroupInvitation: if ((perms & BotPermissions.AcceptGroupAndFriendRequests) != 0) { string groupName = Message; int found = groupName.IndexOf("Group:"); if (found > 0) { groupName = groupName.Substring(found + 6); } Self.InstantMessage(Self.Name, FromAgentID, string.Empty, IMSessionID, InstantMessageDialog.GroupInvitationAccept, InstantMessageOnline.Offline, Self.SimPosition, UUID.Zero, new byte[0]); found = groupName.IndexOf(":"); if (found > 0) { groupName = groupName.Substring(0, found).Trim(); ExecuteCommand("joingroup " + groupName, CMDFLAGS.NoResult); } } break; case InstantMessageDialog.InventoryOffered: break; case InstantMessageDialog.InventoryAccepted: break; case InstantMessageDialog.InventoryDeclined: break; case InstantMessageDialog.GroupVote: break; case InstantMessageDialog.TaskInventoryOffered: break; case InstantMessageDialog.TaskInventoryAccepted: break; case InstantMessageDialog.TaskInventoryDeclined: break; case InstantMessageDialog.NewUserDefault: break; case InstantMessageDialog.SessionAdd: break; case InstantMessageDialog.SessionOfflineAdd: break; case InstantMessageDialog.SessionGroupStart: break; case InstantMessageDialog.SessionCardlessStart: break; case InstantMessageDialog.SessionSend: break; case InstantMessageDialog.SessionDrop: break; case InstantMessageDialog.BusyAutoResponse: break; case InstantMessageDialog.ConsoleAndChatHistory: break; case InstantMessageDialog.Lure911: case InstantMessageDialog.RequestTeleport: if ((perms & BotPermissions.AcceptTeleport) != 0) { TheSimAvatar.StopMoving(); if (RegionID != UUID.Zero) { if (!displayedMessage) { DisplayNotificationInChat("TP to Lure from " + FromAgentName); displayedMessage = true; } SimRegion R = SimRegion.GetRegion(RegionID, gridClient); if (R != null) { Self.Teleport(R.RegionHandle, Position); return; } } DisplayNotificationInChat("Accepting TP Lure from " + FromAgentName); displayedMessage = true; Self.TeleportLureRespond(FromAgentID, IMSessionID, true); } break; case InstantMessageDialog.AcceptTeleport: break; case InstantMessageDialog.DenyTeleport: break; case InstantMessageDialog.GodLikeRequestTeleport: break; // case InstantMessageDialog.CurrentlyUnused: // break; case InstantMessageDialog.GotoUrl: break; case InstantMessageDialog.Session911Start: break; case InstantMessageDialog.FromTaskAsAlert: break; case InstantMessageDialog.GroupNotice: break; case InstantMessageDialog.GroupNoticeInventoryAccepted: break; case InstantMessageDialog.GroupNoticeInventoryDeclined: break; case InstantMessageDialog.GroupInvitationAccept: break; case InstantMessageDialog.GroupInvitationDecline: break; case InstantMessageDialog.GroupNoticeRequested: break; case InstantMessageDialog.FriendshipOffered: if ((perms & BotPermissions.AcceptGroupAndFriendRequests) != 0) { DisplayNotificationInChat("Accepting Friendship from " + FromAgentName); Friends.AcceptFriendship(FromAgentID, IMSessionID); displayedMessage = true; } break; case InstantMessageDialog.FriendshipAccepted: break; case InstantMessageDialog.FriendshipDeclined: break; case InstantMessageDialog.StartTyping: break; case InstantMessageDialog.StopTyping: break; case InstantMessageDialog.MessageFromObject: case InstantMessageDialog.MessageFromAgent: // message from self if (FromAgentName == GetName()) { return; } // message from system if (FromAgentName == "System") { return; } // message from others CommandInstance ci; if (Commands.TryGetValue("im", out ci)) { var whisper = ci.WithBotClient as Cogbot.Actions.Communication.ImCommand; if (whisper != null) { whisper.currentAvatar = FromAgentID; whisper.currentSession = IMSessionID; } } var cea = origin as ChatEventArgs; if ((perms & BotPermissions.ExecuteCommands) != 0) { OutputDelegate WriteLine; if (origin is InstantMessageEventArgs) { WriteLine = new OutputDelegate( (string text, object[] ps) => { string reply0 = DLRConsole.SafeFormat(text, ps); InstantMessage(FromAgentID, reply0, IMSessionID); }); } else { WriteLine = new OutputDelegate( (string text, object[] ps) => { string reply0 = DLRConsole.SafeFormat(text, ps); Talk(reply0, 0, Type); }); } string cmd = Message; CMDFLAGS needResult = CMDFLAGS.Console; if (cmd.StartsWith("cmcmd ")) { cmd = cmd.Substring(6); WriteLine(""); WriteLine(string.Format("invokecm='{0}'", cmd)); ClientManager.DoCommandAll(cmd, FromAgentID, WriteLine); } else if (cmd.StartsWith("cmd ")) { cmd = cmd.Substring(4); WriteLine(string.Format("invoke='{0}'", cmd)); var res = ExecuteCommand(cmd, FromAgentID, WriteLine, needResult); WriteLine("iresult='" + res + "'"); } else if (cmd.StartsWith("/") || cmd.StartsWith("@")) { cmd = cmd.Substring(1); WriteLine(""); WriteLine(string.Format("invoke='{0}'", cmd)); var res = ExecuteCommand(cmd, FromAgentID, WriteLine, needResult); WriteLine("iresult='" + res + "'"); } } if (cea != null && cea.AudibleLevel == ChatAudibleLevel.Barely) { return; } break; default: break; } //if (Dialog != InstantMessageDialog.MessageFromAgent && Dialog != InstantMessageDialog.MessageFromObject) { string debug = String.Format("{0} {1} {2} {3} {4} {5}: {6}", groupIM ? "GroupIM" : "IM", Dialog, Type, perms, FromAgentID, FromAgentName, Helpers.StructToString(origin)); if (!displayedMessage) { DisplayNotificationInChat(debug); displayedMessage = true; } } }
public CmdResult ExecuteCommand(string text, object session, OutputDelegate WriteLine, CMDFLAGS needResult) { text = GetCommandText(text); try { return ExecuteBotsCommand(text, session, WriteLine, needResult); } catch (NoSuchCommand) { } return ExecuteSystemCommand(text, session, WriteLine, needResult); }