public override CmdResult ExecuteRequest(CmdRequest args) { int argsUsed; TheSimAvatar.StopMoving(); return(Success(string.Format("Stopped moving"))); }
public override CmdResult ExecuteRequest(CmdRequest args) { if (args.Length < 1) { return(ShowUsage()); // " goto sim/x/y/z"; } int argsUsed; SimPosition position = WorldSystem.GetVector(args, out argsUsed); if (position == null) { return(Failure("Teleport - Cannot resolve to a location: " + args.str)); } SimPathStore ps = position.PathStore; ulong handle = SimRegion.GetRegionHandle(ps); TheSimAvatar.StopMoving(); if (Client.Self.Teleport(handle, position.SimPosition)) { return(Success("Teleported to " + Client.Network.CurrentSim)); } else { return(Failure("Teleport failed: " + Client.Self.TeleportMessage)); } }
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; } } }
private void acceptInput0(string verb, Parser parser) { String[] args = parser.GetProperty("to"); string ToS = Parser.Rejoin(args, 0); if (String.IsNullOrEmpty(ToS)) { ToS = parser.str; } int argUsed; if (ToS == "home") { Client.Self.GoHome(); AddSuccess("teleporting home"); return; } SimPosition pos = WorldSystem.GetVector(args, out argUsed); if (argUsed > 0) { Vector3d global = pos.GlobalPosition; WriteLine("Teleporting to " + pos + "..."); float x, y; TheSimAvatar.StopMoving(); bool res = Client.Self.Teleport( SimRegion.GlobalPosToRegionHandle((float)global.X, (float)global.Y, out x, out y), pos.SimPosition, pos.SimPosition); if (res) { AddSuccess("Teleported to " + pos); } else { Failure("Teleport Failed to " + pos); } return; } char[] splitchar = null; if (ToS.Contains("/")) { splitchar = new char[] { '/' }; } string[] tokens = ToS.Split(splitchar); if (tokens.Length == 0) { WriteLine("Provide somewhere to teleport to."); } else { Vector3 coords = new Vector3(128, 128, 40); string simName = ""; //CurSim.Name; bool ifCoordinates = false; if (tokens.Length >= 3) { try { coords.X = float.Parse(tokens[tokens.Length - 3]); coords.Y = float.Parse(tokens[tokens.Length - 2]); coords.Z = float.Parse(tokens[tokens.Length - 1]); ifCoordinates = true; } catch (Exception e) { } } if (!ifCoordinates) { for (int i = 0; i < tokens.Length; i++) { simName += tokens[i] + " "; } simName = simName.Trim(); } else { for (int i = 0; i < tokens.Length - 3; i++) { simName += tokens[i] + " "; } simName = simName.Trim(); } { if (String.IsNullOrEmpty(simName)) { simName = Client.Network.CurrentSim.Name; } TeleportFinished.Reset(); Client.Self.TeleportProgress += On_Teleport; WriteLine("Trying to teleport to " + simName + " " + coords); Client.Self.Teleport(simName, coords); // wait 30 seconds if (!TeleportFinished.WaitOne(30000, false)) { Client.Self.TeleportProgress -= On_Teleport; WriteLine("Timeout on teleport to " + simName + " " + coords); } } } }