diff --git a/BSBshared/Json/JsonConfigApi.cs b/BSBshared/Json/JsonConfigApi.cs index 5722a20..bbbe441 100644 --- a/BSBshared/Json/JsonConfigApi.cs +++ b/BSBshared/Json/JsonConfigApi.cs @@ -404,12 +404,12 @@ namespace BetterSecondBotShared.Json { LogFormater.Warn("Http disabled: Http_Host must be vaild or \"docker\" - Given: (" + jsonConfig.Http_Host + ")"); } - else if (jsonConfig.Http_Host == "docker") - { - jsonConfig.Http_Host = "http://*:8080"; - } else - { + { + if (jsonConfig.Http_Host == "docker") + { + jsonConfig.Http_Host = "http://*:80"; + } jsonConfig.Http_Enable = true; } } diff --git a/CLI/HttpService/Inventory.cs b/CLI/HttpService/Inventory.cs index 342960f..0093f71 100644 --- a/CLI/HttpService/Inventory.cs +++ b/CLI/HttpService/Inventory.cs @@ -15,6 +15,18 @@ namespace BetterSecondBot.HttpService public SecondbotInventory(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { } + [Route(HttpVerbs.Get, "/rezobject/{item}/{token}")] + public object rezobject(string item, string token, [FormField] string newname) + { + if (tokens.Allow(token, getClientIP()) == true) + { + bool status = bot.GetCommandsInterface.Call("RezObject", item); + return BasicReply(status.ToString()); + } + return BasicReply("Token not accepted"); + } + + [Route(HttpVerbs.Post, "/rename/{item}/{token}")] public object rename(string item, string token, [FormField] string newname) { diff --git a/CLI/HttpService/Secondbot.cs b/CLI/HttpService/Secondbot.cs index 0f3c000..cb448b9 100644 --- a/CLI/HttpService/Secondbot.cs +++ b/CLI/HttpService/Secondbot.cs @@ -46,29 +46,129 @@ namespace BetterSecondBot.HttpService } [Route(HttpVerbs.Get, "/friends/{token}")] - public object friends(string token) + public object Friends(string token) { - return BasicReply(bot.getJsonFriendlist()); + if (tokens.Allow(token, getClientIP()) == true) + { + return BasicReply(bot.getJsonFriendlist()); + } + return BasicReply("Token not accepted"); } + [Route(HttpVerbs.Get, "/walkto/{x}/{y}/{z}/{token}")] + public object WalkTo(string x, string y, string z, string token) + { + if (tokens.Allow(token, getClientIP()) == true) + { + bool status = bot.GetCommandsInterface.Call("AutoPilot", "<"+x+","+y+","+z+">"); + if (status == true) + { + return BasicReply("Accepted"); + } + return BasicReply("Error Unable to AutoPilot to location"); + } + return BasicReply("Token not accepted"); + } - [Route(HttpVerbs.Get, "/nearme/{token}")] - public object nearme(string token) + + [Route(HttpVerbs.Get, "/gesture/{gesture}/{token}")] + public object Gesture(string gesture, string token) + { + if (tokens.Allow(token, getClientIP()) == true) + { + bool status = bot.GetCommandsInterface.Call("PlayGesture", gesture); + if (status == true) + { + return BasicReply("Accepted"); + } + return BasicReply("Error with gesture"); + } + return BasicReply("Token not accepted"); + } + + [Route(HttpVerbs.Get, "/teleport/{region}/{x}/{y}/{z}/{token}")] + public object Teleport(string region,string x, string y, string z, string token) + { + if (tokens.Allow(token, getClientIP()) == true) + { + bool status = bot.GetCommandsInterface.Call("Teleport", ""+region+"/" + x + "/" + y + "/" + z + ""); + if (status == true) + { + return BasicReply("Accepted"); + } + return BasicReply("Error Unable to Teleport to location"); + } + return BasicReply("Token not accepted"); + } + + + + [Route(HttpVerbs.Get, "/regiontile/{regionname}/{token}")] + public object Regiontile(string regionname, string token) + { + if (tokens.Allow(token, getClientIP()) == true) + { + if (bot.GetClient.Grid.GetGridRegion(regionname, GridLayerType.Objects, out GridRegion region)) + { + return BasicReply(region.MapImageID.ToString()); + } + else + { + return BasicReply("Unable to find region"); + } + } + return BasicReply("Token not accepted"); + } + + [Route(HttpVerbs.Get, "/nearmewithdetails/{token}")] + public object NearmeWithDetails(string token) { if (bot.GetClient.Network.CurrentSim != null) { - Dictionary NearMe = new Dictionary(); + List BetterNearMe = new List(); + Dictionary avcopy = bot.GetClient.Network.CurrentSim.ObjectsAvatars.Copy(); foreach (Avatar av in avcopy.Values) { if (av.ID != bot.GetClient.Self.AgentID) { - NearMe.Add(av.ID, av.Name); + NearMeDetails details = new NearMeDetails(); + details.id = av.ID.ToString(); + details.name = av.Name; + details.x = (int)Math.Round(av.Position.X); + details.y = (int)Math.Round(av.Position.Y); + details.z = (int)Math.Round(av.Position.Z); + details.range = (int)Math.Round(Vector3.Distance(av.Position,bot.GetClient.Self.SimPosition)); + BetterNearMe.Add(details); } } - return BasicReply(JsonConvert.SerializeObject(NearMe)); + return BasicReply(JsonConvert.SerializeObject(BetterNearMe)); } - return BasicReply("Error"); + return BasicReply("Token not accepted"); + } + + + [Route(HttpVerbs.Get, "/nearme/{token}")] + public object Nearme(string token) + { + if (tokens.Allow(token, getClientIP()) == true) + { + if (bot.GetClient.Network.CurrentSim != null) + { + Dictionary NearMe = new Dictionary(); + Dictionary avcopy = bot.GetClient.Network.CurrentSim.ObjectsAvatars.Copy(); + foreach (Avatar av in avcopy.Values) + { + if (av.ID != bot.GetClient.Self.AgentID) + { + NearMe.Add(av.ID, av.Name); + } + } + return BasicReply(JsonConvert.SerializeObject(NearMe)); + } + return BasicReply("Error not in a sim"); + } + return BasicReply("Token not accepted"); } [Route(HttpVerbs.Get, "/hello")] @@ -107,6 +207,32 @@ namespace BetterSecondBot.HttpService return BasicReply("Token not accepted"); } + [Route(HttpVerbs.Get, "/regionname/{token}")] + public object Regionname(string token) + { + if (tokens.Allow(token, getClientIP()) == true) + { + return BasicReply(bot.GetClient.Network.CurrentSim.Name); + } + return BasicReply("Token not accepted"); + } + + + [Route(HttpVerbs.Get, "/location/{token}")] + public object Location(string token) + { + if (tokens.Allow(token, getClientIP()) == true) + { + Dictionary pos = new Dictionary(); + pos.Add("x",(int)Math.Round(bot.GetClient.Self.SimPosition.X)); + pos.Add("y", (int)Math.Round(bot.GetClient.Self.SimPosition.Y)); + pos.Add("z", (int)Math.Round(bot.GetClient.Self.SimPosition.Z)); + return BasicReply(JsonConvert.SerializeObject(pos)); + } + return BasicReply("Token not accepted"); + } + + [Route(HttpVerbs.Post, "/command/{token}")] public async Task command(string token) { @@ -136,5 +262,16 @@ namespace BetterSecondBot.HttpService public string AuthCode { get; set; } } + public class NearMeDetails + { + public string id { get; set; } + public string name { get; set; } + public int x { get; set; } + public int y { get; set; } + public int z { get; set; } + public int range { get; set; } + + } + } diff --git a/CLI/WikiMake/wikimake.cs b/CLI/WikiMake/wikimake.cs index 700cb7e..39b2132 100644 --- a/CLI/WikiMake/wikimake.cs +++ b/CLI/WikiMake/wikimake.cs @@ -499,6 +499,12 @@ namespace BetterSecondBot.WikiMake core.callable.Add(new friends()); core.callable.Add(new nearme()); core.callable.Add(new hello()); + core.callable.Add(new regiontile()); + core.callable.Add(new location()); + core.callable.Add(new regionname()); + core.callable.Add(new nearmewithdetails()); + core.callable.Add(new walkto()); + core.callable.Add(new teleport()); endpoints.Add(core); Endpoint inventory = new Endpoint(); inventory.name = "inventory"; @@ -508,6 +514,7 @@ namespace BetterSecondBot.WikiMake inventory.callable.Add(new realuuid()); inventory.callable.Add(new send()); inventory.callable.Add(new delete()); + inventory.callable.Add(new rezobject()); endpoints.Add(inventory); Endpoint im = new Endpoint(); im.name = "im"; @@ -795,6 +802,18 @@ namespace BetterSecondBot.WikiMake } } + public class gesture : APIcall + { + public override void Setup() + { + about = "Attempts to play a gesture"; + values.Add("gesture", new KeyValuePair("URLARG", "UUID of the gesture")); + returns.Add("Accepted"); + returns.Add("Invaild gesture UUID for arg 1"); + base.Setup(); + } + } + public class command : postAPIcall { public override void Setup() @@ -976,7 +995,7 @@ namespace BetterSecondBot.WikiMake public override void Setup() { about = "fetchs the groupchat history"; - values.Add("group ", new KeyValuePair("URLARG", "UUID of the group")); + values.Add("group", new KeyValuePair("URLARG", "UUID of the group")); returns.Add("Group UUID invaild"); returns.Add("Group Chat"); base.Setup(); @@ -988,7 +1007,7 @@ namespace BetterSecondBot.WikiMake public override void Setup() { about = "sends a message to the groupchat"; - values.Add("group ", new KeyValuePair("URLARG", "UUID of the group")); + values.Add("group", new KeyValuePair("URLARG", "UUID of the group")); values.Add("message ", new KeyValuePair("string", "the message to send")); returns.Add("Group UUID invaild"); returns.Add("Processing"); @@ -1006,6 +1025,92 @@ namespace BetterSecondBot.WikiMake } } + public class location : APIcall + { + public override void Setup() + { + about = "Fetchs the current location of the bot"; + returns.Add("array of X,Y,Z values"); + base.Setup(); + } + } + + public class walkto : APIcall + { + public override void Setup() + { + about = "uses the AutoPilot to move to a location"; + values.Add("x", new KeyValuePair("URLARG", "X location to AutoPilot to")); + values.Add("y", new KeyValuePair("URLARG", "Y location to AutoPilot to")); + values.Add("z", new KeyValuePair("URLARG", "Z location to AutoPilot to")); + returns.Add("Error Unable to AutoPilot to location"); + returns.Add("Accepted"); + base.Setup(); + } + } + + + public class teleport : APIcall + { + public override void Setup() + { + about = "uses the AutoPilot to move to a location"; + values.Add("region", new KeyValuePair("URLARG", "the name of the region we are going to")); + values.Add("x", new KeyValuePair("URLARG", "X location")); + values.Add("y", new KeyValuePair("URLARG", "Y location")); + values.Add("z", new KeyValuePair("URLARG", "Z location")); + returns.Add("Error Unable to Teleport to location"); + returns.Add("Accepted"); + base.Setup(); + } + } + + public class regionname : APIcall + { + public override void Setup() + { + about = "Fetchs the current region name"; + returns.Add("string regionname"); + base.Setup(); + } + } + + public class nearmewithdetails : APIcall + { + public override void Setup() + { + about = "an improved version of near me with extra details
NearMeDetails is a object formated as follows
  • id
  • name
  • x
  • y
  • z
  • range
"; + returns.Add("array NearMeDetails"); + base.Setup(); + } + } + + + + public class regiontile : APIcall + { + public override void Setup() + { + about = "Fetchs the regions map tile"; + values.Add("region", new KeyValuePair("URLARG", "string name of region")); + returns.Add("Unable to find region"); + returns.Add("Texture UUID"); + base.Setup(); + } + } + + public class rezobject : APIcall + { + public override void Setup() + { + about = "rezs the item at the bots current location"; + values.Add("item", new KeyValuePair("URLARG", "UUID of item to rez")); + returns.Add("true|false"); + base.Setup(); + } + } + + public class localchatsay : postAPIcall { public override void Setup() @@ -1017,4 +1122,6 @@ namespace BetterSecondBot.WikiMake } } + + } diff --git a/Core/Commands/Animation/PlayGesture.cs b/Core/Commands/Animation/PlayGesture.cs new file mode 100644 index 0000000..1e75700 --- /dev/null +++ b/Core/Commands/Animation/PlayGesture.cs @@ -0,0 +1,25 @@ +using OpenMetaverse; + +namespace BSB.Commands.Animation +{ + public class PlayGesture : CoreCommand_1arg + { + public override string[] ArgTypes { get { return new[] { "UUID" }; } } + public override string[] ArgHints { get { return new[] { "The UUID of the gesture to play" }; } } + public override string Helpfile { get { return "Triggers a gesture [once]"; } } + public override bool CallFunction(string[] args) + { + if (base.CallFunction(args) == true) + { + if (UUID.TryParse(args[0], out UUID gesture) == true) + { + InventoryItem itm = bot.GetClient.Inventory.FetchItem(gesture, bot.GetClient.Self.AgentID, (3 * 1000)); + bot.GetClient.Self.PlayGesture(itm.AssetUUID); + return true; + } + return Failed("Invaild gesture UUID for arg 1"); + } + return false; + } + } +} diff --git a/Core/Commands/Movement/AutoPilot.cs b/Core/Commands/Movement/AutoPilot.cs index d491b01..1043c22 100644 --- a/Core/Commands/Movement/AutoPilot.cs +++ b/Core/Commands/Movement/AutoPilot.cs @@ -23,6 +23,7 @@ namespace BSB.Commands.Movement { if (helpers.inrange(pos.Z, 0, 5000) == true) { + bot.GetClient.Self.AutoPilotCancel(); bot.GetClient.Self.Movement.TurnToward(pos, true); Thread.Sleep(500); uint Globalx, Globaly; diff --git a/Core/Commands/Movement/teleport.cs b/Core/Commands/Movement/teleport.cs index b6538fb..49c28c0 100644 --- a/Core/Commands/Movement/teleport.cs +++ b/Core/Commands/Movement/teleport.cs @@ -17,6 +17,7 @@ namespace BSB.Commands.Movement { if(base.CallFunction(args) == true) { + bot.GetClient.Self.AutoPilotCancel(); if (args[0].Contains("http://maps.secondlife.com/secondlife/") == true) { bot.TeleportWithSLurl(args[0]); diff --git a/Core/bottypes/chatrelay.cs b/Core/bottypes/chatrelay.cs index 15ea1a5..0ff2d7b 100644 --- a/Core/bottypes/chatrelay.cs +++ b/Core/bottypes/chatrelay.cs @@ -65,7 +65,7 @@ namespace BSB.bottypes im_chat_unread.Add(avatar, false); } var date = DateTime.Now; - im_chat_history[avatar].Add("[" + date.Hour.ToString() + ":" + date.Minute.ToString() + "] " + sendername + ":" + message + ""); + im_chat_history[avatar].Add("[" + date.Hour.ToString() + ":" + date.Minute.ToString() + "] " + sendername + ": " + message + ""); if (im_chat_history[avatar].Count > imchatlimit) { im_chat_history[avatar].RemoveAt(0); @@ -78,7 +78,7 @@ namespace BSB.bottypes public override void AddToLocalChat(string name, string message) { var date = DateTime.Now; - LocalChat_history.Add("[" + date.Hour.ToString() + ":" + date.Minute.ToString() + "] " + name + ":" + message + ""); + LocalChat_history.Add("[" + date.Hour.ToString() + ":" + date.Minute.ToString() + "] " + name + ": " + message + ""); if (LocalChat_history.Count > localchatlimit) { LocalChat_history.RemoveAt(0); @@ -163,7 +163,7 @@ namespace BSB.bottypes group_chat_unread.Add(group, false); } var date = DateTime.Now; - group_chat_history[group].Add("[" + date.Hour.ToString() + ":" + date.Minute.ToString() + "] " + name + ":" + message + ""); + group_chat_history[group].Add("[" + date.Hour.ToString() + ":" + date.Minute.ToString() + "] " + name + ": " + message + ""); if (group_chat_history[group].Count > groupchatlimit) { group_chat_history[group].RemoveAt(0); diff --git a/libremetaverse-core/Libremetaverse/InventoryAISClient.cs b/libremetaverse-core/Libremetaverse/InventoryAISClient.cs index 96dedc2..e255364 100644 --- a/libremetaverse-core/Libremetaverse/InventoryAISClient.cs +++ b/libremetaverse-core/Libremetaverse/InventoryAISClient.cs @@ -20,11 +20,16 @@ namespace LibreMetaverse [NonSerialized] private readonly GridClient Client; - private static readonly HttpClient httpClient = new HttpClient(); + private static HttpClient httpClient; public InventoryAISClient(GridClient client) { Client = client; + + HttpClientHandler clientHandler = new HttpClientHandler(); + clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; }; + httpClient = new HttpClient(clientHandler); + httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Add("User-Agent", "LibreMetaverse AIS Client"); }