diff --git a/BetterSecondbot/HttpService/Animation.cs b/BetterSecondbot/HttpService/Animation.cs
new file mode 100644
index 0000000..c503689
--- /dev/null
+++ b/BetterSecondbot/HttpService/Animation.cs
@@ -0,0 +1,79 @@
+using BetterSecondBot.bottypes;
+using BetterSecondBot.Static;
+using EmbedIO;
+using EmbedIO.Routing;
+using EmbedIO.WebApi;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenMetaverse;
+using Newtonsoft.Json;
+using System.Reflection;
+
+namespace BetterSecondBot.HttpService
+{
+ public class HttpApiAnimation : WebApiControllerWithTokens
+ {
+ public HttpApiAnimation(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { }
+
+ [About("Toggles if animation requests from this avatar (used for remote poseballs) are accepted")]
+ [ReturnHints("Granted perm animation")]
+ [ReturnHints("Removed perm animation")]
+ [ReturnHints("avatar lookup")]
+ [ArgHints("avatar", "URLARG", "UUID (or Firstname Lastname)")]
+ [Route(HttpVerbs.Get, "/AddToAllowAnimations/{avatar}/{token}")]
+ public object AddToAllowAnimations(string avatar, string token)
+ {
+ if (tokens.Allow(token, "animation", "addtoallowanimations", getClientIP()) == false)
+ {
+ return BasicReply("Token not accepted");
+ }
+ ProcessAvatar(avatar);
+ if (avataruuid == UUID.Zero)
+ {
+ return BasicReply("avatar lookup");
+ }
+ if (bot.Accept_action_from("animation", avataruuid) == false)
+ {
+ bot.Add_action_from("animation", avataruuid);
+ return BasicReply("Granted perm animation");
+ }
+ bot.Remove_action_from("animation", avataruuid, true);
+ return BasicReply("Removed perm animation");
+ }
+
+ [About("Attempts to play a gesture")]
+ [ReturnHints("Error with gesture")]
+ [ReturnHints("Accepted")]
+ [ArgHints("gesture", "URLARG", "Inventory UUID of the gesture")]
+ [Route(HttpVerbs.Get, "/PlayGesture/{gesture}/{token}")]
+ public object PlayGesture(string gesture, string token)
+ {
+ if (tokens.Allow(token, "animation", "gesture", getClientIP()) == false)
+ {
+ return BasicReply("Token not accepted");
+ }
+ if (UUID.TryParse(gesture, out UUID gestureUUID) == false)
+ {
+ return BasicReply("Error with gesture");
+ }
+ InventoryItem itm = bot.GetClient.Inventory.FetchItem(gestureUUID, bot.GetClient.Self.AgentID, (3 * 1000));
+ bot.GetClient.Self.PlayGesture(itm.AssetUUID);
+ return BasicReply("Accepted");
+ }
+
+ [About("Resets the animation stack for the bot")]
+ [ReturnHints("Accepted")]
+ [Route(HttpVerbs.Get, "/ResetAnimations/{token}")]
+ public object ResetAnimations(string token)
+ {
+ if (tokens.Allow(token, "animation", "resetanimations", getClientIP()) == false)
+ {
+ return BasicReply("Token not accepted");
+ }
+ bot.ResetAnimations();
+ return BasicReply("Accepted");
+ }
+
+ }
+}
diff --git a/BetterSecondbot/HttpService/Avatars.cs b/BetterSecondbot/HttpService/Avatars.cs
new file mode 100644
index 0000000..62903dc
--- /dev/null
+++ b/BetterSecondbot/HttpService/Avatars.cs
@@ -0,0 +1,112 @@
+using BetterSecondBot.bottypes;
+using BetterSecondBot.Static;
+using EmbedIO;
+using EmbedIO.Routing;
+using EmbedIO.WebApi;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenMetaverse;
+using Newtonsoft.Json;
+using System.Reflection;
+
+namespace BetterSecondBot.HttpService
+{
+ public class HTTP_Avatars : WebApiControllerWithTokens
+ {
+ public HTTP_Avatars(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { }
+
+ [About("an improved version of near me with extra details
NearMeDetails is a object formated as follows
")]
+ [ReturnHints("array NearMeDetails")]
+ [ReturnHints("Error not in a sim")]
+ [Route(HttpVerbs.Get, "/NearmeWithDetails/{token}")]
+ public object NearmeWithDetails(string token)
+ {
+ if (tokens.Allow(token, "avatars", "nearmewithdetails", getClientIP()) == false)
+ {
+ return BasicReply("Token not accepted");
+ }
+ if (bot.GetClient.Network.CurrentSim == null)
+ {
+ return BasicReply("Error not in a sim");
+ }
+ 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)
+ {
+ 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(BetterNearMe));
+ }
+
+ [About("returns a list of all known avatars nearby")]
+ [ReturnHints("array UUID = Name")]
+ [ReturnHints("Error not in a sim")]
+ [Route(HttpVerbs.Get, "/Nearme/{token}")]
+ public object Nearme(string token)
+ {
+ if (tokens.Allow(token, "avatars", "nearme", getClientIP()) == false)
+ {
+ return BasicReply("Token not accepted");
+ }
+ if (bot.GetClient.Network.CurrentSim == null)
+ {
+ return BasicReply("Error not in a sim");
+ }
+ 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));
+ }
+
+
+ [About("Makes the bot pay a avatar")]
+ [ReturnHints("Accepted")]
+ [ReturnHints("avatar lookup")]
+ [ReturnHints("Invaild amount")]
+ [ReturnHints("Transfer funds to avatars disabled")]
+ [Route(HttpVerbs.Get, "/PayAvatar/{avatar}/{amount}/{token}")]
+ public object PayAvatar(string avatar,string amount,string token)
+ {
+ if (tokens.Allow(token, "avatars", "payavatar", getClientIP()) == false)
+ {
+ return BasicReply("Token not accepted");
+ }
+ if (bot.GetAllowFunds == false)
+ {
+ return BasicReply("Transfer funds to avatars disabled");
+ }
+ ProcessAvatar(avatar);
+ if (avataruuid == UUID.Zero)
+ {
+ return BasicReply("avatar lookup");
+ }
+ if (int.TryParse(amount, out int amountvalue) == false)
+ {
+ return BasicReply("Invaild amount");
+ }
+ if(amountvalue < 1)
+ {
+ return BasicReply("Invaild amount");
+ }
+ bot.GetClient.Self.GiveAvatarMoney(avataruuid, amountvalue);
+ return BasicReply("Accepted");
+ }
+ }
+}
diff --git a/BetterSecondbot/HttpService/Chat.cs b/BetterSecondbot/HttpService/Chat.cs
index fe7f7a0..1ddf9bc 100644
--- a/BetterSecondbot/HttpService/Chat.cs
+++ b/BetterSecondbot/HttpService/Chat.cs
@@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using Newtonsoft.Json;
+using BetterSecondBotShared.Static;
namespace BetterSecondBot.HttpService
{
@@ -17,8 +18,8 @@ namespace BetterSecondBot.HttpService
[About("fetchs the last 20 localchat messages")]
[ReturnHints("array string")]
- [Route(HttpVerbs.Get, "/localchathistory/{token}")]
- public object localchatHistory(string token)
+ [Route(HttpVerbs.Get, "/LocalChatHistory/{token}")]
+ public object LocalChatHistory(string token)
{
if (tokens.Allow(token, "chat", "localchathistory", getClientIP()) == true)
{
@@ -30,15 +31,52 @@ namespace BetterSecondBot.HttpService
[About("sends a message to localchat")]
[ArgHints("message", "URLARG", "the message to send")]
[ReturnHints("array string")]
- [Route(HttpVerbs.Post, "/localchatsay/{token}")]
- public object localchatSay(string token, [FormField] string message)
+ [ReturnHints("Message empty")]
+ [ReturnHints("Invaild channel")]
+ [Route(HttpVerbs.Post, "/Say/{channel}/{token}")]
+ public object Say(string channel,[FormField] string message,string token)
{
- if (tokens.Allow(token, "chat", "localchatsay", getClientIP()) == true)
+ if (tokens.Allow(token, "chat", "localchatsay", getClientIP()) == false)
{
- bot.GetCommandsInterface.Call("say", message);
- return BasicReply(JsonConvert.SerializeObject(bot.getLocalChatHistory()));
+ return BasicReply("Token not accepted");
}
- return BasicReply("Token not accepted");
+ if (helpers.notempty(message) == false)
+ {
+ return BasicReply("Message empty");
+ }
+ if(int.TryParse(channel,out int channelnum) == false)
+ {
+ return BasicReply("Invaild channel");
+ }
+ bot.GetClient.Self.Chat(message, channelnum, ChatType.Normal);
+ return BasicReply(JsonConvert.SerializeObject(bot.getLocalChatHistory()));
+
+ }
+
+ [About("sends a im to the selected avatar")]
+ [ArgHints("avatar", "URLARG", "a UUID or Firstname Lastname")]
+ [ArgHints("message", "Text", "the message to send")]
+ [ReturnHints("ok")]
+ [ReturnHints("Message empty")]
+ [ReturnHints("avatar lookup")]
+ [Route(HttpVerbs.Post, "/IM/{avatar}/{token}")]
+ public object IM(string avatar, [FormField] string message, string token)
+ {
+ if (tokens.Allow(token, "chat", "im", getClientIP()) == false)
+ {
+ return BasicReply("Token not accepted");
+ }
+ ProcessAvatar(avatar);
+ if(avataruuid == UUID.Zero)
+ {
+ return BasicReply("avatar lookup");
+ }
+ if (helpers.notempty(message) == false)
+ {
+ return BasicReply("Message empty");
+ }
+ bot.SendIM(avataruuid, message);
+ return BasicReply("ok");
}
}
diff --git a/BetterSecondbot/HttpService/Core.cs b/BetterSecondbot/HttpService/Core.cs
index 07aa2a2..3defd91 100644
--- a/BetterSecondbot/HttpService/Core.cs
+++ b/BetterSecondbot/HttpService/Core.cs
@@ -12,9 +12,6 @@ using Newtonsoft.Json;
namespace BetterSecondBot.HttpService
{
-
-
-
public class HttpApiCore : WebApiControllerWithTokens
{
@@ -30,7 +27,7 @@ namespace BetterSecondBot.HttpService
[ReturnHints("A new token with full system scope")]
[ArgHints("authcode", "text", "the first 10 chars of SHA1(unixtime+WebUIkey)
unixtime can be +- 30 of the bots time.")]
[ArgHints("unixtimegiven", "number", "the unixtime you made this request")]
- [Route(HttpVerbs.Post, "/gettoken")]
+ [Route(HttpVerbs.Post, "/GetToken")]
public Object GetToken([FormField] string authcode, [FormField] string unixtimegiven)
{
long now = helpers.UnixTimeNow();
@@ -56,7 +53,7 @@ namespace BetterSecondBot.HttpService
[About("Gets the friendslist
Formated as follows
friendreplyobject
- name: String
- id: String
- online: bool
")]
[ReturnHints("array UUID = friendreplyobject")]
- [Route(HttpVerbs.Get, "/friends/{token}")]
+ [Route(HttpVerbs.Get, "/Friends/{token}")]
public object Friends(string token)
{
if (tokens.Allow(token, "core", "friends", getClientIP()) == true)
@@ -72,7 +69,7 @@ namespace BetterSecondBot.HttpService
[ArgHints("x", "URLARG", "X location to AutoPilot to")]
[ArgHints("y", "URLARG", "y location to AutoPilot to")]
[ArgHints("z", "URLARG", "z location to AutoPilot to")]
- [Route(HttpVerbs.Get, "/walkto/{x}/{y}/{z}/{token}")]
+ [Route(HttpVerbs.Get, "/WalkTo/{x}/{y}/{z}/{token}")]
public object WalkTo(string x, string y, string z, string token)
{
if (tokens.Allow(token, "core", "walkto", getClientIP()) == true)
@@ -87,24 +84,7 @@ namespace BetterSecondBot.HttpService
return BasicReply("Token not accepted");
}
- [About("Attempts to play a gesture")]
- [ReturnHints("Invaild gesture UUID for arg 1")]
- [ReturnHints("Accepted")]
- [ArgHints("gesture", "URLARG", "Inventory UUID of the gesture")]
- [Route(HttpVerbs.Get, "/gesture/{gesture}/{token}")]
- public object Gesture(string gesture, string token)
- {
- if (tokens.Allow(token, "core", "gesture", 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");
- }
+
[About("Attempt to teleport to a new region")]
[ReturnHints("Error Unable to Teleport to location")]
@@ -113,7 +93,7 @@ namespace BetterSecondBot.HttpService
[ArgHints("x", "URLARG", "X location to teleport to")]
[ArgHints("y", "URLARG", "y location to teleport to")]
[ArgHints("z", "URLARG", "z location to teleport to")]
- [Route(HttpVerbs.Get, "/teleport/{region}/{x}/{y}/{z}/{token}")]
+ [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, "core", "teleport", getClientIP()) == true)
@@ -132,7 +112,7 @@ namespace BetterSecondBot.HttpService
[ReturnHints("Unable to find region")]
[ReturnHints("Texture UUID")]
[ArgHints("regionname", "URLARG", "the name of the region we are fetching")]
- [Route(HttpVerbs.Get, "/regiontile/{regionname}/{token}")]
+ [Route(HttpVerbs.Get, "/Regiontile/{regionname}/{token}")]
public object Regiontile(string regionname, string token)
{
if (tokens.Allow(token, "core", "regiontile", getClientIP()) == true)
@@ -149,69 +129,12 @@ namespace BetterSecondBot.HttpService
return BasicReply("Token not accepted");
}
- [About("an improved version of near me with extra details
NearMeDetails is a object formated as follows
")]
- [ReturnHints("array NearMeDetails")]
- [ReturnHints("Error not in a sim")]
- [Route(HttpVerbs.Get, "/nearmewithdetails/{token}")]
- public object NearmeWithDetails(string token)
- {
- if (tokens.Allow(token, "core", "nearmewithdetails", getClientIP()) == true)
- {
- if (bot.GetClient.Network.CurrentSim != null)
- {
- 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)
- {
- 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(BetterNearMe));
- }
- return BasicReply("Error not in a sim");
- }
- return BasicReply("Token not accepted");
- }
- [About("returns a list of all known avatars nearby")]
- [ReturnHints("array UUID = Name")]
- [ReturnHints("Error not in a sim")]
- [Route(HttpVerbs.Get, "/nearme/{token}")]
- public object Nearme(string token)
- {
- if (tokens.Allow(token, "core", "nearme", 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");
- }
[About("Used to check HTTP connections")]
[ReturnHints("world")]
[NeedsToken(false)]
- [Route(HttpVerbs.Get, "/hello")]
+ [Route(HttpVerbs.Get, "/Hello")]
public object Hello()
{
return BasicReply("world");
@@ -221,7 +144,7 @@ namespace BetterSecondBot.HttpService
[About("Removes the given token from the accepted token pool")]
[ReturnHints("Failed to remove token")]
[ReturnHints("ok")]
- [Route(HttpVerbs.Get, "/logout/{token}")]
+ [Route(HttpVerbs.Get, "/Logout/{token}")]
public object Logout(string token)
{
if (tokens.Allow(token, "core", "logout", getClientIP()) == true)
@@ -235,7 +158,7 @@ namespace BetterSecondBot.HttpService
[About("Fetchs the current bot")]
[ReturnHints("The build ID of the bot")]
- [Route(HttpVerbs.Get, "/version/{token}")]
+ [Route(HttpVerbs.Get, "/Version/{token}")]
public object Version(string token)
{
if (tokens.Allow(token, "core", "version", getClientIP()) == true)
@@ -247,7 +170,7 @@ namespace BetterSecondBot.HttpService
[About("Fetchs the name of the bot")]
[ReturnHints("Firstname Lastname")]
- [Route(HttpVerbs.Get, "/name/{token}")]
+ [Route(HttpVerbs.Get, "/Name/{token}")]
public object Name(string token)
{
if (tokens.Allow(token, "core", "name", getClientIP()) == true)
@@ -260,7 +183,7 @@ namespace BetterSecondBot.HttpService
[About("Fetchs the current region name")]
[ReturnHints("Regionname")]
[ReturnHints("Error not in a sim")]
- [Route(HttpVerbs.Get, "/regionname/{token}")]
+ [Route(HttpVerbs.Get, "/Regionname/{token}")]
public object Regionname(string token)
{
if (tokens.Allow(token, "core", "regionname", getClientIP()) == true)
@@ -277,7 +200,7 @@ namespace BetterSecondBot.HttpService
[About("Fetchs the current location of the bot")]
[ReturnHints("array of X,Y,Z values")]
[ReturnHints("Error not in a sim")]
- [Route(HttpVerbs.Get, "/location/{token}")]
+ [Route(HttpVerbs.Get, "/Location/{token}")]
public object Location(string token)
{
if (tokens.Allow(token, "core", "location", getClientIP()) == true)
@@ -301,8 +224,8 @@ namespace BetterSecondBot.HttpService
[ReturnHints("accepted")]
[ReturnHints("Auth not accepted")]
[ReturnHints("Failed")]
- [Route(HttpVerbs.Post, "/command/{token}")]
- public async Task