public override CmdResult ExecuteRequest(CmdRequest args0) { var args = args0.GetProperty("image"); if (args.Length < 1) { return(ShowUsage()); } UUID AssetID = UUID.Zero; int argsUsed; if (!UUIDTryParse(args, 0, out AssetID, out argsUsed)) { return(Failure("Cant get asset from " + AssetID)); } TheBotClient.InvokeGUI(() => { var v = new SLImageHandler(TheBotClient.TheRadegastInstance, AssetID, AssetID.ToString()) { Dock = DockStyle.Fill }; var f = new RadegastForm(); f.Controls.Add(v); f.Show(); }); return(Success("Done RequestAsset " + AssetID)); }
public override CmdResult ExecuteRequest(CmdRequest args) { if (args.Length < 1) { return(ShowUsage()); } GroupName = String.Empty; for (int i = 0; i < args.Length; i++) { GroupName += args[i] + " "; } GroupName = GroupName.Trim(); GroupUUID = Client.GroupName2UUID(GroupName); if (UUID.Zero != GroupUUID) { TheBotClient.InvokeGUI(() => { Group group = new Group { ID = GroupUUID }; TheBotClient.TheRadegastInstance.MainForm.ShowGroupProfile(group); }); return(Failure("Shown group " + GroupName + " " + GroupUUID)); } return(Failure("Cannot find group " + GroupName)); }
public override CmdResult ExecuteRequest(CmdRequest args) { string to_op = args.GetString("verb"); string objname = args.GetString("target"); if (objname == "") { return(Failure("$bot don't know what object to use.")); } if (to_op == "") { SimObject objToUse; if (WorldSystem.tryGetPrim(objname, out objToUse)) { if ((BotNeeds)TheSimAvatar["CurrentNeeds"] == null) { TheSimAvatar["CurrentNeeds"] = new BotNeeds(90.0f); } SimTypeUsage usage = objToUse.Affordances.GetBestUse((BotNeeds)TheSimAvatar["CurrentNeeds"]); if (usage == null) { //usage = new MoveToLocation(TheSimAvatar, objToUse); return(Failure("$bot don't have a use for " + objToUse + " yet.")); } TheSimAvatar.Do(usage, objToUse); return(Success("used " + objToUse)); } return(Failure("$bot don't know what to do with " + objname)); } WriteLine("Trying to (" + to_op + ") with (" + objname + ")"); TheBotClient.UseInventoryItem(to_op, objname); return(Success("completed to (" + to_op + ") with (" + objname + ")")); }
public override CmdResult ExecuteRequest(CmdRequest args) { string mustHave = ": "; // everything bool detailed = false; if (args.Length > 0) { mustHave = args.str.ToLower().TrimEnd('s') + ": "; detailed = true; } int found = 0; var dictionary = TheBotClient.AllCommands(); foreach (string action in dictionary.Keys) { CommandInfo info = dictionary[action]; string overview = action.TrimEnd('s') + ": " + info.Description; string s = overview + " " + info.Details; if (!s.ToLower().Contains(mustHave)) { continue; } found++; WriteLine("[HELP] " + overview); if (detailed) { WriteLine(info.Details); } } if (found == 0) { WriteLine("I don't know about the verb " + args.GetString("topic") + "."); } return(Success("Help complete")); }
public override CmdResult ExecuteRequest(CmdRequest args) { if (args.Length < 2) { return(ShowUsage()); } string interp = args[0]; return(TheBotClient.ExecuteTask(args.GetString("interp"), new StringReader(args.GetString("code")), WriteLine)); }
public override CmdResult ExecuteRequest(CmdRequest args) { string str; if (args.TryGetValue("commandMask", out str)) { SortedList <string, CommandInfo> all = null; if (TheBotClient != null) { all = TheBotClient.AllCommands(); } else { all = ClientManager.SingleInstance.AllCommands(); } foreach (var cmdinfo in all) { if (cmdinfo.Value.Matches(str)) { WriteLine(cmdinfo.Value.ToPrologString()); } } } WriteLine("GroupNames:"); foreach (var name in WorldSystem.GroupNames) { WriteLine("$" + name); } WriteLine("Filters:"); Type typesearch = typeof(SimObjectImpl); IEnumerable <FilterMember> filters = WorldSystem.GetFilters(typesearch); foreach (FilterMember fmemb in filters) { if (!fmemb.IsCollectionType) { continue; } WriteLine(typeString(fmemb.ReturnType) + " < = " + fmemb.ReflectionMember.Name + (fmemb.IsOf ? "Of" : "") + typeString(fmemb.CastArgTo)); } foreach (FilterMember fmemb in filters) { if (fmemb.IsCollectionType) { continue; } WriteLine("[!]" + fmemb.ReflectionMember.Name + (fmemb.IsOf ? "Of" : "") + (fmemb.PreCompare ? "<>" : "") + typeString(fmemb.CastArgTo)); } return(Success("Help complete")); }
private void EnsureRunning() { if (isDisposing || ThinkThread != null) { return; } ThinkThread = new AAbortable(new Thread(SecondLoop) { Name = "LindenFollow" }, OnDeath); TheBotClient.AddThread(ThinkThread); }
public override CmdResult ExecuteRequest(CmdRequest args) { if (args.Length < 1) { int nfound = 0; foreach (var sl in TheBotClient.SecurityLevels) { nfound++; AddSuccess(string.Format("{0}={1}", sl.Key, sl.Value)); } foreach (var sl in TheBotClient.SecurityLevelsByName) { nfound++; AddSuccess(string.Format("{0}={1}", sl.Key, sl.Value)); } return(Success(nfound + " entries found")); } int argsUsed; List <SimObject> worldSystemGetPrimitives = WorldSystem.GetSingleArg(args, out argsUsed); if (IsEmpty(worldSystemGetPrimitives)) { return(Failure("Cannot find objects from " + args.str)); } BotPermissions who = BotPermissions.Stranger; object value; if (TryEnumParse(typeof(BotPermissions), args, argsUsed, out argsUsed, out value)) { who = (BotPermissions)value; } foreach (var p in worldSystemGetPrimitives) { BotPermissions perms = TheBotClient.GetSecurityLevel(p.ID, null); if (argsUsed == 0) { AddSuccess("Perms for " + p + " was " + perms); continue; } AddSuccess("Perms for " + p + " was " + perms + " now setting to " + who); TheBotClient.SetSecurityLevel(p.ID, null, who); } return(SuccessOrFailure()); }
public override CmdResult ExecuteRequest(CmdRequest args) { int used = 0; if (args.Length == 0) { return(ShowUsage()); } else { if (args.ContainsFlag("listns")) { foreach (var c in MushDLR223.ScriptEngines.ScriptManager.GetNameSpaces(TheBotClient)) { AddSuccess(c); } return(SuccessOrFailure()); } if (args.ContainsFlag("vars") || args.ContainsFlag("list")) { foreach (var c in ScriptManager.GetNameSpaces(TheBotClient)) { foreach (var s in ScriptManager.GetProviders(TheBotClient, c)) { foreach (var s1 in s.SettingNames(TheBotClient, 1)) { GetValue(c, s1, AddSuccess); } } } return(SuccessOrFailure()); } string nss = TheBotClient.GetName(); string varname = args[0]; if (args.tokens.Length > 1) { string[] sa = Parser.SplitOff(args.tokens, 1); string value = string.Join(" ", sa); ScriptManager.AddSetting(TheBotClient, nss, varname, value); } GetValue(nss, varname, AddSuccess); return(SuccessOrFailure()); } }
public override CmdResult ExecuteRequest(CmdRequest args) { int channel = 0; int startIndex = 0; if (args.Length < 1) { return(ShowUsage()); // " say (optional channel) whatever"; } else if (args.Length > 1 && (args[0].StartsWith("/") || args[0].StartsWith("#"))) { if (Int32.TryParse(args[0].Substring(1), out channel)) { startIndex = 1; } } StringBuilder message = new StringBuilder(); for (int i = startIndex; i < args.Length; i++) { message.Append(args[i]); if (i != args.Length - 1) { message.Append(" "); } } string text = message.ToString(); if (text.StartsWith("<") && text.EndsWith(">")) { TheBotClient.XmlTalk(text, WriteLine); return(Success("xmlsaid: " + text)); } if (channel == 0) { TheBotClient.Talk(text); } else { TheBotClient.Talk(text, channel, ChatType.Normal); } return(args.Complete(Name, "said: " + text, true)); }
public override CmdResult ExecuteRequest(CmdRequest args0) { var args = args0.GetProperty("targets"); if (args.Length == 0) { return(ShowUsage()); } int argsUsed; List <string> searchArgs = new List <string> { "family" }; searchArgs.AddRange(args); List <SimObject> PSO = WorldSystem.GetPrimitives(searchArgs.ToArray(), out argsUsed); List <Primitive> PS = new List <Primitive>(); WorldSystem.AsPrimitives(PS, PSO); if (IsEmpty(PS)) { return(Failure("Cannot find objects from " + string.Join(" ", args))); } Primitive rootPim = PS[0]; foreach (Primitive ps in PS) { if (ps.ParentID == 0) { rootPim = ps; } } TheBotClient.InvokeGUI(() => { frmPrimWorkshop pw = new frmPrimWorkshop(TheBotClient.TheRadegastInstance, rootPim.LocalID); // pw.LoadPrims(PS); // pw. pw.Show(); }); return(Success(Name + " on " + PS.Count)); }
public override CmdResult ExecuteRequest(CmdRequest args) { if (args.Length < 1) { return(ShowUsage()); } int argsUsed; foreach (var p in WorldSystem.GetPrimitives(args, out argsUsed)) { if (p is SimAvatar) { SimAvatar a = (SimAvatar)p; AddSuccess("Showing " + a); TheBotClient.InvokeGUI(() => new Radegast.frmProfile(TheBotClient.TheRadegastInstance, a.GetName(), a.ID).Show()); } } return(SuccessOrFailure()); }
public override CmdResult ExecuteRequest(CmdRequest args) { int argsUsed; ICollection <SimObject> objs; bool rightNow = true; if (!args.TryGetValue("targets", out objs)) { objs = (ICollection <SimObject>)WorldSystem.GetAllSimObjects(); rightNow = false; } WriteLine("Unmeshing " + objs.Count); foreach (SimObject o2 in objs) { SimObjectPathFinding o = o2.PathFinding; o.IsWorthMeshing = true; if (rightNow) { o.RemoveCollisions(); } else { o.RemoveCollisions(); } } if (rightNow) { TheSimAvatar.GetSimRegion().GetPathStore(TheSimAvatar.SimPosition).RemoveAllCollisionPlanes(); } else { TheSimAvatar.GetSimRegion().GetPathStore(TheSimAvatar.SimPosition).RemoveAllCollisionPlanes(); } return(TheBotClient.ExecuteCommand("meshinfo", args.CallerAgent, args.Output, args.CmdFlags)); }
public override CmdResult ExecuteRequest(CmdRequest args) { int argsUsed; var keyargs = args.GetProperty("targets"); ICollection <SimObject> objs = WorldSystem.GetPrimitives(keyargs, out argsUsed); bool rightNow = true; if (argsUsed == 0) { objs = (ICollection <SimObject>)WorldSystem.GetAllSimObjects(); rightNow = false; } WriteLine("Meshing " + objs.Count); foreach (SimObject o2 in objs) { SimObjectPathFinding o = o2.PathFinding; o.IsWorthMeshing = true; if (rightNow) { o.AddCollisionsNow(); } else { o.AddCollisions(); } } if (rightNow) { SimRegion.BakeRegions(); } else { Cogbot.WorldPathSystem.MeshingQueue.Enqueue(SimRegion.BakeRegions); } return(TheBotClient.ExecuteCommand("meshinfo", args.CallerAgent, args.Output, args.CmdFlags)); }
public override CmdResult ExecuteRequest(CmdRequest args) { if (args.Length < 2) { return(ShowUsage()); // " im [firstname] [lastname] [message]"; } string message = String.Empty; int argsUsed; SimObject prim; if (WorldSystem.tryGetPrim(args, out prim, out argsUsed)) { for (int ct = argsUsed; ct < args.Length; ct++) { message += args[ct] + " "; } message = message.TrimEnd(); int nfound = 0; //foreach (var prim in PS) { TheBotClient.InstantMessage(prim.ID, message, UUID.Zero); AddSuccess(Name + ": " + prim); nfound++; } if (nfound > 0) { return(Success(Name + " found: " + nfound + " object/agent(s)")); } } // Build the message message = message.TrimEnd(); string ToAvatarName = args[0] + " " + args[1]; int skip = 2; if (ToAvatarName.StartsWith("$")) { ToAvatarName = args[0]; skip = 1; } for (int ct = skip; ct < args.Length; ct++) { message += args[ct] + " "; } if (ToAvatarName.StartsWith("$")) { var col = WorldSystem.ResolveCollection(ToAvatarName, out argsUsed, null); if (col != null) { foreach (object c in col) { AddSuccess("Send to " + c); string s = "" + c; if (s.Length > 0) { var so = WorldObjects.GetSimAvatarFromNameIfKnown(s); if (so != null) { TheBotClient.InstantMessage(so.ID, message, UUID.Zero); } } } return(Success("Total Sent to " + col.Count)); } } UUID found = WorldSystem.GetUserID(ToAvatarName); if (found != UUID.Zero) { if (message.Length > 1023) { message = message.Remove(1023); } TheBotClient.InstantMessage(found, message, UUID.Zero); return(Success("Instant Messaged " + found.ToString() + " with message: " + message)); } UUID ToGroupID = UUID.Zero; ManualResetEvent WaitForSessionStart = new ManualResetEvent(false); if (UUIDTryParse(args, 0, out ToGroupID, out argsUsed)) { string messageGroup = String.Empty; for (int ct = argsUsed; ct < args.Length; ct++) { messageGroup += args[ct] + " "; } messageGroup = messageGroup.TrimEnd(); if (messageGroup.Length > 1023) { messageGroup = messageGroup.Remove(1023); } EventHandler <GroupChatJoinedEventArgs> callback = delegate(object sender, GroupChatJoinedEventArgs e) { if (e.Success) { WriteLine("Joined {0} Group Chat Success!", e.SessionName); WaitForSessionStart.Set(); } else { WriteLine("Join Group Chat failed :("); } }; try { Client.Self.GroupChatJoined += callback; if (!Client.Self.GroupChatSessions.ContainsKey(ToGroupID)) { WaitForSessionStart.Reset(); Client.Self.RequestJoinGroupChat(ToGroupID); } else { WaitForSessionStart.Set(); } if (WaitForSessionStart.WaitOne(20000, false)) { Client.Self.InstantMessageGroup(ToGroupID, messageGroup); } else { return(Failure("Timeout waiting for group session start")); } } finally { Client.Self.GroupChatJoined -= callback; } return(Success("Instant Messaged group " + ToGroupID.ToString() + " with message: " + messageGroup)); } else { return(Failure("failed to instant message group/avatar " + ToAvatarName)); } }
public override CmdResult ExecuteRequest(CmdRequest args) { bool kill = args.IsTrue("--kill"); bool createFresh; string id = GetTaskID(args, out createFresh); if (kill && createFresh) { return(Failure("Cannot create and kill in the same operation")); } int secondsOfSleep; if (!args.TryGetValue("seconds", out secondsOfSleep)) { return(ShowUsage()); } // remove the time string[] cmdS; args.TryGetValue("command", out cmdS); string cmd = Parser.Rejoin(cmdS, 0); ThreadStart thread = () => { try { while (true) { try { Client.ExecuteCommand(cmd, args.CallerAgent, WriteLine, args.CmdFlags); } catch (ThreadAbortException e) { WriteLine("Aborting " + cmd); } catch (Exception e) { WriteLine("Problem with " + cmd + " " + e); return; } Thread.Sleep(secondsOfSleep * 1000); } } finally { try { TheBotClient.RemoveThread(Thread.CurrentThread); } catch (OutOfMemoryException) { } catch (StackOverflowException) { } catch (Exception) { } WriteLine("done with " + cmd); } }; String threadName = "Repeating " + cmd; string message = TheBotClient.CreateTask(id, thread, threadName, createFresh, kill, null, WriteLine); SetResult("taskid", id); return(Success(message)); }
public CmdResult ExecuteRequestTree(CmdRequest args) { BotClient Client = TheBotClient; bool showPLVersionOfHelp = false; if (args.Length == 1) { if (args[0] == "prolog") { showPLVersionOfHelp = true; args = args.AdvanceArgs(1); } if (showPLVersionOfHelp) { foreach (var s in Client.AllCommands().Values) { WriteLine(s.ToPrologString() + "."); } return(Success("showPLVersion(done).")); } } if (args.Length > 0) { int found = 0; foreach (var s in Client.AllCommands().Values) { if (s.Matches(args[0])) { found++; WriteLine(s.Name + ": " + s.Description); } } if (found == 0) { return(Failure("Command " + args[0] + " Does not exist. \"help\" to display all available commands.")); } return(Success("found=" + found)); } StringBuilder result = new StringBuilder(); var CommandTree = new SortedDictionary <string, List <CommandInfo> >(); string cc; foreach (CommandInfo c in TheBotClient.AllCommands().Values) { if (c.Category.Equals(null)) { cc = "Unknown"; } else { cc = c.Category; } if (CommandTree.ContainsKey(cc)) { CommandTree[cc].Add(c); } else { var l = new List <CommandInfo>(); l.Add(c); CommandTree.Add(cc, l); } } foreach (var kvp in CommandTree) { result.AppendFormat(Environment.NewLine + "* {0} Related Commands:" + Environment.NewLine, kvp.Key.ToString()); int colMax = 0; for (int i = 0; i < kvp.Value.Count; i++) { if (colMax >= 120) { result.AppendLine(); colMax = 0; } result.AppendFormat(" {0,-15}", kvp.Value[i].Name); colMax += 15; } result.AppendLine(); } result.AppendLine(Environment.NewLine + "Help [command] for usage/information"); return(Success(result.ToString())); ; }
public override CmdResult ExecuteRequest(CmdRequest args) { //base.acceptInput(verb, args); return(Success(TheBotClient.evalLispString(args.GetString("code")))); }
public override CmdResult ExecuteRequest(CmdRequest args) { //AutoResetEvent are = new AutoResetEvent(false); // AppearanceManager.AppearanceUpdatedCallback callback = (Primitive.TextureEntry te) => are.Set(); try { //Client.Appearance.OnAppearanceUpdated += callback; // base.acceptInput(verb, args); string target = String.Empty; if (args.Length == 0) { return(ShowUsage()); } bool bake = true; string wear = args.str.Trim(); if (args.IsTrue("nobake")) { bake = false; wear = wear.Substring(6).Trim(); } if (args.IsTrue("test")) { bake = true; wear = wear.Substring(4).Trim(); TheBotClient.wearFolder(wear); // if (!are.WaitOne(WEARABLE_TIMEOUT * 2)) // return Success("Timeout wearing " + wear + " " + (bake ? " (baked)" : " (not baked)"); // else return(Success("wearing folder: " + wear + " " + (bake ? " (baked)" : " (not baked)"))); } try { WriteLine("wearing folder: " + wear + " " + (bake ? " (baked)" : " (not baked)")); if (false) { List <InventoryItem> outfit = Client.GetFolderItems(wear); if (outfit != null) { Client.Appearance.ReplaceOutfit(outfit); return(Success(wear)); } WriteLine("no folder found attaching item: " + wear); } string lwear = wear.ToLower(); BotInventoryEval searcher = new BotInventoryEval(Client); InventoryFolder rootFolder = Client.Inventory.Store.RootFolder; if (rootFolder.UUID == UUID.Zero) { return(Success("Cant get roiot folder yet")); } bool found = searcher.findInFolders(rootFolder, (ib) => { if (ib.Name.ToLower() == lwear) { if (ib is InventoryItem) { Client.Appearance.Attach( ib as InventoryItem, AttachmentPoint.Default); return(true); } else { var fldr = ib as InventoryFolder; List <InventoryBase> clientInventoryFolderContents = Client.Inventory. FolderContents(ib.UUID, Client. Self. AgentID, false, true, InventorySortOrder . ByName, 40000); if (clientInventoryFolderContents == null) { return(false); } List <InventoryItem> items = new List <InventoryItem>(); foreach ( InventoryBase content in clientInventoryFolderContents ) { var it = content as InventoryItem; if (it != null) { items.Add(it); } } if (items.Count > 0) { Client.Appearance.ReplaceOutfit( items); return(true); } } } return(false); }); if (found) { return(Success("attaching " + wear)); } return(Failure("did not find " + wear)); // if (!are.WaitOne(WEARABLE_TIMEOUT * 2)) // return Success("Timeout wearing " + wear + " " + (bake ? " (baked)" : " (not baked)"); // else } catch (Exception ex) { return(Failure("(Invalid outfit (" + ex.Message + ")" + args.str + ".")); } } finally { // Client.Appearance.OnAppearanceUpdated -= callback; } }