commands remove tokens

This commit is contained in:
Madpeter 2022-05-30 05:30:15 +01:00
parent feacb83182
commit a3173dcac8
21 changed files with 621 additions and 1198 deletions

View file

@ -1,6 +1,4 @@
using EmbedIO; using OpenMetaverse;
using EmbedIO.Routing;
using OpenMetaverse;
using SecondBotEvents.Services; using SecondBotEvents.Services;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
@ -15,14 +13,9 @@ namespace SecondBotEvents.Commands
[ReturnHints("Granted perm animation")] [ReturnHints("Granted perm animation")]
[ReturnHints("Removed perm animation")] [ReturnHints("Removed perm animation")]
[ReturnHintsFailure("avatar lookup")] [ReturnHintsFailure("avatar lookup")]
[ArgHints("avatar", "URLARG", "UUID (or Firstname Lastname)")] [ArgHints("avatar", "UUID (or Firstname Lastname)")]
[Route(HttpVerbs.Get, "/AddToAllowAnimations/{avatar}/{token}")] public object AddToAllowAnimations(string avatar)
public object AddToAllowAnimations(string avatar, string token)
{ {
if(AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
@ -35,14 +28,9 @@ namespace SecondBotEvents.Commands
[About("Attempts to play a gesture")] [About("Attempts to play a gesture")]
[ReturnHintsFailure("Error with gesture")] [ReturnHintsFailure("Error with gesture")]
[ReturnHints("Accepted")] [ReturnHints("Accepted")]
[ArgHints("gesture", "URLARG", "Inventory UUID of the gesture")] [ArgHints("gesture", "Inventory UUID of the gesture")]
[Route(HttpVerbs.Get, "/PlayGesture/{gesture}/{token}")] public object PlayGesture(string gesture)
public object PlayGesture(string gesture, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(gesture, out UUID gestureUUID) == false) if (UUID.TryParse(gesture, out UUID gestureUUID) == false)
{ {
return BasicReply("Error with gesture", "PlayGesture", new [] { gesture }); return BasicReply("Error with gesture", "PlayGesture", new [] { gesture });
@ -54,13 +42,8 @@ namespace SecondBotEvents.Commands
[About("Resets the animation stack for the bot")] [About("Resets the animation stack for the bot")]
[ReturnHints("Accepted")] [ReturnHints("Accepted")]
[Route(HttpVerbs.Get, "/ResetAnimations/{token}")] public object ResetAnimations()
public object ResetAnimations(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
// @todo Reset animations function from old version // @todo Reset animations function from old version
return Failure("@todo", "ResetAnimations"); return Failure("@todo", "ResetAnimations");
} }

View file

@ -1,6 +1,4 @@
using EmbedIO; using System;
using EmbedIO.Routing;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenMetaverse; using OpenMetaverse;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -17,13 +15,8 @@ namespace SecondBotEvents.Commands
[About("an improved version of near me with extra details<br/>NearMeDetails is a object formated as follows<br/><ul><li>id</li><li>name</li><li>x</li><li>y</li><li>z</li><li>range</li></ul>")] [About("an improved version of near me with extra details<br/>NearMeDetails is a object formated as follows<br/><ul><li>id</li><li>name</li><li>x</li><li>y</li><li>z</li><li>range</li></ul>")]
[ReturnHints("array NearMeDetails")] [ReturnHints("array NearMeDetails")]
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[Route(HttpVerbs.Get, "/NearmeWithDetails/{token}")] public object NearmeWithDetails()
public object NearmeWithDetails(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (getClient().Network.CurrentSim == null) if (getClient().Network.CurrentSim == null)
{ {
return BasicReply("Error not in a sim"); return BasicReply("Error not in a sim");
@ -50,13 +43,8 @@ namespace SecondBotEvents.Commands
[About("returns a list of all known avatars nearby")] [About("returns a list of all known avatars nearby")]
[ReturnHints("array UUID = Name")] [ReturnHints("array UUID = Name")]
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[Route(HttpVerbs.Get, "/Nearme/{token}")] public object Nearme()
public object Nearme(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (getClient().Network.CurrentSim == null) if (getClient().Network.CurrentSim == null)
{ {
return BasicReply("Error not in a sim"); return BasicReply("Error not in a sim");
@ -73,17 +61,13 @@ namespace SecondBotEvents.Commands
return BasicReply(JsonConvert.SerializeObject(NearMe)); return BasicReply(JsonConvert.SerializeObject(NearMe));
} }
[About("searchs the AV database for the given UUID to find the name, if not found triggers a lookup")] [About("searchs the AV database if not found triggers a lookup")]
[ArgHints("uuid", "the UUID to find the name for")]
[ReturnHints("the name of the avatar")] [ReturnHints("the name of the avatar")]
[ReturnHints("lookup")] [ReturnHints("lookup")]
[ReturnHintsFailure("Not a vaild UUID")] [ReturnHintsFailure("Not a vaild UUID")]
[Route(HttpVerbs.Get, "/Key2Name/{uuid}/{token}")] public object Key2Name(string uuid)
public object Key2Name(string uuid, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
UUID avUUID = UUID.Zero; UUID avUUID = UUID.Zero;
if (UUID.TryParse(uuid, out avUUID) == false) if (UUID.TryParse(uuid, out avUUID) == false)
{ {
@ -92,17 +76,13 @@ namespace SecondBotEvents.Commands
return BasicReply(master.DataStoreService.getAvatarName(avUUID)); return BasicReply(master.DataStoreService.getAvatarName(avUUID));
} }
[About("searchs the AV database for the given name to find the UUID, if not found triggers a lookup")] [About("searchs the AV database if not found triggers a lookup")]
[ReturnHints("the uuid of the avatar")] [ReturnHints("the uuid of the avatar")]
[ReturnHints("lookup")] [ReturnHints("lookup")]
[ReturnHintsFailure("Not a vaild name")] [ReturnHintsFailure("Not a vaild name")]
[Route(HttpVerbs.Get, "/Name2Key/{name}/{token}")] [ArgHints("name", "the name to find the uuid for")]
public object Name2Key(string name, string token) public object Name2Key(string name)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if(name == null) if(name == null)
{ {
return Failure("Not a vaild name"); return Failure("Not a vaild name");

View file

@ -1,10 +1,6 @@
using EmbedIO; using Newtonsoft.Json;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using Newtonsoft.Json;
using OpenMetaverse; using OpenMetaverse;
using SecondBotEvents.Services; using SecondBotEvents.Services;
using System.Collections.Generic;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
@ -16,29 +12,19 @@ namespace SecondBotEvents.Commands
[About("fetchs the last localchat messages")] [About("fetchs the last localchat messages")]
[ReturnHints("json encoded array")] [ReturnHints("json encoded array")]
[Route(HttpVerbs.Get, "/LocalChatHistory/{token}")] public object LocalChatHistory()
public object LocalChatHistory(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.getLocalChat())); return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.getLocalChat()));
} }
[About("sends a message to localchat")] [About("sends a message to localchat")]
[ArgHints("channel", "URLARG", "the channel to output on (>=0)")] [ArgHints("channel", "the channel to output on (>=0)")]
[ArgHints("message", "Text", "the message to send")] [ArgHints("message", "the message to send")]
[ReturnHints("array string")] [ReturnHints("array string")]
[ReturnHintsFailure("Message empty")] [ReturnHintsFailure("Message empty")]
[ReturnHintsFailure("Invaild channel")] [ReturnHintsFailure("Invaild channel")]
[Route(HttpVerbs.Post, "/Say/{channel}/{token}")] public object Say(string channel, string message)
public object Say(string channel,[FormField] string message,string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (SecondbotHelpers.isempty(message) == true) if (SecondbotHelpers.isempty(message) == true)
{ {
return Failure("Message empty", "Say", new [] { channel, message }); return Failure("Message empty", "Say", new [] { channel, message });
@ -57,18 +43,13 @@ namespace SecondBotEvents.Commands
} }
[About("sends a im to the selected avatar")] [About("sends a im to the selected avatar")]
[ArgHints("avatar", "URLARG", "a UUID or Firstname Lastname")] [ArgHints("avatar", "a UUID or Firstname Lastname")]
[ArgHints("message", "Text", "the message to send")] [ArgHints("message", "the message to send")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Message empty")] [ReturnHintsFailure("Message empty")]
[ReturnHintsFailure("avatar lookup")] [ReturnHintsFailure("avatar lookup")]
[Route(HttpVerbs.Post, "/IM/{avatar}/{token}")] public object IM(string avatar, string message)
public object IM(string avatar, [FormField] string message, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar); ProcessAvatar(avatar);
if(avataruuid == UUID.Zero) if(avataruuid == UUID.Zero)
{ {
@ -84,51 +65,31 @@ namespace SecondBotEvents.Commands
[About("gets a full list of all avatar chat windows")] [About("gets a full list of all avatar chat windows")]
[ReturnHints("array UUID = Name")] [ReturnHints("array UUID = Name")]
[Route(HttpVerbs.Get, "/chatwindows/{token}")] public object chatwindows()
public object chatwindows(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.getAvatarImWindows())); return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.getAvatarImWindows()));
} }
[About("gets a list of chat windows from avatars with unread messages")] [About("gets a list of chat windows from avatars with unread messages")]
[ReturnHints("array of UUID")] [ReturnHints("array of UUID")]
[Route(HttpVerbs.Get, "/listwithunread/{token}")] public object listwithunread()
public object listwithunread(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.getAvatarImWindowsUnread())); return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.getAvatarImWindowsUnread()));
} }
[About("gets if there are any unread im messages from avatars at all")] [About("gets if there are any unread im messages from avatars at all")]
[ReturnHints("True|False")] [ReturnHints("True|False")]
[Route(HttpVerbs.Get, "/haveunreadims/{token}")] public object haveunreadims()
public object haveunreadims(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return BasicReply(master.DataStoreService.getAvatarImWindowsUnreadAny().ToString()); return BasicReply(master.DataStoreService.getAvatarImWindowsUnreadAny().ToString());
} }
[About("gets the chat from the selected window for avatar")] [About("gets the chat from the selected window for avatar")]
[ArgHints("window", "URLARG", "the UUID of the avatar you wish to view the chat from")] [ArgHints("window", "the UUID of the avatar you wish to view the chat from")]
[ReturnHintsFailure("avatar UUID invaild")] [ReturnHintsFailure("avatar UUID invaild")]
[ReturnHints("Array of text")] [ReturnHints("Array of text")]
[Route(HttpVerbs.Get, "/getimchat/{avatarid}/{token}")] public object getimchat(string avatarid)
public object getimchat(string avatarid, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
UUID avatarUUID = UUID.Zero; UUID avatarUUID = UUID.Zero;
if (UUID.TryParse(avatarid, out avatarUUID) == false) if (UUID.TryParse(avatarid, out avatarUUID) == false)
{ {

View file

@ -1,9 +1,4 @@
using EmbedIO; using SecondBotEvents.Services;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using OpenMetaverse;
using SecondBotEvents.Services;
using System.Threading;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
@ -12,28 +7,12 @@ namespace SecondBotEvents.Commands
public Core(EventsSecondBot setmaster) : base(setmaster) public Core(EventsSecondBot setmaster) : base(setmaster)
{ {
} }
[About("Used to check HTTP connections")] [About("Used to check connections")]
[ReturnHints("world")] [ReturnHints("world")]
[NeedsToken(false)]
[Route(HttpVerbs.Get, "/Hello")]
public object Hello() public object Hello()
{ {
return BasicReply("world", "Hello"); return BasicReply("world", "Hello");
} }
[About("Removes the given token from the accepted token pool")]
[ReturnHints("ok")]
[Route(HttpVerbs.Get, "/LogoutUI/{token}")]
public object LogoutUI(string token)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
SuccessNoReturn("LogoutUI");
// @todo remove token from stoage
return BasicReply("ok");
}
} }
public class CommandLibCall public class CommandLibCall

View file

@ -1,7 +1,4 @@
using EmbedIO; using SecondBotEvents.Services;
using EmbedIO.Routing;
using OpenMetaverse;
using SecondBotEvents.Services;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
@ -17,31 +14,20 @@ namespace SecondBotEvents.Commands
[ReturnHints("set/http [ok]")] [ReturnHints("set/http [ok]")]
[ReturnHints("set/channel [ok]")] [ReturnHints("set/channel [ok]")]
[ReturnHintsFailure("Not a vaild option")] [ReturnHintsFailure("Not a vaild option")]
[ArgHints("target","URLARG", "Options: Channel (Any number),Avatar UUID,HTTPurl<br/>Clear")] [ArgHints("target", "Options: Channel (Any number),Avatar UUID,HTTPurl<br/>Clear")]
[Route(HttpVerbs.Get, "/DialogRelay/{target}/{token}")] public object DialogRelay(string target)
public object DialogRelay(string target,string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return Failure("@todo dialog relay"); return Failure("@todo dialog relay");
} }
[About("Makes the bot interact with the dialog [dialogid] with the button [buttontext]")] [About("Makes the bot interact with the dialog [dialogid] with the button [buttontext]")]
[ReturnHints("true")] [ReturnHints("true")]
[ReturnHints("false")] [ReturnHints("false")]
[ReturnHintsFailure("bad dialog id")] [ReturnHintsFailure("bad dialog id")]
[ArgHints("dialogid", "URLARG", "The ID for the dialog")] [ArgHints("dialogid", "The ID for the dialog")]
[ArgHints("buttontext", "URLARG", "The button text to push")] [ArgHints("buttontext", "The button text to push")]
[Route(HttpVerbs.Get, "/DialogResponce/{dialogid}/{buttontext}/{token}")] public object DialogResponce(string dialogid, string buttontext)
public object DialogResponce(string dialogid, string buttontext, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (int.TryParse(dialogid, out int dialogidnum) == false) if (int.TryParse(dialogid, out int dialogidnum) == false)
{ {
return Failure("bad dialog id", "DialogResponce", new [] { dialogid, buttontext }); return Failure("bad dialog id", "DialogResponce", new [] { dialogid, buttontext });
@ -52,14 +38,9 @@ namespace SecondBotEvents.Commands
[About("Should the bot track dialogs and send them to the relays setup?")] [About("Should the bot track dialogs and send them to the relays setup?")]
[ReturnHints("updated")] [ReturnHints("updated")]
[ReturnHintsFailure("bad status")] [ReturnHintsFailure("bad status")]
[ArgHints("status", "URLARG", "true or false")] [ArgHints("status", "true or false")]
[Route(HttpVerbs.Get, "/DialogTrack/{status}/{token}")] public object DialogTrack(string status)
public object DialogTrack(string status, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (bool.TryParse(status, out bool statuscode) == false) if (bool.TryParse(status, out bool statuscode) == false)
{ {
return Failure("bad status", "DialogTrack", new [] { status }); return Failure("bad status", "DialogTrack", new [] { status });

View file

@ -1,10 +1,4 @@
using EmbedIO; using SecondBotEvents.Services;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using OpenMetaverse;
using SecondBotEvents.Services;
using System;
using System.Collections.Generic;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
@ -16,16 +10,11 @@ namespace SecondBotEvents.Commands
[About("Adds a discord server role to the selected member")] [About("Adds a discord server role to the selected member")]
[ReturnHintsFailure("Discord client not ready")] [ReturnHintsFailure("Discord client not ready")]
[ReturnHints("true|false")] [ReturnHints("true|false")]
[ArgHints("serverid","URLARG","the server id to apply this action to")] [ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("roleid", "URLARG", "the role id we are giving")] [ArgHints("roleid", "the role id we are giving")]
[ArgHints("memberid", "URLARG", "who we are giving it to")] [ArgHints("memberid", "who we are giving it to")]
[Route(HttpVerbs.Get, "/Discord_AddRole/{serverid}/{roleid}/{memberid}/{token}")] public object Discord_AddRole(string serverid,string roleid,string memberid)
public object Discord_AddRole(string serverid,string roleid,string memberid,string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false) if (master.DiscordService.DiscordReady() == false)
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
@ -37,16 +26,11 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Discord client not ready")] [ReturnHintsFailure("Discord client not ready")]
[ReturnHintsFailure("Why empty")] [ReturnHintsFailure("Why empty")]
[ReturnHints("true|false")] [ReturnHints("true|false")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")] [ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("memberid", "URLARG", "who we are giving it to")] [ArgHints("memberid", "who we are giving it to")]
[ArgHints("why", "string", "why they are being banned")] [ArgHints("why", "why they are being banned")]
[Route(HttpVerbs.Post, "/Discord_BanMember/{serverid}/{memberid}/{token}")] public object Discord_BanMember(string serverid, string memberid, string why)
public object Discord_BanMember(string serverid, string memberid, [FormField] string why, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false) if (master.DiscordService.DiscordReady() == false)
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
@ -61,15 +45,10 @@ namespace SecondBotEvents.Commands
[About("Clears messages on the server sent by the member in the last 13 days, 22hours 59mins")] [About("Clears messages on the server sent by the member in the last 13 days, 22hours 59mins")]
[ReturnHintsFailure("Discord client not ready")] [ReturnHintsFailure("Discord client not ready")]
[ReturnHints("true|false")] [ReturnHints("true|false")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")] [ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("memberid", "URLARG", "who we are giving it to")] [ArgHints("memberid", "who we are giving it to")]
[Route(HttpVerbs.Get, "/Discord_BulkClear_Messages/{serverid}/{memberid}/{token}")] public object Discord_BulkClear_Messages(string serverid, string memberid)
public object Discord_BulkClear_Messages(string serverid, string memberid, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false) if (master.DiscordService.DiscordReady() == false)
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
@ -81,16 +60,11 @@ namespace SecondBotEvents.Commands
[About("Sends a message directly to the user [They must be in the server]\n This command requires the SERVER MEMBERS INTENT found in discord app dev")] [About("Sends a message directly to the user [They must be in the server]\n This command requires the SERVER MEMBERS INTENT found in discord app dev")]
[ReturnHintsFailure("Discord client not ready")] [ReturnHintsFailure("Discord client not ready")]
[ReturnHints("true|false")] [ReturnHints("true|false")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")] [ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("memberid", "URLARG", "who we are giving it to")] [ArgHints("memberid", "who we are giving it to")]
[ArgHints("message", "Text", "what we are sending")] [ArgHints("message", "what we are sending")]
[Route(HttpVerbs.Post, "/Discord_Dm_Member/{serverid}/{memberid}/{token}")] public object Discord_Dm_Member(string serverid, string memberid, string message)
public object Discord_Dm_Member(string serverid, string memberid, [FormField] string message, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false) if (master.DiscordService.DiscordReady() == false)
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
@ -103,14 +77,9 @@ namespace SecondBotEvents.Commands
"SERVER MEMBERS INTENT set to true on the discord bot api area !!!")] "SERVER MEMBERS INTENT set to true on the discord bot api area !!!")]
[ReturnHintsFailure("Discord client not ready")] [ReturnHintsFailure("Discord client not ready")]
[ReturnHints("mixed array of userid: nickname|username or userid:username")] [ReturnHints("mixed array of userid: nickname|username or userid:username")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")] [ArgHints("serverid", "the server id to apply this action to")]
[Route(HttpVerbs.Get, "/Discord_MembersList/{serverid}/{token}")] public object Discord_MembersList(string serverid)
public object Discord_MembersList(string serverid, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false) if (master.DiscordService.DiscordReady() == false)
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
@ -123,17 +92,12 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Discord client not ready")] [ReturnHintsFailure("Discord client not ready")]
[ReturnHintsFailure("message empty")] [ReturnHintsFailure("message empty")]
[ReturnHints("true|false")] [ReturnHints("true|false")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")] [ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("channelid", "URLARG", "the channel id to apply this action to")] [ArgHints("channelid", "the channel id to apply this action to")]
[ArgHints("tts", "URLARG", "shoud tts be enabled true or false")] [ArgHints("tts", "shoud tts be enabled true or false")]
[ArgHints("message", "Text", "what we are sending")] [ArgHints("message", "what we are sending")]
[Route(HttpVerbs.Post, "/Discord_MembersList/{serverid}/{tts}/{token}")] public object Discord_MessageChannel(string serverid, string channelid, string tts, string message)
public object Discord_MessageChannel(string serverid, string channelid, string tts, [FormField] string message, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false) if (master.DiscordService.DiscordReady() == false)
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
@ -148,16 +112,11 @@ namespace SecondBotEvents.Commands
[About("Sends a message to the selected channel - Optional TTS usage")] [About("Sends a message to the selected channel - Optional TTS usage")]
[ReturnHints("mixed array of userid: nickname|username or userid:username")] [ReturnHints("mixed array of userid: nickname|username or userid:username")]
[ReturnHintsFailure("Discord client not ready")] [ReturnHintsFailure("Discord client not ready")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")] [ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("memberid", "URLARG", "who we are giving it to")] [ArgHints("memberid", "who we are giving it to")]
[ArgHints("mode", "URLARG", "should we mute them \"true\" or unmute \"false\"")] [ArgHints("mode", "should we mute them \"true\" or unmute \"false\"")]
[Route(HttpVerbs.Get, "/Discord_MuteMember/{serverid}/{memberid}/{mode}/{token}")] public object Discord_MuteMember(string serverid, string memberid, string mode)
public object Discord_MuteMember(string serverid, string memberid, string mode, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false) if (master.DiscordService.DiscordReady() == false)
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
@ -168,16 +127,11 @@ namespace SecondBotEvents.Commands
[About("returns a collection of settings for the given role \n This command requires Discord full client mode enabled and connected")] [About("returns a collection of settings for the given role \n This command requires Discord full client mode enabled and connected")]
[ReturnHints("KeyPair of status: KeyPair[] item = value")] [ReturnHints("KeyPair of status: KeyPair[] item = value")]
[ReturnHintsFailure("Discord client not ready")] [ReturnHintsFailure("Discord client not ready")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")] [ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("memberid", "URLARG", "who we are giving it to")] [ArgHints("memberid", "who we are giving it to")]
[ArgHints("mode", "URLARG", "should we mute them \"true\" or unmute \"false\"")] [ArgHints("mode", "should we mute them \"true\" or unmute \"false\"")]
[Route(HttpVerbs.Get, "/Discord_Role_GetSettings/{serverid}/{roleid}/{token}")] public object Discord_Role_GetSettings(string serverid, string roleid)
public object Discord_Role_GetSettings(string serverid, string roleid, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false) if (master.DiscordService.DiscordReady() == false)
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
@ -190,16 +144,11 @@ namespace SecondBotEvents.Commands
" This command requires Discord full client mode enabled and connected")] " This command requires Discord full client mode enabled and connected")]
[ReturnHints("true|false")] [ReturnHints("true|false")]
[ReturnHintsFailure("Discord client not ready")] [ReturnHintsFailure("Discord client not ready")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")] [ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("roleid", "URLARG", "who we are giving it to")] [ArgHints("roleid", "who we are giving it to")]
[ArgHints("flagscsv", "Text", "what we are setting")] [ArgHints("flagscsv", "what we are setting")]
[Route(HttpVerbs.Post, "/Discord_Role_UpdatePerms/{serverid}/{roleid}/{token}")] public object Discord_Role_UpdatePerms(string serverid, string roleid, string flagscsv)
public object Discord_Role_UpdatePerms(string serverid, string roleid, [FormField] string flagscsv, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false) if (master.DiscordService.DiscordReady() == false)
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
@ -211,15 +160,10 @@ namespace SecondBotEvents.Commands
" This command requires Discord full client mode enabled and connected")] " This command requires Discord full client mode enabled and connected")]
[ReturnHints("KeyPair of statusmessage=roleid or 0")] [ReturnHints("KeyPair of statusmessage=roleid or 0")]
[ReturnHintsFailure("Discord client not ready")] [ReturnHintsFailure("Discord client not ready")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")] [ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("role", "URLARG", "the name of the role we are creating")] [ArgHints("role", "the name of the role we are creating")]
[Route(HttpVerbs.Get, "/Discord_RoleCreate/{serverid}/{role}/{token}")] public object Discord_RoleCreate(string serverid, string role)
public object Discord_RoleCreate(string serverid, string role, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false) if (master.DiscordService.DiscordReady() == false)
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
@ -231,14 +175,9 @@ namespace SecondBotEvents.Commands
[About("Returns a list of roles and their ids in collection \n This command requires Discord full client mode enabled and connected")] [About("Returns a list of roles and their ids in collection \n This command requires Discord full client mode enabled and connected")]
[ReturnHints("KeyPair of status: KeyPair of roleid: rolename")] [ReturnHints("KeyPair of status: KeyPair of roleid: rolename")]
[ReturnHintsFailure("Discord client not ready")] [ReturnHintsFailure("Discord client not ready")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")] [ArgHints("serverid", "the server id to apply this action to")]
[Route(HttpVerbs.Get, "/Discord_RoleList/{serverid}/{token}")] public object Discord_RoleList(string serverid)
public object Discord_RoleList(string serverid, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false) if (master.DiscordService.DiscordReady() == false)
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
@ -249,14 +188,9 @@ namespace SecondBotEvents.Commands
[About("Remove a role from a server \n This command requires Discord full client mode enabled and connected")] [About("Remove a role from a server \n This command requires Discord full client mode enabled and connected")]
[ReturnHints("true|false")] [ReturnHints("true|false")]
[ReturnHintsFailure("Discord client not ready")] [ReturnHintsFailure("Discord client not ready")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")] [ArgHints("serverid", "the server id to apply this action to")]
[Route(HttpVerbs.Get, "/Discord_RoleRemove/{serverid}/{roleid}/{token}")] public object Discord_RoleRemove(string serverid, string roleid)
public object Discord_RoleRemove(string serverid, string roleid, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false) if (master.DiscordService.DiscordReady() == false)
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
@ -267,14 +201,9 @@ namespace SecondBotEvents.Commands
[About("Returns a list of text channels in a server")] [About("Returns a list of text channels in a server")]
[ReturnHints("array of channelid: name")] [ReturnHints("array of channelid: name")]
[ReturnHintsFailure("Discord client not ready")] [ReturnHintsFailure("Discord client not ready")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")] [ArgHints("serverid", "the server id to apply this action to")]
[Route(HttpVerbs.Get, "/Discord_TextChannels_List/{serverid}/{roleid}/{token}")] public object Discord_TextChannels_List(string serverid)
public object Discord_TextChannels_List(string serverid, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false) if (master.DiscordService.DiscordReady() == false)
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");

View file

@ -1,7 +1,4 @@
using EmbedIO; using Newtonsoft.Json;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using Newtonsoft.Json;
using OpenMetaverse; using OpenMetaverse;
using SecondBotEvents.Services; using SecondBotEvents.Services;
using System.Collections.Generic; using System.Collections.Generic;
@ -17,16 +14,11 @@ namespace SecondBotEvents.Commands
[ReturnHints("restarting")] [ReturnHints("restarting")]
[ReturnHintsFailure("Not an estate manager here")] [ReturnHintsFailure("Not an estate manager here")]
[ReturnHintsFailure("canceled")] [ReturnHintsFailure("canceled")]
[ArgHints("delay", "URLARG", "How long to delay the restart for (30 to 240 secs) - defaults to 240 if out of bounds \n" + [ArgHints("delay", "How long to delay the restart for (30 to 240 secs) - defaults to 240 if out of bounds \n" +
"set to 0 if your canceling!")] "set to 0 if your canceling!")]
[ArgHints("mode", "URLARG", "true to start a restart, false to cancel")] [ArgHints("mode", "true to start a restart, false to cancel")]
[Route(HttpVerbs.Get, "/SimRestart/{delay}/{mode}/{token}")] public object SimRestart(string delay, string mode)
public object SimRestart(string delay, string mode, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (getClient().Network.CurrentSim.IsEstateManager == false) if (getClient().Network.CurrentSim.IsEstateManager == false)
{ {
return Failure("Not an estate manager here", "SimRestart", new [] { delay, mode }); return Failure("Not an estate manager here", "SimRestart", new [] { delay, mode });
@ -51,14 +43,9 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Not an estate manager here")] [ReturnHintsFailure("Not an estate manager here")]
[ReturnHintsFailure("Message empty")] [ReturnHintsFailure("Message empty")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ArgHints("message", "Text", "What the message is")] [ArgHints("message", "What the message is")]
[Route(HttpVerbs.Post, "/SimMessage/{token}")] public object SimMessage(string message, string token)
public object SimMessage([FormField] string message, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (SecondbotHelpers.notempty(message) == false) if (SecondbotHelpers.notempty(message) == false)
{ {
return Failure("Message empty", "SimMessage", new [] { message }); return Failure("Message empty", "SimMessage", new [] { message });
@ -74,14 +61,9 @@ namespace SecondBotEvents.Commands
[About("Fetchs the regions map tile")] [About("Fetchs the regions map tile")]
[ReturnHintsFailure("Unable to find region")] [ReturnHintsFailure("Unable to find region")]
[ReturnHints("Texture UUID")] [ReturnHints("Texture UUID")]
[ArgHints("regionname", "URLARG", "the name of the region we are fetching")] [ArgHints("regionname", "the name of the region we are fetching")]
[Route(HttpVerbs.Get, "/GetSimTexture/{regionname}/{token}")] public object GetSimTexture(string regionname)
public object GetSimTexture(string regionname, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (getClient().Grid.GetGridRegion(regionname, GridLayerType.Objects, out GridRegion region) == false) if (getClient().Grid.GetGridRegion(regionname, GridLayerType.Objects, out GridRegion region) == false)
{ {
return Failure("Unable to find region", "GetSimTexture", new [] { regionname }); return Failure("Unable to find region", "GetSimTexture", new [] { regionname });
@ -92,32 +74,23 @@ namespace SecondBotEvents.Commands
[About("Reclaims ownership of the current parcel")] [About("Reclaims ownership of the current parcel")]
[ReturnHintsFailure("Not an estate manager here")] [ReturnHintsFailure("Not an estate manager here")]
[ReturnHints("ok")] [ReturnHints("ok")]
[Route(HttpVerbs.Get, "/EstateParcelReclaim/{token}")] public object EstateParcelReclaim()
public object EstateParcelReclaim(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (getClient().Network.CurrentSim.IsEstateManager == false) if (getClient().Network.CurrentSim.IsEstateManager == false)
{ {
return Failure("Not an estate manager here", "EstateParcelReclaim"); return Failure("Not an estate manager here");
} }
int localid = getClient().Parcels.GetParcelLocalID(getClient().Network.CurrentSim, getClient().Self.SimPosition); int localid = getClient().Parcels.GetParcelLocalID(getClient().Network.CurrentSim, getClient().Self.SimPosition);
getClient().Parcels.Reclaim(getClient().Network.CurrentSim, localid); getClient().Parcels.Reclaim(getClient().Network.CurrentSim, localid);
return BasicReply("ok", "EstateParcelReclaim"); return BasicReply("ok");
} }
[About("Reclaims ownership of the current parcel")] [About("Gets the global location of a sim [region]")]
[ReturnHintsFailure("Not an estate manager here")] [ArgHints("regionname", "the region we want")]
[ReturnHints("ok")] [ReturnHintsFailure("Unable to find region")]
[Route(HttpVerbs.Get, "/GetSimGlobalPos/{regionname}/{token}")] [ReturnHints("a json object with the x,y and region name")]
public object GetSimGlobalPos(string regionname, string token) public object GetSimGlobalPos(string regionname)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (getClient().Grid.GetGridRegion(regionname, GridLayerType.Objects, out GridRegion region) == false) if (getClient().Grid.GetGridRegion(regionname, GridLayerType.Objects, out GridRegion region) == false)
{ {
return Failure("Unable to find region", "GetSimGlobalPos", new [] { regionname }); return Failure("Unable to find region", "GetSimGlobalPos", new [] { regionname });
@ -126,20 +99,14 @@ namespace SecondBotEvents.Commands
reply.Add("region", regionname); reply.Add("region", regionname);
reply.Add("X", region.X.ToString()); reply.Add("X", region.X.ToString());
reply.Add("Y", region.Y.ToString()); reply.Add("Y", region.Y.ToString());
SuccessNoReturn("GetSimGlobalPos", new [] { regionname }); return BasicReply(JsonConvert.SerializeObject(reply));
return reply;
} }
[About("Requests the estate banlist")] [About("Requests the estate banlist")]
[ReturnHints("ban list json")] [ReturnHints("ban list json")]
[Route(HttpVerbs.Get, "/GetEstateBanList/{token}")] public object GetEstateBanList()
public object GetEstateBanList(string token)
{ {
if (AllowToken(token) == false) return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetEstateBans()));
{
return Failure("Token not accepted");
}
return Failure("@todo estate blacklist");
} }
[About("Attempts to add/remove the avatar to/from the Estate banlist")] [About("Attempts to add/remove the avatar to/from the Estate banlist")]
@ -148,17 +115,12 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Unable to find avatar UUID")] [ReturnHintsFailure("Unable to find avatar UUID")]
[ReturnHintsFailure("Unable to process global value please use true or false")] [ReturnHintsFailure("Unable to process global value please use true or false")]
[ReturnHintsFailure("Not an estate manager on region {REGIONNAME}")] [ReturnHintsFailure("Not an estate manager on region {REGIONNAME}")]
[ArgHints("avatar", "URLARG", "the uuid avatar you wish to ban")] [ArgHints("avatar", "the uuid avatar you wish to ban")]
[ArgHints("mode", "URLARG", "What action would you like to take<br/>Defaults to remove if not given \"add\"")] [ArgHints("mode", "What action would you like to take<br/>Defaults to remove if not given \"add\"")]
[ArgHints("global", "URLARG", "if true this the ban/unban will be applyed to all estates the bot has access to")] [ArgHints("global", "if true this the ban/unban will be applyed to all estates the bot has access to")]
[Route(HttpVerbs.Get, "/UpdateEstateBanlist/{avatar}/{mode}/{global}/{token}")]
public object UpdateEstateBanlist(string avatar, string mode, string global, string token) public object UpdateEstateBanlist(string avatar, string mode, string global)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (getClient().Network.CurrentSim.IsEstateManager == false) if (getClient().Network.CurrentSim.IsEstateManager == false)
{ {
return Failure("Not an estate manager on region " + getClient().Network.CurrentSim.Name, "UpdateEstateBanlist", new [] { avatar, mode, global }); return Failure("Not an estate manager on region " + getClient().Network.CurrentSim.Name, "UpdateEstateBanlist", new [] { avatar, mode, global });

View file

@ -1,6 +1,4 @@
using EmbedIO; using OpenMetaverse;
using EmbedIO.Routing;
using OpenMetaverse;
using SecondBotEvents.Services; using SecondBotEvents.Services;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -12,33 +10,24 @@ namespace SecondBotEvents.Commands
public Friends(EventsSecondBot setmaster) : base(setmaster) public Friends(EventsSecondBot setmaster) : base(setmaster)
{ {
} }
[About("Gets the friendslist")] [About("Gets the friendslist")]
[ReturnHints("array UUID = friendreplyobject")] [ReturnHints("array UUID = friendreplyobject")]
[Route(HttpVerbs.Get, "/Friendslist/{token}")] public object Friendslist()
public object Friendslist(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return BasicReply(JsonConvert.SerializeObject(getClient().Friends.FriendList)); return BasicReply(JsonConvert.SerializeObject(getClient().Friends.FriendList));
} }
[About("Updates the friend perms for avatar avatar to State \n if true grants (Online/Map/Modify) perms")] [About("Updates the friend perms for avatar avatar to State \n if true grants (Online/Map/Modify) perms")]
[ArgHints("avatar", "URLARG", "A avatar uuid or Firstname Lastname")] [ArgHints("avatar", "A avatar uuid or Firstname Lastname")]
[ArgHints("state", "URLARG", "true: Grant perms, false: Remove perms")] [ArgHints("state", "true: Grant perms, false: Remove perms")]
[ReturnHints("granted")] [ReturnHints("granted")]
[ReturnHints("removed")] [ReturnHints("removed")]
[ReturnHintsFailure("Not A friend")] [ReturnHintsFailure("Not A friend")]
[ReturnHintsFailure("state invaild")] [ReturnHintsFailure("state invaild")]
[ReturnHintsFailure("avatar lookup")] [ReturnHintsFailure("avatar lookup")]
[Route(HttpVerbs.Get, "/FriendFullPerms/{avatar}/{state}/{token}")] public object FriendFullPerms(string avatar, string state)
public object FriendFullPerms(string avatar, string state, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
@ -69,15 +58,10 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Not in friendslist")] [ReturnHintsFailure("Not in friendslist")]
[ReturnHintsFailure("state invaild")] [ReturnHintsFailure("state invaild")]
[ReturnHintsFailure("avatar lookup")] [ReturnHintsFailure("avatar lookup")]
[ArgHints("avatar", "URLARG", "A avatar uuid or Firstname Lastname")] [ArgHints("avatar", "A avatar uuid or Firstname Lastname")]
[ArgHints("state", "URLARG", "true: Send invite, false: Remove from friendslist")] [ArgHints("state", "true: Send invite, false: Remove from friendslist")]
[Route(HttpVerbs.Get, "/FriendRequest/{avatar}/{state}/{token}")] public object FriendRequest(string avatar, string state)
public object FriendRequest(string avatar, string state, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
@ -105,6 +89,4 @@ namespace SecondBotEvents.Commands
} }
} }
} }

View file

@ -1,6 +1,4 @@
using EmbedIO; using OpenMetaverse;
using EmbedIO.Routing;
using OpenMetaverse;
using SecondBotEvents.Services; using SecondBotEvents.Services;
@ -14,13 +12,8 @@ namespace SecondBotEvents.Commands
[About("Requests the current balance and requests the balance to update.")] [About("Requests the current balance and requests the balance to update.")]
[ReturnHints("Current fund level")] [ReturnHints("Current fund level")]
[ReturnHintsFailure("Funds commands are disabled")] [ReturnHintsFailure("Funds commands are disabled")]
[Route(HttpVerbs.Get, "/Balance/{token}")]
public object Balance(string token) public object Balance(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.CommandsService.myConfig.GetAllowFundsCommands() == false) if (master.CommandsService.myConfig.GetAllowFundsCommands() == false)
{ {
return Failure("Funds commands are disabled", "Balance"); return Failure("Funds commands are disabled", "Balance");
@ -35,15 +28,10 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Amount out of range")] [ReturnHintsFailure("Amount out of range")]
[ReturnHintsFailure("Invaild amount")] [ReturnHintsFailure("Invaild amount")]
[ReturnHintsFailure("Transfer funds to avatars disabled")] [ReturnHintsFailure("Transfer funds to avatars disabled")]
[ArgHints("avatar", "URLARG", "the avatars UUID or Firstname Lastname")] [ArgHints("avatar", "the avatars UUID or Firstname Lastname")]
[ArgHints("amount", "URLARG", "the amount to pay (from 1 to current balance)")] [ArgHints("amount", "the amount to pay (from 1 to current balance)")]
[Route(HttpVerbs.Get, "/PayAvatar/{avatar}/{amount}/{token}")] public object PayAvatar(string avatar, string amount)
public object PayAvatar(string avatar, string amount, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.CommandsService.myConfig.GetAllowFundsCommands() == false) if (master.CommandsService.myConfig.GetAllowFundsCommands() == false)
{ {
return Failure("Transfer funds to avatars disabled", "PayAvatar", new [] { avatar, amount }); return Failure("Transfer funds to avatars disabled", "PayAvatar", new [] { avatar, amount });
@ -72,16 +60,11 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Invaild amount")] [ReturnHintsFailure("Invaild amount")]
[ReturnHintsFailure("Amount out of range")] [ReturnHintsFailure("Amount out of range")]
[ReturnHintsFailure("Funds commands are disabled")] [ReturnHintsFailure("Funds commands are disabled")]
[ArgHints("object", "URLARG", "UUID of the object to pay")] [ArgHints("object", "UUID of the object to pay")]
[ArgHints("primname", "URLARG", "The name of the prim on the object to pay")] [ArgHints("primname", "The name of the prim on the object to pay")]
[ArgHints("amount", "URLARG", "the amount to pay (from 1 to current balance)")] [ArgHints("amount", "the amount to pay (from 1 to current balance)")]
[Route(HttpVerbs.Get, "/PayObject/{object}/{primname}/{amount}/{token}")] public object PayObject(string objectuuid,string primname,string amount)
public object PayObject(string objectuuid,string primname,string amount,string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.CommandsService.myConfig.GetAllowFundsCommands() == false) if (master.CommandsService.myConfig.GetAllowFundsCommands() == false)
{ {
return Failure("Funds commands are disabled", "PayObject", new [] { objectuuid, primname, amount }); return Failure("Funds commands are disabled", "PayObject", new [] { objectuuid, primname, amount });

View file

@ -1,11 +1,7 @@
using EmbedIO; using Newtonsoft.Json;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using Newtonsoft.Json;
using OpenMetaverse; using OpenMetaverse;
using SecondBotEvents.Services; using SecondBotEvents.Services;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
@ -21,15 +17,10 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Unknown group")] [ReturnHintsFailure("Unknown group")]
[ReturnHintsFailure("Invaild group UUID")] [ReturnHintsFailure("Invaild group UUID")]
[ReturnHintsFailure("avatar lookup")] [ReturnHintsFailure("avatar lookup")]
[ArgHints("group", "URLARG", "the UUID of the group")] [ArgHints("group", "the UUID of the group")]
[ArgHints("avatar", "URLARG", "the UUID of the avatar you wish to check with")] [ArgHints("avatar", "the UUID of the avatar you wish to check with")]
[Route(HttpVerbs.Get, "/IsGroupMember/{group}/{avatar}/{token}")] public object IsGroupMember(string group, string avatar)
public object IsGroupMember(string group, string avatar, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", "IsGroupMember", new [] { group, avatar }); return Failure("Invaild group UUID", "IsGroupMember", new [] { group, avatar });
@ -44,14 +35,9 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Unknown group")] [ReturnHintsFailure("Unknown group")]
[ReturnHintsFailure("Invaild group UUID")] [ReturnHintsFailure("Invaild group UUID")]
[ReturnHintsFailure("avatar lookup")] [ReturnHintsFailure("avatar lookup")]
[ArgHints("group", "URLARG", "the UUID of the group")] [ArgHints("group", "the UUID of the group")]
[Route(HttpVerbs.Get, "/GetGroupMembers/{group}/{token}")] public object GetGroupMembers(string group)
public object GetGroupMembers(string group, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", "GetGroupMembers", new [] { group }); return Failure("Invaild group UUID", "GetGroupMembers", new [] { group });
@ -66,16 +52,11 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Invaild group UUID")] [ReturnHintsFailure("Invaild group UUID")]
[ReturnHintsFailure("avatar lookup")] [ReturnHintsFailure("avatar lookup")]
[ReturnHintsFailure("Missing group GroupBanAccess power")] [ReturnHintsFailure("Missing group GroupBanAccess power")]
[ArgHints("group", "URLARG", "the UUID of the group")] [ArgHints("group", "the UUID of the group")]
[ArgHints("avatar", "URLARG", "the UUID of the avatar or Firstname Lastname")] [ArgHints("avatar", "the UUID of the avatar or Firstname Lastname")]
[ArgHints("state", "URLARG", "true to ban false to unban")] [ArgHints("state", "true to ban false to unban")]
[Route(HttpVerbs.Get, "/GroupBan/{group}/{avatar}/{state}/{token}")] public object GroupBan(string group, string avatar, string state)
public object GroupBan(string group, string avatar, string state, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", "GroupBan", new[] { group, avatar, state }); return Failure("Invaild group UUID", "GroupBan", new[] { group, avatar, state });
@ -110,15 +91,10 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Not in group")] [ReturnHintsFailure("Not in group")]
[ReturnHintsFailure("avatar lookup")] [ReturnHintsFailure("avatar lookup")]
[ReturnHintsFailure("Missing group Eject power")] [ReturnHintsFailure("Missing group Eject power")]
[ArgHints("group", "URLARG", "the UUID of the group")] [ArgHints("group", "the UUID of the group")]
[ArgHints("avatar", "URLARG", "the UUID of the avatar you wish to check with")] [ArgHints("avatar", "the UUID of the avatar you wish to check with")]
[Route(HttpVerbs.Get, "/GroupEject/{group}/{avatar}/{token}")] public object GroupEject(string group, string avatar)
public object GroupEject(string group, string avatar, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", "GroupEject", new [] { group, avatar }); return Failure("Invaild group UUID", "GroupEject", new [] { group, avatar });
@ -144,15 +120,10 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Invaild group UUID")] [ReturnHintsFailure("Invaild group UUID")]
[ReturnHintsFailure("Invaild role UUID")] [ReturnHintsFailure("Invaild role UUID")]
[ReturnHintsFailure("avatar lookup")] [ReturnHintsFailure("avatar lookup")]
[ArgHints("group", "URLARG", "the UUID of the group")] [ArgHints("group", "the UUID of the group")]
[ArgHints("avatar", "URLARG", "the UUID of the avatar you wish to check with")] [ArgHints("avatar", "the UUID of the avatar you wish to check with")]
[Route(HttpVerbs.Get, "/GroupAddRole/{group}/{avatar}/{role}/{token}")] public object GroupAddRole(string group, string avatar, string role)
public object GroupAddRole(string group, string avatar, string role, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", "GroupAddRole", new [] { group, avatar }); return Failure("Invaild group UUID", "GroupAddRole", new [] { group, avatar });
@ -183,16 +154,11 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Invaild group UUID")] [ReturnHintsFailure("Invaild group UUID")]
[ReturnHintsFailure("avatar lookup")] [ReturnHintsFailure("avatar lookup")]
[ReturnHintsFailure("Missing group Invite power")] [ReturnHintsFailure("Missing group Invite power")]
[ArgHints("group", "URLARG", "the UUID of the group")] [ArgHints("group", "the UUID of the group")]
[ArgHints("avatar", "URLARG", "the UUID of the avatar you wish to check with")] [ArgHints("avatar", "the UUID of the avatar you wish to check with")]
[ArgHints("role", "URLARG", "the UUID of the role to invite them at the word \"everyone\"")] [ArgHints("role", "the UUID of the role to invite them at the word \"everyone\"")]
[Route(HttpVerbs.Get, "/GroupInvite/{group}/{avatar}/{role}/{token}")] public object GroupInvite(string group, string avatar, string role)
public object GroupInvite(string group, string avatar, string role, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", "GroupInvite", new [] { group, avatar, role }); return Failure("Invaild group UUID", "GroupInvite", new [] { group, avatar, role });
@ -228,16 +194,11 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Title empty")] [ReturnHintsFailure("Title empty")]
[ReturnHintsFailure("Message empty")] [ReturnHintsFailure("Message empty")]
[ReturnHintsFailure("Missing group Notice power")] [ReturnHintsFailure("Missing group Notice power")]
[ArgHints("group", "URLARG", "the UUID of the group")] [ArgHints("group", "the UUID of the group")]
[ArgHints("title", "Text", "The title of the group notice")] [ArgHints("title", "The title of the group notice")]
[ArgHints("message", "Text", "The body of the group notice")] [ArgHints("message", "The body of the group notice")]
[Route(HttpVerbs.Post, "/Groupnotice/{group}/{token}")] public object Groupnotice(string group, string title, string message)
public object Groupnotice(string group, [FormField] string title, [FormField] string message, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", "Groupnotice", new [] { group, title, message }); return Failure("Invaild group UUID", "Groupnotice", new [] { group, title, message });
@ -267,15 +228,10 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Unknown group")] [ReturnHintsFailure("Unknown group")]
[ReturnHintsFailure("Invaild group UUID")] [ReturnHintsFailure("Invaild group UUID")]
[ReturnHintsFailure("Invaild role UUID")] [ReturnHintsFailure("Invaild role UUID")]
[ArgHints("group", "URLARG", "the UUID of the group")] [ArgHints("group", "the UUID of the group")]
[ArgHints("role", "URLARG", "tje UUID of the role")] [ArgHints("role", "the UUID of the role")]
[Route(HttpVerbs.Get, "/GroupActiveTitle/{group}/{token}")] public object GroupActiveTitle(string group, string role)
public object GroupActiveTitle(string group, string role, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", "GroupActiveTitle", new [] { group, role }); return Failure("Invaild group UUID", "GroupActiveTitle", new [] { group, role });
@ -296,14 +252,9 @@ namespace SecondBotEvents.Commands
[ReturnHints("Switching active group")] [ReturnHints("Switching active group")]
[ReturnHintsFailure("Unknown group")] [ReturnHintsFailure("Unknown group")]
[ReturnHintsFailure("Invaild group UUID")] [ReturnHintsFailure("Invaild group UUID")]
[ArgHints("group", "URLARG", "the UUID of the group")] [ArgHints("group", "the UUID of the group")]
[Route(HttpVerbs.Get, "/GroupActiveGroup/{group}/{token}")] public object GroupActiveGroup(string group)
public object GroupActiveGroup(string group, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", "GroupActiveGroup", new [] { group }); return Failure("Invaild group UUID", "GroupActiveGroup", new [] { group });
@ -324,17 +275,12 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Title empty")] [ReturnHintsFailure("Title empty")]
[ReturnHintsFailure("Message empty")] [ReturnHintsFailure("Message empty")]
[ReturnHintsFailure("Missing group Notice power")] [ReturnHintsFailure("Missing group Notice power")]
[ArgHints("group", "URLARG", "the UUID of the group")] [ArgHints("group", "the UUID of the group")]
[ArgHints("title", "Text", "The title of the group notice")] [ArgHints("title", "The title of the group notice")]
[ArgHints("message", "Text", "The body of the group notice")] [ArgHints("message", "The body of the group notice")]
[ArgHints("attachment", "URLARG", "the UUID of inventory you wish to attach")] [ArgHints("attachment", "the UUID of inventory you wish to attach")]
[Route(HttpVerbs.Post, "/Groupnotice/{group}/{attachment}/{token}")] public object GroupnoticeWithAttachment(string group, string title, string message, string attachment)
public object GroupnoticeWithAttachment(string group, [FormField] string title, [FormField] string message, string attachment, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", "GroupnoticeWithAttachment", new [] { group, title, message, attachment }); return Failure("Invaild group UUID", "GroupnoticeWithAttachment", new [] { group, title, message, attachment });
@ -367,13 +313,8 @@ namespace SecondBotEvents.Commands
[About("fetchs a list of all groups known to the bot")] [About("fetchs a list of all groups known to the bot")]
[ReturnHints("array UUID=name")] [ReturnHints("array UUID=name")]
[Route(HttpVerbs.Get, "/GetGroupList/{token}")] public object GetGroupList()
public object GetGroupList(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroups())); return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroups()));
} }
@ -382,14 +323,9 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Group is not currently known")] [ReturnHintsFailure("Group is not currently known")]
[ReturnHintsFailure("Invaild group UUID")] [ReturnHintsFailure("Invaild group UUID")]
[ReturnHintsFailure("Updating")] [ReturnHintsFailure("Updating")]
[ArgHints("group", "URLARG", "the UUID of the group")] [ArgHints("group", "the UUID of the group")]
[Route(HttpVerbs.Get, "/GetGroupRoles/{group}/{token}")] public object GetGroupRoles(string group)
public object GetGroupRoles(string group, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", "GetGroupRoles", new [] { group }); return Failure("Invaild group UUID", "GetGroupRoles", new [] { group });
@ -398,65 +334,23 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Unknown group", "GetGroupRoles", new [] { group }); return Failure("Unknown group", "GetGroupRoles", new [] { group });
} }
return Failure("@todo group role storage"); return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroupRoles(groupuuid)));
/*
GroupRoleDetails reply = new GroupRoleDetails();
reply.UpdateUnderway = false;
reply.RoleDataAge = -1;
reply.Roles = new Dictionary<string, string>();
if (bot.MyGroupRolesStorage.ContainsKey(groupuuid) == false)
{
reply.UpdateUnderway = true;
}
else
{
long dif = SecondbotHelpers.UnixTimeNow() - bot.MyGroupRolesStorage[groupuuid].Key;
reply.RoleDataAge = dif;
if (dif >= 120)
{
reply.UpdateUnderway = true;
}
foreach (GroupRole gr in bot.MyGroupRolesStorage[groupuuid].Value)
{
reply.Roles.Add(gr.ID.ToString(), gr.Name);
}
}
if (reply.UpdateUnderway == true)
{
getClient().Groups.RequestGroupRoles(groupuuid);
if (reply.Roles.Count == 0)
{
return Failure("Updating", "GetGroupRoles", new [] { group });
}
}
return BasicReply(JsonConvert.SerializeObject(reply), "GetGroupRoles", new [] { group });
*/
} }
[About("fetchs a list of all groups with unread messages")] [About("fetchs a list of all groups with unread messages")]
[ReturnHints("array UUID")] [ReturnHints("array UUID")]
[Route(HttpVerbs.Get, "/GroupchatListAllUnreadGroups/{token}")] public object GroupchatListAllUnreadGroups()
public object GroupchatListAllUnreadGroups(string token)
{ {
if (AllowToken(token) == false) return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetAllGroupsChatWithUnread()));
{
return Failure("Token not accepted");
}
return Failure("@todo group message storage");
} }
[About("fetchs a list of all groups with unread messages")] [About("fetchs a list of all groups with unread messages")]
[ReturnHints("true|false")] [ReturnHints("true|false")]
[ReturnHintsFailure("Unknown group")] [ReturnHintsFailure("Unknown group")]
[ReturnHintsFailure("group value is invaild")] [ReturnHintsFailure("group value is invaild")]
[ArgHints("group", "URLARG", "the UUID of the group")] [ArgHints("group", "the UUID of the group")]
[Route(HttpVerbs.Get, "/GroupchatGroupHasUnread/{group}/{token}")] public object GroupchatGroupHasUnread(string group)
public object GroupchatGroupHasUnread(string group,string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
UUID groupUUID = UUID.Zero; UUID groupUUID = UUID.Zero;
if(UUID.TryParse(group,out groupUUID) == false) if(UUID.TryParse(group,out groupUUID) == false)
{ {
@ -466,66 +360,46 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Unknown group", "GroupchatGroupHasUnread", new [] { group }); return Failure("Unknown group", "GroupchatGroupHasUnread", new [] { group });
} }
return Failure("@todo group message storage"); return BasicReply(master.DataStoreService.GetGroupChatHasUnread(groupUUID).ToString());
} }
[About("checks if there are any groups with unread messages")] [About("checks if there are any groups with unread messages")]
[ReturnHints("True|False")] [ReturnHints("True|False")]
[Route(HttpVerbs.Get, "/GroupchatAnyUnread/{token}")] public object GroupchatAnyUnread()
public object GroupchatAnyUnread(string token)
{ {
if (AllowToken(token) == false) return BasicReply(master.DataStoreService.GetGroupChatHasAnyUnread().ToString());
{
return Failure("Token not accepted");
}
return Failure("@todo group message storage");
} }
[About("Clears all group chat buffers at once")] [About("Clears all group chat buffers at once")]
[ReturnHints("ok")] [ReturnHints("ok")]
[Route(HttpVerbs.Get, "/GroupchatClearAll/{token}")] public object GroupchatClearAll()
public object GroupchatClearAll(string token)
{ {
if (AllowToken(token) == false) master.DataStoreService.clearGroupChat();
{ return BasicReply("ok");
return Failure("Token not accepted");
}
return Failure("@todo group message storage");
} }
[About("fetchs the groupchat history")] [About("fetchs the groupchat history")]
[ReturnHintsFailure("Group UUID invaild")] [ReturnHintsFailure("Group UUID invaild")]
[ReturnHints("Group Chat")] [ReturnHints("Group Chat")]
[ArgHints("group", "URLARG", "the UUID of the group")] [ArgHints("group", "the UUID of the group")]
[Route(HttpVerbs.Get, "/GroupchatHistory/{group}/{token}")] public object GroupchatHistory(string group)
public object GroupchatHistory(string group, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupUUID) == false) if (UUID.TryParse(group, out UUID groupUUID) == false)
{ {
return Failure("Group UUID invaild", "GroupchatHistory", new [] { group }); return Failure("Group UUID invaild", "GroupchatHistory", new [] { group });
} }
return Failure("@todo group message storage"); return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroupChatHistory(groupUUID)));
} }
[About("sends a message to the groupchat")] [About("sends a message to the groupchat")]
[ArgHints("group", "URLARG", "UUID of the group")] [ArgHints("group", "UUID of the group")]
[ArgHints("message", "Text", "the message to send")] [ArgHints("message", "the message to send")]
[ReturnHints("Sending")] [ReturnHints("Sending")]
[ReturnHintsFailure("Group UUID invaild")] [ReturnHintsFailure("Group UUID invaild")]
[ReturnHintsFailure("Opening groupchat - Please retry later")] [ReturnHintsFailure("Unknown group")]
[ReturnHintsFailure("Missing group JoinChat power")] public object Groupchat(string group, string message)
[Route(HttpVerbs.Post, "/Groupchat/{group}/{token}")]
public object Groupchat(string group, [FormField] string message, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
UUID groupUUID = UUID.Zero; UUID groupUUID = UUID.Zero;
if (UUID.TryParse(group, out groupUUID) == false) if (UUID.TryParse(group, out groupUUID) == false)
{ {
@ -535,7 +409,12 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Unknown group", "Groupchat", new [] { group, message }); return Failure("Unknown group", "Groupchat", new [] { group, message });
} }
return Failure("@todo groupchat"); if (getClient().Groups.GroupName2KeyCache.ContainsKey(groupUUID) == false)
{
return Failure("Unknown group", "Groupchat", new[] { group });
}
getClient().Self.InstantMessageGroup(groupUUID, message);
return BasicReply("Sending");
} }
} }
} }

View file

@ -1,6 +1,4 @@
using EmbedIO; using Newtonsoft.Json;
using EmbedIO.Routing;
using Newtonsoft.Json;
using OpenMetaverse; using OpenMetaverse;
using SecondBotEvents.Services; using SecondBotEvents.Services;
using System; using System;
@ -16,13 +14,8 @@ namespace SecondBotEvents.Commands
[About("Lists objects that are sculpty type in the current sim that the bot can see")] [About("Lists objects that are sculpty type in the current sim that the bot can see")]
[ReturnHints("A json object")] [ReturnHints("A json object")]
[Route(HttpVerbs.Get, "/ListSculptys/{token}")] public object ListSculptys()
public object ListSculptys(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
Dictionary<uint, Primitive> objects_copy = getClient().Network.CurrentSim.ObjectsPrimitives.Copy(); Dictionary<uint, Primitive> objects_copy = getClient().Network.CurrentSim.ObjectsPrimitives.Copy();
Dictionary<uint, uint> mapLocalID = new Dictionary<uint, uint>(); Dictionary<uint, uint> mapLocalID = new Dictionary<uint, uint>();
@ -72,107 +65,77 @@ namespace SecondBotEvents.Commands
} }
if (reply.Count == 0) if (reply.Count == 0)
{ {
return Failure("No objects found", "ListSculptys"); return Failure("No objects found");
} }
return BasicReply(JsonConvert.SerializeObject(reply), "ListSculptys",new string[] { }); return BasicReply(JsonConvert.SerializeObject(reply));
} }
[About("Fetchs the current bot")] [About("Fetchs the current bot")]
[ReturnHints("The build ID of the bot")] [ReturnHints("The build ID of the bot")]
[Route(HttpVerbs.Get, "/Version/{token}")] public object Version()
public object Version(string token)
{ {
if (AllowToken(token) == false) return BasicReply(master.GetVersion());
{
return Failure("Token not accepted");
}
return BasicReply(master.GetVersion(), "Version");
} }
[About("Fetchs the name of the bot")] [About("Fetchs the name of the bot")]
[ReturnHints("Firstname Lastname")] [ReturnHints("Firstname Lastname")]
[Route(HttpVerbs.Get, "/Name/{token}")] public object Name()
public object Name(string token)
{ {
if (AllowToken(token) == false) return BasicReply(getClient().Self.FirstName + " " + getClient().Self.LastName);
{
return Failure("Token not accepted");
}
return BasicReply(getClient().Self.FirstName + " " + getClient().Self.LastName, "Name");
} }
[About("Fetchs the current parcels name")] [About("Fetchs the current parcels name")]
[ReturnHints("Parcelname")] [ReturnHints("Parcelname")]
[ReturnHintsFailure("Error parcel not found")] [ReturnHintsFailure("Error parcel not found")]
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[Route(HttpVerbs.Get, "/ParcelName/{token}")] public object ParcelName()
public object ParcelName(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (getClient().Network.CurrentSim == null) if (getClient().Network.CurrentSim == null)
{ {
return Failure("Error not in a sim", "ParcelName"); return Failure("Error not in a sim");
} }
int localid = getClient().Parcels.GetParcelLocalID(getClient().Network.CurrentSim, getClient().Self.SimPosition); int localid = getClient().Parcels.GetParcelLocalID(getClient().Network.CurrentSim, getClient().Self.SimPosition);
if (getClient().Network.CurrentSim.Parcels.ContainsKey(localid) == false) if (getClient().Network.CurrentSim.Parcels.ContainsKey(localid) == false)
{ {
return Failure("Error parcel not found", "ParcelName"); return Failure("Error parcel not found");
} }
return BasicReply(getClient().Network.CurrentSim.Parcels[localid].Name, "ParcelName"); return BasicReply(getClient().Network.CurrentSim.Parcels[localid].Name);
} }
[About("Requests the current unixtime at the bot")] [About("Requests the current unixtime at the bot")]
[ReturnHints("Unixtime")] [ReturnHints("Unixtime")]
[Route(HttpVerbs.Get, "/UnixTimeNow/{token}")] public object UnixTimeNow()
public object UnixTimeNow(string token)
{ {
if (AllowToken(token) == false) return BasicReply(SecondbotHelpers.UnixTimeNow().ToString());
{
return Failure("Token not accepted");
}
return BasicReply(SecondbotHelpers.UnixTimeNow().ToString(), "UnixTimeNow");
} }
[About("Fetchs the current region name")] [About("Fetchs the current region name")]
[ReturnHints("Regionname")] [ReturnHints("Regionname")]
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[Route(HttpVerbs.Get, "/SimName/{token}")] public object SimName()
public object SimName(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (getClient().Network.CurrentSim == null) if (getClient().Network.CurrentSim == null)
{ {
return Failure("Error not in a sim", "SimName"); return Failure("Error not in a sim");
} }
return BasicReply(getClient().Network.CurrentSim.Name, "SimName"); return BasicReply(getClient().Network.CurrentSim.Name);
} }
[About("Fetchs the current location of the bot")] [About("Fetchs the current location of the bot")]
[ReturnHints("array of X,Y,Z values")] [ReturnHints("array of X,Y,Z values")]
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[Route(HttpVerbs.Get, "/GetPosition/{token}")] public object GetPosition()
public object GetPosition(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (getClient().Network.CurrentSim == null) if (getClient().Network.CurrentSim == null)
{ {
return Failure("Error not in a sim", "GetPosition"); return Failure("Error not in a sim");
} }
Dictionary<string, int> pos = new Dictionary<string, int>(); Dictionary<string, int> pos = new Dictionary<string, int>();
pos.Add("x", (int)Math.Round(getClient().Self.SimPosition.X)); pos.Add("x", (int)Math.Round(getClient().Self.SimPosition.X));
pos.Add("y", (int)Math.Round(getClient().Self.SimPosition.Y)); pos.Add("y", (int)Math.Round(getClient().Self.SimPosition.Y));
pos.Add("z", (int)Math.Round(getClient().Self.SimPosition.Z)); pos.Add("z", (int)Math.Round(getClient().Self.SimPosition.Z));
return BasicReply(JsonConvert.SerializeObject(pos), "GetPosition"); return BasicReply(JsonConvert.SerializeObject(pos));
} }
} }

View file

@ -1,7 +1,4 @@
using BetterSecondBot.Static; using BetterSecondBot.Static;
using EmbedIO;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Assets; using OpenMetaverse.Assets;
using SecondBotEvents.Services; using SecondBotEvents.Services;
@ -22,29 +19,19 @@ namespace SecondBotEvents.Commands
[ReturnHints("cleared")] [ReturnHints("cleared")]
[ReturnHints("No action")] [ReturnHints("No action")]
[ReturnHints("Event added")] [ReturnHints("Event added")]
[ArgHints("inventoryType", "URLARG", "Types: texture,sound,callcard,landmark,clothing,object,notecard,lsltext,lslbyte,animatn,gesture,mesh")] [ArgHints("inventoryType", "Types: texture,sound,callcard,landmark,clothing,object,notecard,lsltext,lslbyte,animatn,gesture,mesh")]
[ArgHints("outputTarget", "text", "HTTP url, channel, avatar UUID or clear to remove all events for the selected type")] [ArgHints("outputTarget", "HTTP url, channel, avatar UUID or clear to remove all events for the selected type")]
[Route(HttpVerbs.Post, "/SetInventoryUpdate/{inventoryType}/{token}")] public object SetInventoryUpdate(string inventoryType, string outputTarget)
public object SetInventoryUpdate(string inventoryType, [FormField] string outputTarget, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return Failure("@todo inventory update events"); return Failure("@todo inventory update events");
} }
[About("Uploads a new sound file to inventory")] [About("Uploads a new sound file to inventory")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ArgHints("sourcePath", "Text", "accepts a file path to a wave PCM file @ 44100")] [ArgHints("sourcePath", "accepts a file path to a wave PCM file @ 44100")]
[ArgHints("inventoryName", "URLARG", "the name in secondlife")] [ArgHints("inventoryName", "the name in secondlife")]
[Route(HttpVerbs.Post, "/UploadMediaWave/{inventoryName}/{token}")] public object UploadMediaWave(string sourcePath, string inventoryName)
public object UploadMediaWave([FormField] string sourcePath, string inventoryName, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
byte[] audioData = File.ReadAllBytes(sourcePath); byte[] audioData = File.ReadAllBytes(sourcePath);
InventoryFolder AA = getClient().Inventory.Store.RootFolder; InventoryFolder AA = getClient().Inventory.Store.RootFolder;
List<InventoryBase> T = getClient().Inventory.Store.GetContents(AA); List<InventoryBase> T = getClient().Inventory.Store.GetContents(AA);
@ -70,14 +57,9 @@ namespace SecondBotEvents.Commands
[ReturnHints("UUID of rezzed item")] [ReturnHints("UUID of rezzed item")]
[ReturnHints("Invaild item UUID")] [ReturnHints("Invaild item UUID")]
[ReturnHints("Unable to find item")] [ReturnHints("Unable to find item")]
[ArgHints("item", "URLARG", "UUID of item to rez")] [ArgHints("item", "UUID of item to rez")]
[Route(HttpVerbs.Get, "/RezObject/{item}/{token}")] public object RezObject(string item)
public object RezObject(string item, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(item, out UUID targetitem) == false) if (UUID.TryParse(item, out UUID targetitem) == false)
{ {
return Failure("Invaild item UUID: "+ item, "RezObject", new [] { item }); return Failure("Invaild item UUID: "+ item, "RezObject", new [] { item });
@ -97,15 +79,10 @@ namespace SecondBotEvents.Commands
[ReturnHints("invaild item uuid")] [ReturnHints("invaild item uuid")]
[ReturnHints("Item name is to short")] [ReturnHints("Item name is to short")]
[ReturnHints("Unable to find inventory item")] [ReturnHints("Unable to find inventory item")]
[ArgHints("item", "URLARG", "UUID of item/folder to name")] [ArgHints("item", "UUID of item/folder to name")]
[ArgHints("newname", "Text", "What we are changing it to")] [ArgHints("newname", "What we are changing it to")]
[Route(HttpVerbs.Post, "/RenameInventory/{item}/{token}")] public object RenameInventory(string item, string newname)
public object RenameInventory(string item, [FormField] string newname, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(item, out UUID target) == false) if (UUID.TryParse(item, out UUID target) == false)
{ {
return Failure("invaild item uuid", "RenameInventory", new [] { item, newname }); return Failure("invaild item uuid", "RenameInventory", new [] { item, newname });
@ -127,14 +104,9 @@ namespace SecondBotEvents.Commands
[About("Attempts to Remove the given inventory item")] [About("Attempts to Remove the given inventory item")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHints("invaild item uuid")] [ReturnHints("invaild item uuid")]
[ArgHints("item", "URLARG", "UUID of item")] [ArgHints("item", "UUID of item")]
[Route(HttpVerbs.Get, "/DeleteInventoryItem/{item}/{token}")] public object DeleteInventoryItem(string item)
public object DeleteInventoryItem(string item, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(item, out UUID target) == false) if (UUID.TryParse(item, out UUID target) == false)
{ {
return Failure("invaild item uuid", "DeleteInventoryItem", new [] { item }); return Failure("invaild item uuid", "DeleteInventoryItem", new [] { item });
@ -146,14 +118,9 @@ namespace SecondBotEvents.Commands
[About("Attempts to Remove the given inventory folder")] [About("Attempts to Remove the given inventory folder")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHints("invaild folder uuid")] [ReturnHints("invaild folder uuid")]
[ArgHints("folder", "URLARG", "UUID of folder")] [ArgHints("folder", "UUID of folder")]
[Route(HttpVerbs.Get, "/DeleteInventoryFolder/{folder}/{token}")] public object DeleteInventoryFolder(string folder)
public object DeleteInventoryFolder(string folder, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(folder, out UUID target) == false) if (UUID.TryParse(folder, out UUID target) == false)
{ {
return Failure("invaild folder uuid", "DeleteInventoryFolder", new [] { folder }); return Failure("invaild folder uuid", "DeleteInventoryFolder", new [] { folder });
@ -165,14 +132,9 @@ namespace SecondBotEvents.Commands
[About("Attempts to attach the given inventory item")] [About("Attempts to attach the given inventory item")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHints("invaild item uuid")] [ReturnHints("invaild item uuid")]
[ArgHints("item", "URLARG", "UUID of item")] [ArgHints("item", "UUID of item")]
[Route(HttpVerbs.Get, "/Attach/{item}/{token}")] public object Attach(string item)
public object Attach(string item, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(item,out UUID itemuuid) == false) if (UUID.TryParse(item,out UUID itemuuid) == false)
{ {
return Failure("invaild item uuid", "Attach", new [] { item }); return Failure("invaild item uuid", "Attach", new [] { item });
@ -185,14 +147,9 @@ namespace SecondBotEvents.Commands
[About("Attempts to Remove the given inventory folder")] [About("Attempts to Remove the given inventory folder")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHints("invaild item uuid")] [ReturnHints("invaild item uuid")]
[ArgHints("item", "URLARG", "UUID of item")] [ArgHints("item", "UUID of item")]
[Route(HttpVerbs.Get, "/Detach/{item}/{token}")] public object Detach(string item)
public object Detach(string item, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(item, out UUID itemuuid) == false) if (UUID.TryParse(item, out UUID itemuuid) == false)
{ {
return Failure("invaild item uuid", "Detach", new [] { item }); return Failure("invaild item uuid", "Detach", new [] { item });
@ -208,14 +165,9 @@ namespace SecondBotEvents.Commands
[ReturnHints("Cant find Clothing folder")] [ReturnHints("Cant find Clothing folder")]
[ReturnHints("Cant find target folder")] [ReturnHints("Cant find target folder")]
[ReturnHints("target folder is empty or so full I cant get it in 5 secs...")] [ReturnHints("target folder is empty or so full I cant get it in 5 secs...")]
[ArgHints("name", "URLARG", "Name of the folder")] [ArgHints("name", "Name of the folder")]
[Route(HttpVerbs.Get, "/Outfit/{name}/{token}")] public object Outfit(string name)
public object Outfit(string name, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (SecondbotHelpers.notempty(name) == false) if (SecondbotHelpers.notempty(name) == false)
{ {
return Failure("Named folder value is empty", "Outfit", new [] { name }); return Failure("Named folder value is empty", "Outfit", new [] { name });
@ -273,14 +225,8 @@ namespace SecondBotEvents.Commands
[About("Searchs the notecards folder for notecards, any older than 31 days are deleted.<br/>Depending on the number of notecards this might require multiple calls!")] [About("Searchs the notecards folder for notecards, any older than 31 days are deleted.<br/>Depending on the number of notecards this might require multiple calls!")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHints("Unable to find notecard folder")] [ReturnHints("Unable to find notecard folder")]
[Route(HttpVerbs.Get, "/InventoryPurgeNotecards/{token}")] public object InventoryPurgeNotecards()
[Obsolete]
public object InventoryPurgeNotecards(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
List<InventoryBase> T = getClient().Inventory.Store.GetContents(getClient().Inventory.Store.RootFolder); List<InventoryBase> T = getClient().Inventory.Store.GetContents(getClient().Inventory.Store.RootFolder);
InventoryBase NotecardFolder = null; InventoryBase NotecardFolder = null;
foreach (InventoryBase R in T) foreach (InventoryBase R in T)
@ -319,14 +265,9 @@ namespace SecondBotEvents.Commands
[About("converts a inventory uuid to a realworld uuid<br/>Needed for texture preview")] [About("converts a inventory uuid to a realworld uuid<br/>Needed for texture preview")]
[ReturnHints("Asset UUID or UUID zero")] [ReturnHints("Asset UUID or UUID zero")]
[ReturnHints("Invaild item uuid")] [ReturnHints("Invaild item uuid")]
[ArgHints("item", "URLARG", "inventory level UUID of item")] [ArgHints("item", "inventory level UUID of item")]
[Route(HttpVerbs.Get, "/getRealUUID/{item}/{token}")] public object getRealUUID(string item)
public object getRealUUID(string item, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(item, out UUID itemUUID) == false) if (UUID.TryParse(item, out UUID itemUUID) == false)
{ {
return Failure("Invaild item uuid", "getRealUUID", new [] { item }); return Failure("Invaild item uuid", "getRealUUID", new [] { item });
@ -341,15 +282,10 @@ namespace SecondBotEvents.Commands
[ReturnHints("Invaild avatar uuid")] [ReturnHints("Invaild avatar uuid")]
[ReturnHints("Invaild item uuid")] [ReturnHints("Invaild item uuid")]
[ReturnHints("Unable to find item")] [ReturnHints("Unable to find item")]
[ArgHints("item", "URLARG", "UUID of item")] [ArgHints("item", "UUID of item")]
[ArgHints("avatar", "URLARG", "a UUID or Firstname Lastname")] [ArgHints("avatar", "a UUID or Firstname Lastname")]
[Route(HttpVerbs.Get, "/SendItem/{item}/{avatar}/{token}")] public object SendItem(string item, string avatar)
public object SendItem(string item, string avatar, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar); ProcessAvatar(avatar);
if(avataruuid == UUID.Zero) if(avataruuid == UUID.Zero)
{ {
@ -374,15 +310,10 @@ namespace SecondBotEvents.Commands
[ReturnHints("Invaild avatar uuid")] [ReturnHints("Invaild avatar uuid")]
[ReturnHints("Invaild folter uuid")] [ReturnHints("Invaild folter uuid")]
[ReturnHints("Unable to find folder")] [ReturnHints("Unable to find folder")]
[ArgHints("item", "URLARG", "UUID of item")] [ArgHints("item", "UUID of item")]
[ArgHints("avatar", "URLARG", "a UUID or Firstname Lastname")] [ArgHints("avatar", "a UUID or Firstname Lastname")]
[Route(HttpVerbs.Get, "/SendFolder/{folder}/{avatar}/{token}")] public object SendFolder(string folder, string avatar)
public object SendFolder(string folder, string avatar, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
@ -401,8 +332,6 @@ namespace SecondBotEvents.Commands
return BasicReply("ok", "SendFolder", new [] { folder, avatar }); return BasicReply("ok", "SendFolder", new [] { folder, avatar });
} }
[About("Transfers a item [ARG 2] to a objects inventory [ARG 1] (And if set with the script running state [ARG 3])")] [About("Transfers a item [ARG 2] to a objects inventory [ARG 1] (And if set with the script running state [ARG 3])")]
[ReturnHints("Transfering running script")] [ReturnHints("Transfering running script")]
[ReturnHints("Transfering inventory")] [ReturnHints("Transfering inventory")]
@ -411,17 +340,11 @@ namespace SecondBotEvents.Commands
[ReturnHints("Unable to find inventory")] [ReturnHints("Unable to find inventory")]
[ReturnHints("Unable to find object")] [ReturnHints("Unable to find object")]
[ReturnHints("Invaild running")] [ReturnHints("Invaild running")]
[ArgHints("item", "URLARG", "UUID of item")] [ArgHints("item", "UUID of item")]
[ArgHints("object", "URLARG", "the uuid of the object")] [ArgHints("object", "the uuid of the object")]
[ArgHints("running", "URLARG", "true if you wish the transfered script to be running otherwise false")] [ArgHints("running", "true if you wish the transfered script to be running otherwise false")]
public object TransferInventoryToObject(string item, string objectuuid, string running)
[Route(HttpVerbs.Get, "/TransferInventoryToObject/{item}/{objectuuid}/{running}/{token}")]
public object TransferInventoryToObject(string item, string objectuuid, string running, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(item, out UUID itemuuid) == false) if (UUID.TryParse(item, out UUID itemuuid) == false)
{ {
return Failure("Invaild item uuid", "TransferInventoryToObject", new [] { item, objectuuid, running }); return Failure("Invaild item uuid", "TransferInventoryToObject", new [] { item, objectuuid, running });
@ -471,29 +394,19 @@ namespace SecondBotEvents.Commands
[About("Requests the inventory folder layout as a json object InventoryMapFolder<br/>Formated as follows<br/>InventoryMapItem<br/><ul><li>id: UUID</li><li>name: String</li><li>subfolders: InventoryMapFolder[]</li></ul>")] [About("Requests the inventory folder layout as a json object InventoryMapFolder<br/>Formated as follows<br/>InventoryMapItem<br/><ul><li>id: UUID</li><li>name: String</li><li>subfolders: InventoryMapFolder[]</li></ul>")]
[ReturnHints("array of InventoryMapFolder")] [ReturnHints("array of InventoryMapFolder")]
[ReturnHints("Error")] [ReturnHints("Error")]
[Route(HttpVerbs.Get, "/InventoryFolders/{token}")] public object InventoryFolders()
public object InventoryFolders(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
string reply = HelperInventory.MapFolderJson(getClient()); string reply = HelperInventory.MapFolderJson(getClient());
if (reply != null) return BasicReply(reply, "InventoryFolders"); if (reply != null) return BasicReply(reply, "InventoryFolders");
return Failure("Error", "InventoryFolders"); return Failure("Error", "InventoryFolders");
} }
[About("Requests folders limited to selected folder")] [About("Requests folders limited to selected folder")]
[ArgHints("targetfolder", "URLARG", "the UUID of the folder or root")] [ArgHints("targetfolder", "the UUID of the folder or root")]
[ReturnHints("single InventoryMapFolder")] [ReturnHints("single InventoryMapFolder")]
[ReturnHints("Error")] [ReturnHints("Error")]
[Route(HttpVerbs.Get, "/InventoryFoldersLimited/{targetfolder}/{token}")] public object InventoryFoldersLimited(string targetfolder)
public object InventoryFoldersLimited(string targetfolder,string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
string reply = HelperInventory.MapFolderJson(getClient(), targetfolder,false); string reply = HelperInventory.MapFolderJson(getClient(), targetfolder,false);
if (reply != null) return BasicReply(reply, "InventoryFoldersLimited"); if (reply != null) return BasicReply(reply, "InventoryFoldersLimited");
return Failure("Error", "InventoryFoldersLimited"); return Failure("Error", "InventoryFoldersLimited");
@ -502,14 +415,9 @@ namespace SecondBotEvents.Commands
[About("Requests the contents of a folder as an array of InventoryMapItem<br/>Formated as follows<br/>InventoryMapItem<br/><ul><li>id: UUID</li><li>name: String</li><li>typename: String</li></ul>")] [About("Requests the contents of a folder as an array of InventoryMapItem<br/>Formated as follows<br/>InventoryMapItem<br/><ul><li>id: UUID</li><li>name: String</li><li>typename: String</li></ul>")]
[ReturnHints("array of InventoryMapItem")] [ReturnHints("array of InventoryMapItem")]
[ReturnHints("Invaild folder UUID")] [ReturnHints("Invaild folder UUID")]
[ArgHints("folderUUID", "URLARG", "the folder to fetch (Found via: inventory/folders)")] [ArgHints("folderUUID", "the folder to fetch (Found via: inventory/folders)")]
[Route(HttpVerbs.Get, "/InventoryContents/{folderUUID}/{token}")] public object InventoryContents(string folderUUID)
public object InventoryContents(string folderUUID, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(folderUUID, out UUID folder) == false) if (UUID.TryParse(folderUUID, out UUID folder) == false)
{ {
return Failure("Invaild folder UUID", "InventoryContents", new [] { folderUUID }); return Failure("Invaild folder UUID", "InventoryContents", new [] { folderUUID });

View file

@ -1,7 +1,4 @@
using EmbedIO; using OpenMetaverse;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using OpenMetaverse;
using SecondBotEvents.Services; using SecondBotEvents.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -21,16 +18,11 @@ namespace SecondBotEvents.Commands
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Convert to vector has failed")] [ReturnHintsFailure("Convert to vector has failed")]
[ReturnHintsFailure("? value out of range 0-?")] [ReturnHintsFailure("? value out of range 0-?")]
[ArgHints("x", "URLARG", "X location to AutoPilot to")] [ArgHints("x", "X location to AutoPilot to")]
[ArgHints("y", "URLARG", "y location to AutoPilot to")] [ArgHints("y", "Y location to AutoPilot to")]
[ArgHints("z", "URLARG", "z location to AutoPilot to")] [ArgHints("z", "Z location to AutoPilot to")]
[Route(HttpVerbs.Get, "/AutoPilot/{x}/{y}/{z}/{token}")] public object AutoPilot(string x, string y, string z)
public object AutoPilot(string x, string y, string z, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (Vector3.TryParse("<" + x + "," + y + "," + z + ">", out Vector3 pos) == false) if (Vector3.TryParse("<" + x + "," + y + "," + z + ">", out Vector3 pos) == false)
{ {
return Failure("Convert to vector has failed", "AutoPilot", new [] { x, y, z }); return Failure("Convert to vector has failed", "AutoPilot", new [] { x, y, z });
@ -58,13 +50,8 @@ namespace SecondBotEvents.Commands
[About("Attempt to teleport to a new region")] [About("Attempt to teleport to a new region")]
[ReturnHints("ok")] [ReturnHints("ok")]
[Route(HttpVerbs.Get, "/AutoPilotStop/{token}")] public object AutoPilotStop()
public object AutoPilotStop(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
getClient().Self.AutoPilotCancel(); getClient().Self.AutoPilotCancel();
return BasicReply("ok", "AutoPilotStop"); return BasicReply("ok", "AutoPilotStop");
} }
@ -72,14 +59,9 @@ namespace SecondBotEvents.Commands
[About("Make the bot request the target avatar teleport to the bot")] [About("Make the bot request the target avatar teleport to the bot")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Invaild avatar UUID")] [ReturnHintsFailure("Invaild avatar UUID")]
[ArgHints("avatar", "URLARG", "Avatar UUID or Firstname Lastname")] [ArgHints("avatar", "Avatar UUID or Firstname Lastname")]
[Route(HttpVerbs.Get, "/SendTeleportLure/{avatar}/{token}")] public object SendTeleportLure(string avatar)
public object SendTeleportLure(string avatar,string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar); ProcessAvatar(avatar);
if(avataruuid == UUID.Zero) if(avataruuid == UUID.Zero)
{ {
@ -92,14 +74,9 @@ namespace SecondBotEvents.Commands
[About("Sends a teleport request (Move the bot to the avatar)")] [About("Sends a teleport request (Move the bot to the avatar)")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Invaild avatar UUID")] [ReturnHintsFailure("Invaild avatar UUID")]
[ArgHints("avatar", "URLARG", "Avatar UUID or Firstname Lastname")] [ArgHints("avatar", "Avatar UUID or Firstname Lastname")]
[Route(HttpVerbs.Get, "/RequestTeleport/{avatar}/{token}")] public object RequestTeleport(string avatar)
public object RequestTeleport(string avatar, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
@ -113,14 +90,9 @@ namespace SecondBotEvents.Commands
[About("Makes the bot fly (or not)")] [About("Makes the bot fly (or not)")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Invaild mode")] [ReturnHintsFailure("Invaild mode")]
[ArgHints("mode", "URLARG", "true: Start flying, false: stop flying (super fun at height)")] [ArgHints("mode", "true: Start flying, false: stop flying (super fun at height)")]
[Route(HttpVerbs.Get, "/Fly/{mode}/{token}")] public object Fly(string mode)
public object Fly(string mode, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (bool.TryParse(mode, out bool flymode) == false) if (bool.TryParse(mode, out bool flymode) == false)
{ {
return Failure("Invaild mode", "Fly", new [] { mode }); return Failure("Invaild mode", "Fly", new [] { mode });
@ -130,20 +102,13 @@ namespace SecondBotEvents.Commands
return BasicReply("ok", "Fly", new [] { mode }); return BasicReply("ok", "Fly", new [] { mode });
} }
[About("Rotates the bot to face a vector from its current location")] [About("Rotates the bot to face a vector from its current location")]
[ReturnHints("true|false")] [ReturnHints("true|false")]
[ReturnHintsFailure("Invaild vector")] [ReturnHintsFailure("Invaild vector")]
[ReturnHintsFailure("Vector ? value is out of range 0-?")] [ReturnHintsFailure("Vector ? value is out of range 0-?")]
[ArgHints("vector", "Text", "a vector to face eg <123,45,44>")] [ArgHints("vector", "a vector to face eg <123,45,44>")]
[Route(HttpVerbs.Post, "/RotateToFaceVector/{token}")] public object RotateToFaceVector(string vector)
public object RotateToFaceVector([FormField] string vector, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (Vector3.TryParse(vector, out Vector3 pos) == false) if (Vector3.TryParse(vector, out Vector3 pos) == false)
{ {
return Failure("Invaild vector", "RotateToFaceVector", new [] { vector }); return Failure("Invaild vector", "RotateToFaceVector", new [] { vector });
@ -167,14 +132,9 @@ namespace SecondBotEvents.Commands
[ReturnHints("true|false")] [ReturnHints("true|false")]
[ReturnHintsFailure("Invaild avatar UUID")] [ReturnHintsFailure("Invaild avatar UUID")]
[ReturnHintsFailure("Unable to see avatar")] [ReturnHintsFailure("Unable to see avatar")]
[ArgHints("avatar", "URLARG", "An avatar UUID or Firstname Lastname")] [ArgHints("avatar", "An avatar UUID or Firstname Lastname")]
[Route(HttpVerbs.Post, "/RotateToFace/{avatar}/{token}")] public object RotateToFace(string avatar)
public object RotateToFace(string avatar, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar); ProcessAvatar(avatar);
if(avataruuid == UUID.Zero) if(avataruuid == UUID.Zero)
{ {
@ -187,18 +147,12 @@ namespace SecondBotEvents.Commands
return BasicReply(getClient().Self.Movement.TurnToward(getClient().Network.CurrentSim.AvatarPositions[avataruuid], true).ToString(), "RotateToFace", new [] { avatar }); return BasicReply(getClient().Self.Movement.TurnToward(getClient().Network.CurrentSim.AvatarPositions[avataruuid], true).ToString(), "RotateToFace", new [] { avatar });
} }
[About("Rotates the avatar to face a rotation from north in Degrees")] [About("Rotates the avatar to face a rotation from north in Degrees")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Unable to process rotation")] [ReturnHintsFailure("Unable to process rotation")]
[ArgHints("deg", "URLARG", "0 to 360")] [ArgHints("deg", "0 to 360")]
[Route(HttpVerbs.Post, "/RotateTo/{deg}/{token}")] public object RotateTo(string deg)
public object RotateTo(string deg, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (float.TryParse(deg, out float target_yaw) == true) if (float.TryParse(deg, out float target_yaw) == true)
{ {
return Failure("Unable to process rotation", "RotateTo", new [] { deg }); return Failure("Unable to process rotation", "RotateTo", new [] { deg });
@ -232,17 +186,12 @@ namespace SecondBotEvents.Commands
[About("Attempt to teleport to a new region")] [About("Attempt to teleport to a new region")]
[ReturnHintsFailure("Error Unable to Teleport to location")] [ReturnHintsFailure("Error Unable to Teleport to location")]
[ReturnHints("Accepted")] [ReturnHints("Accepted")]
[ArgHints("region", "URLARG", "the name of the region we are going to")] [ArgHints("region", "the name of the region we are going to")]
[ArgHints("x", "URLARG", "X location to teleport to")] [ArgHints("x", "X location to teleport to")]
[ArgHints("y", "URLARG", "y location to teleport to")] [ArgHints("y", "y location to teleport to")]
[ArgHints("z", "URLARG", "z location to teleport to")] [ArgHints("z", "z location to teleport to")]
[Route(HttpVerbs.Get, "/Teleport/{region}/{x}/{y}/{z}/{token}")] public object Teleport(string region, string x, string y, string z)
public object Teleport(string region, string x, string y, string z, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
bool status = TeleportRequest(new [] { region, x, y, z }); bool status = TeleportRequest(new [] { region, x, y, z });
if (status == false) if (status == false)
{ {
@ -255,14 +204,9 @@ namespace SecondBotEvents.Commands
[About("Attempt to teleport to a new region via a SL url")] [About("Attempt to teleport to a new region via a SL url")]
[ReturnHintsFailure("slurl is empty")] [ReturnHintsFailure("slurl is empty")]
[ReturnHints("True|False")] [ReturnHints("True|False")]
[ArgHints("slurl", "Text", "a full SLurl")] [ArgHints("slurl", "a full SLurl")]
[Route(HttpVerbs.Post, "/TeleportSLURL/{token}")] public object TeleportSLURL(string slurl)
public object TeleportSLURL([FormField] string slurl, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (SecondbotHelpers.notempty(slurl) == false) if (SecondbotHelpers.notempty(slurl) == false)
{ {
return Failure("slurl is empty", "TeleportSLURL", new [] { slurl }); return Failure("slurl is empty", "TeleportSLURL", new [] { slurl });

View file

@ -1,7 +1,4 @@
using EmbedIO; using OpenMetaverse;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using OpenMetaverse;
using SecondBotEvents.Services; using SecondBotEvents.Services;
@ -17,15 +14,10 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Collection value is empty")] [ReturnHintsFailure("Collection value is empty")]
[ReturnHintsFailure("Content value is empty")] [ReturnHintsFailure("Content value is empty")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ArgHints("collection", "URLARG", "The name of the collection")] [ArgHints("collection", "The name of the collection")]
[ArgHints("content", "String", "The text to add to the collection")] [ArgHints("content", "The text to add to the collection")]
[Route(HttpVerbs.Post, "/NotecardAdd/{collection}/{token}")] public object NotecardAdd(string collection, string content)
public object NotecardAdd(string collection, [FormField] string content, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (SecondbotHelpers.notempty(collection) == false) if (SecondbotHelpers.notempty(collection) == false)
{ {
return Failure("Collection value is empty", "NotecardAdd", new [] { collection, content }); return Failure("Collection value is empty", "NotecardAdd", new [] { collection, content });
@ -41,14 +33,9 @@ namespace SecondBotEvents.Commands
[About("Clears the contents of a collection")] [About("Clears the contents of a collection")]
[ReturnHintsFailure("Collection value is empty")] [ReturnHintsFailure("Collection value is empty")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ArgHints("collection", "URLARG", "The name of the collection")] [ArgHints("collection", "The name of the collection")]
[Route(HttpVerbs.Get, "/NotecardClear/{collection}/{token}")] public object NotecardClear(string collection)
public object NotecardClear(string collection, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (SecondbotHelpers.notempty(collection) == false) if (SecondbotHelpers.notempty(collection) == false)
{ {
return Failure("Collection value is empty", "NotecardClear", new [] { collection }); return Failure("Collection value is empty", "NotecardClear", new [] { collection });
@ -62,16 +49,11 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Invaild avatar uuid")] [ReturnHintsFailure("Invaild avatar uuid")]
[ReturnHintsFailure("No content in notecard storage ?")] [ReturnHintsFailure("No content in notecard storage ?")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ArgHints("avatar", "URLARG", "The UUID or Name of an avatar")] [ArgHints("avatar", "The UUID or Name of an avatar")]
[ArgHints("collection", "URLARG", "The name of the collection")] [ArgHints("collection", "The name of the collection")]
[ArgHints("notecardname", "URLARG", "What to call the created notecard")] [ArgHints("notecardname", "What to call the created notecard")]
[Route(HttpVerbs.Get, "/NotecardSend/{avatar}/{collection}/{notecardname}/{token}")] public object NotecardSend(string avatar, string collection, string notecardname)
public object NotecardSend(string avatar, string collection, string notecardname, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (SecondbotHelpers.notempty(collection) == false) if (SecondbotHelpers.notempty(collection) == false)
{ {
return Failure("Collection value is empty", "NotecardSend", new [] { avatar, collection, notecardname }); return Failure("Collection value is empty", "NotecardSend", new [] { avatar, collection, notecardname });
@ -93,16 +75,11 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Content value is empty")] [ReturnHintsFailure("Content value is empty")]
[ReturnHintsFailure("Invaild avatar uuid")] [ReturnHintsFailure("Invaild avatar uuid")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ArgHints("avatar", "URLARG", "The UUID or Name of an avatar")] [ArgHints("avatar", "The UUID or Name of an avatar")]
[ArgHints("content", "String", "The text to add to the collection")] [ArgHints("content", "The text to add to the collection")]
[ArgHints("notecardname", "URLARG", "What to call the created notecard")] [ArgHints("notecardname", "What to call the created notecard")]
[Route(HttpVerbs.Post, "/NotecardDirectSend/{avatar}/{notecardname}/{token}")] public object NotecardDirectSend(string avatar, string content, string notecardname)
public object NotecardDirectSend(string avatar, [FormField] string content, string notecardname, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (SecondbotHelpers.notempty(notecardname) == false) if (SecondbotHelpers.notempty(notecardname) == false)
{ {
return Failure("notecardname value is empty", "NotecardDirectSend", new[] { avatar, content, notecardname }); return Failure("notecardname value is empty", "NotecardDirectSend", new[] { avatar, content, notecardname });

View file

@ -1,7 +1,4 @@
using EmbedIO; using Newtonsoft.Json;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using Newtonsoft.Json;
using OpenMetaverse; using OpenMetaverse;
using SecondBotEvents.Services; using SecondBotEvents.Services;
using System; using System;
@ -22,15 +19,10 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[ReturnHintsFailure("Parcel data not ready")] [ReturnHintsFailure("Parcel data not ready")]
[ReturnHintsFailure("Invaild amount")] [ReturnHintsFailure("Invaild amount")]
[ArgHints("amount", "URLARG", "The amount to sell the parcel for from 1 to 9999999")] [ArgHints("amount", "The amount to sell the parcel for from 1 to 9999999, can be zero if avatar is assigned.")]
[ArgHints("avatar", "URLARG", "Avatar uuid or Firstname Lastname or \"none\" who we are locking the sale to")] [ArgHints("avatar", "Avatar uuid or Firstname Lastname or \"none\" who we are locking the sale to")]
[Route(HttpVerbs.Get, "/SetParcelSale/{amount}/{avatar}/{token}")] public object SetParcelSale(string amount,string avatar)
public object SetParcelSale(string amount,string avatar,string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if(tests.Key == false) if(tests.Key == false)
{ {
@ -67,13 +59,8 @@ namespace SecondBotEvents.Commands
[ReturnHints("traffic value")] [ReturnHints("traffic value")]
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[ReturnHintsFailure("Parcel data not ready")] [ReturnHintsFailure("Parcel data not ready")]
[Route(HttpVerbs.Get, "/GetParcelTraffic/{token}")] public object GetParcelTraffic()
public object GetParcelTraffic(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
@ -87,16 +74,11 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[ReturnHintsFailure("Parcel data not ready")] [ReturnHintsFailure("Parcel data not ready")]
[ReturnHintsFailure("Invaild amount")] [ReturnHintsFailure("Invaild amount")]
[ArgHints("x", "URLARG", "X point for landing")] [ArgHints("x", "X point for landing")]
[ArgHints("y", "URLARG", "Y point for landing")] [ArgHints("y", "Y point for landing")]
[ArgHints("z", "URLARG", "Z point for landing")] [ArgHints("z", "Z point for landing")]
[Route(HttpVerbs.Get, "/SetParcelLandingZone/{x}/{y}/{z}/{token}")] public object SetParcelLandingZone(string x, string y, string z)
public object SetParcelLandingZone(string x, string y, string z, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
@ -126,14 +108,9 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[ReturnHintsFailure("Parcel data not ready")] [ReturnHintsFailure("Parcel data not ready")]
[ReturnHintsFailure("Parcel name is empty")] [ReturnHintsFailure("Parcel name is empty")]
[ArgHints("name", "URLARG", "The new name of the parcel")] [ArgHints("name", "The new name of the parcel")]
[Route(HttpVerbs.Get, "/SetParcelName/{name}/{token}")] public object SetParcelName(string name)
public object SetParcelName(string name, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
@ -152,14 +129,9 @@ namespace SecondBotEvents.Commands
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[ReturnHintsFailure("Parcel data not ready")] [ReturnHintsFailure("Parcel data not ready")]
[ArgHints("desc", "Text", "The new desc of the parcel")] [ArgHints("desc", "The new desc of the parcel")]
[Route(HttpVerbs.Post, "/SetParcelDesc/{token}")] public object SetParcelDesc(string desc)
public object SetParcelDesc([FormField] string desc, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
@ -174,13 +146,8 @@ namespace SecondBotEvents.Commands
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[ReturnHintsFailure("Parcel data not ready")] [ReturnHintsFailure("Parcel data not ready")]
[Route(HttpVerbs.Get, "/GetParcelDesc/{token}")] public object GetParcelDesc()
public object GetParcelDesc(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
@ -193,13 +160,8 @@ namespace SecondBotEvents.Commands
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[ReturnHintsFailure("Parcel data not ready")] [ReturnHintsFailure("Parcel data not ready")]
[Route(HttpVerbs.Get, "/GetParcelFlags/{token}")] public object GetParcelFlags()
public object GetParcelFlags(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
@ -218,14 +180,9 @@ namespace SecondBotEvents.Commands
[About("Ejects an avatar")] [About("Ejects an avatar")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Invaild avatar")] [ReturnHintsFailure("Invaild avatar")]
[ArgHints("avatar", "URLARG", "uuid of the avatar or Firstname Lastname")] [ArgHints("avatar", "uuid of the avatar or Firstname Lastname")]
[Route(HttpVerbs.Get, "/ParcelEject/{avatar}/{token}")] public object ParcelEject(string avatar)
public object ParcelEject(string avatar,string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar); ProcessAvatar(avatar);
if(avataruuid == UUID.Zero) if(avataruuid == UUID.Zero)
{ {
@ -237,13 +194,8 @@ namespace SecondBotEvents.Commands
[About("Abandons the parcel the bot is currently on, returning it to Linden's or Estate owner")] [About("Abandons the parcel the bot is currently on, returning it to Linden's or Estate owner")]
[ReturnHints("ok")] [ReturnHints("ok")]
[Route(HttpVerbs.Get, "/AbandonLand/{token}")] public object AbandonLand()
public object AbandonLand(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
@ -260,14 +212,9 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Parcel data not ready")] [ReturnHintsFailure("Parcel data not ready")]
[ReturnHintsFailure("Invaild avatar")] [ReturnHintsFailure("Invaild avatar")]
[ReturnHintsFailure("Avatar is in the blacklist")] [ReturnHintsFailure("Avatar is in the blacklist")]
[ArgHints("avatar", "URLARG", "uuid of the avatar or Firstname Lastname")] [ArgHints("avatar", "uuid of the avatar or Firstname Lastname")]
[Route(HttpVerbs.Get, "/ParcelBan/{avatar}/{token}")] public object ParcelBan(string avatar)
public object ParcelBan(string avatar, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
@ -306,14 +253,9 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Parcel data not ready")] [ReturnHintsFailure("Parcel data not ready")]
[ReturnHintsFailure("Invaild avatar")] [ReturnHintsFailure("Invaild avatar")]
[ReturnHintsFailure("Avatar is already unbanned")] [ReturnHintsFailure("Avatar is already unbanned")]
[ArgHints("avatar", "URLARG", "uuid of the avatar or Firstname Lastname")] [ArgHints("avatar", "uuid of the avatar or Firstname Lastname")]
[Route(HttpVerbs.Get, "/ParcelUnBan/{avatar}/{token}")] public object ParcelUnBan(string avatar)
public object ParcelUnBan(string avatar, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
@ -349,14 +291,9 @@ namespace SecondBotEvents.Commands
[ReturnHints("true|false")] [ReturnHints("true|false")]
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[ReturnHintsFailure("Parcel data not ready")] [ReturnHintsFailure("Parcel data not ready")]
[ArgHints("musicurl", "URLARG", "The new name of the parcel")] [ArgHints("musicurl", "The new name of the parcel")]
[Route(HttpVerbs.Get, "/SetParcelMusic/{musicurl}/{token}")] public object SetParcelMusic(string musicurl)
public object SetParcelMusic(string musicurl, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
@ -375,14 +312,9 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Unable to set flag ...")] [ReturnHintsFailure("Unable to set flag ...")]
[ReturnHintsFailure("Flag: ? is unknown")] [ReturnHintsFailure("Flag: ? is unknown")]
[ReturnHintsFailure("Flag: ? missing \"=\"")] [ReturnHintsFailure("Flag: ? missing \"=\"")]
[ArgHints("escapedflagdata", "Text", "repeatable flag data split by ::: formated Flag=True|False")] [ArgHints("escapedflagdata", "repeatable flag data split by ::: formated Flag=True|False")]
[Route(HttpVerbs.Post, "/SetParcelFlag/{escapedflagdata}/{token}")] public object SetParcelFlag(string escapedflagdata)
public object SetParcelFlag([FormField] string escapedflagdata, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
@ -437,14 +369,9 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[ReturnHintsFailure("Parcel data not ready")] [ReturnHintsFailure("Parcel data not ready")]
[ReturnHintsFailure("Invaild avatar UUID")] [ReturnHintsFailure("Invaild avatar UUID")]
[ArgHints("avatar", "URLARG", "avatar uuid or Firstname Lastname")] [ArgHints("avatar", "avatar uuid or Firstname Lastname")]
[Route(HttpVerbs.Get, "/ParcelReturnTargeted/{avatar}/{token}")] public object ParcelReturnTargeted(string avatar)
public object ParcelReturnTargeted(string avatar, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
@ -462,17 +389,13 @@ namespace SecondBotEvents.Commands
[About("transfers the current parcel ownership to the assigned group")] [About("transfers the current parcel ownership to the assigned group")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ArgHints("group", "The group uuid to assign")]
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[ReturnHintsFailure("Parcel data not ready")] [ReturnHintsFailure("Parcel data not ready")]
[ReturnHintsFailure("Invaild group uuid")] [ReturnHintsFailure("Invaild group uuid")]
[ReturnHintsFailure("Not in group")] [ReturnHintsFailure("Not in group")]
[Route(HttpVerbs.Get, "/ParcelDeedToGroup/{group}/{token}")] public object ParcelDeedToGroup(string group)
public object ParcelDeedToGroup(string group, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
@ -502,14 +425,9 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Parcel sale locked to other avatars")] [ReturnHintsFailure("Parcel sale locked to other avatars")]
[ReturnHintsFailure("Parcel sale price and amount do not match")] [ReturnHintsFailure("Parcel sale price and amount do not match")]
[ReturnHintsFailure("Invaild amount")] [ReturnHintsFailure("Invaild amount")]
[ArgHints("amount", "URLARG", "amount to pay for the parcel (min 1)")] [ArgHints("amount", "amount to pay for the parcel (min 1)")]
[Route(HttpVerbs.Get, "/ParcelBuy/{amount}/{token}")] public object ParcelBuy(string amount)
public object ParcelBuy(string amount, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
@ -548,15 +466,10 @@ namespace SecondBotEvents.Commands
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Invaild avatar UUID")] [ReturnHintsFailure("Invaild avatar UUID")]
[ReturnHintsFailure("Invaild state")] [ReturnHintsFailure("Invaild state")]
[ArgHints("avatar", "URLARG", "avatar uuid or Firstname Lastname")] [ArgHints("avatar", "avatar uuid or Firstname Lastname")]
[ArgHints("state", "URLARG", "setting state to false will unfreeze or true to freeze")] [ArgHints("state", "setting state to false will unfreeze or true to freeze")]
[Route(HttpVerbs.Get, "/ParcelFreeze/{avatar}/{state}/{token}")] public object ParcelFreeze(string avatar, string state)
public object ParcelFreeze(string avatar, string state, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (bool.TryParse(state, out bool freezestate) == false) if (bool.TryParse(state, out bool freezestate) == false)
{ {
return Failure("Invaild state", "ParcelFreeze", new [] { avatar, state }); return Failure("Invaild state", "ParcelFreeze", new [] { avatar, state });
@ -575,13 +488,8 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("json object: GetParcelBanlistObject")] [ReturnHintsFailure("json object: GetParcelBanlistObject")]
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[ReturnHintsFailure("Parcel data not ready")] [ReturnHintsFailure("Parcel data not ready")]
[Route(HttpVerbs.Get, "/GetParcelBanlist/{token}")] public object GetParcelBanlist()
public object GetParcelBanlist(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
@ -623,14 +531,9 @@ namespace SecondBotEvents.Commands
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Invaild object uuid")] [ReturnHintsFailure("Invaild object uuid")]
[ReturnHintsFailure("Unable to find object")] [ReturnHintsFailure("Unable to find object")]
[ArgHints("objectuuid", "URLARG", "object UUID to unrez")] [ArgHints("objectuuid", "object UUID to unrez")]
[Route(HttpVerbs.Get, "/UnRezObject/{objectuuid}/{token}")] public object UnRezObject(string objectuuid)
public object UnRezObject(string objectuuid,string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(objectuuid, out UUID targetobject) == false) if (UUID.TryParse(objectuuid, out UUID targetobject) == false)
{ {
return Failure("Invaild object uuid", "UnRezObject", new [] { objectuuid }); return Failure("Invaild object uuid", "UnRezObject", new [] { objectuuid });
@ -666,14 +569,9 @@ namespace SecondBotEvents.Commands
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]
[ReturnHintsFailure("Parcel data not ready")] [ReturnHintsFailure("Parcel data not ready")]
[ArgHints("escapedflagdata", "Text", "repeatable flag data split by ::: formated Flag=True|False")] [ArgHints("escapedflagdata", "repeatable flag data split by ::: formated Flag=True|False")]
[Route(HttpVerbs.Get, "/ParcelSetMedia/{token}")] public object ParcelSetMedia(string escapedflagdata)
public object ParcelSetMedia([FormField] string escapedflagdata, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {

View file

@ -1,7 +1,4 @@
using EmbedIO; using OpenMetaverse;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using OpenMetaverse;
using SecondBotEvents.Services; using SecondBotEvents.Services;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -16,67 +13,48 @@ namespace SecondBotEvents.Commands
[About("Makes the bot teleport to its home region")] [About("Makes the bot teleport to its home region")]
[ReturnHints("ok")] [ReturnHints("ok")]
[Route(HttpVerbs.Get, "/GoHome/{token}")] public object GoHome()
public object GoHome(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return Failure("@todo home system"); return Failure("@todo home system");
} }
[About("Makes the bot turn to face avatar and point at them (if found)")] [About("Makes the bot turn to face a avatar and point at it (if found)")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ArgHints("targetUUID", "UUID of a avatar to point at")]
[ReturnHintsFailure("Cant find UUID in sim")] [ReturnHintsFailure("Cant find UUID in sim")]
[Route(HttpVerbs.Get, "/PointAt/{avatar}/{token}")] public object PointAt(string targetUUID)
public object PointAt(string avatar, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar);
if (getClient().Network.CurrentSim.AvatarPositions.ContainsKey(avataruuid) == false) if (getClient().Network.CurrentSim.AvatarPositions.ContainsKey(avataruuid) == false)
{ {
return Failure("Cant find UUID in sim", "PointAt", new [] { avatar }); return Failure("Cant find UUID in sim", "PointAt", new [] { targetUUID });
} }
ProcessAvatar(targetUUID);
getClient().Self.Stand(); getClient().Self.Stand();
getClient().Self.Movement.TurnToward(getClient().Network.CurrentSim.AvatarPositions[avataruuid]); getClient().Self.Movement.TurnToward(getClient().Network.CurrentSim.AvatarPositions[avataruuid]);
getClient().Self.Movement.SendUpdate(); getClient().Self.Movement.SendUpdate();
getClient().Self.AnimationStart(Animations.POINT_YOU, true); getClient().Self.AnimationStart(Animations.POINT_YOU, true);
getClient().Self.PointAtEffect(getClient().Self.AgentID, avataruuid, new Vector3d(0, 0, 0), PointAtType.Select, UUID.Random()); getClient().Self.PointAtEffect(getClient().Self.AgentID, avataruuid, new Vector3d(0, 0, 0), PointAtType.Select, UUID.Random());
getClient().Self.BeamEffect(getClient().Self.AgentID, avataruuid, new Vector3d(0, 0, 2), new Color4(255, 255, 255, 1), (float)3.0, UUID.Random()); getClient().Self.BeamEffect(getClient().Self.AgentID, avataruuid, new Vector3d(0, 0, 2), new Color4(255, 255, 255, 1), (float)3.0, UUID.Random());
return BasicReply("ok", "PointAt", new [] { avatar }); return BasicReply("ok", "PointAt", new [] { targetUUID });
} }
[About("Reads a value from the KeyValue storage (temp unless SQL is enabled)")] [About("Reads a value from the KeyValue storage (temp unless SQL is enabled)")]
[ReturnHints("value")] [ReturnHints("value")]
[ReturnHintsFailure("Unknown Key: KeyName")] [ReturnHintsFailure("Unknown Key: KeyName")]
[ArgHints("Key", "URLARG", "the key we are trying to read from")] [ArgHints("Key", "the key we are trying to read from")]
[Route(HttpVerbs.Get, "/ReadKeyValue/{Key}/{token}")] public object ReadKeyValue(string Key)
public object ReadKeyValue(string Key, string token)
{ {
if (AllowToken(token) == false) return BasicReply(master.DataStoreService.GetKeyValue(Key));
{
return Failure("Token not accepted");
}
return Failure("@todo key value storage");
} }
[About("sets a value for KeyValue storage (temp unless SQL is enabled)")] [About("sets a value for KeyValue storage (temp unless SQL is enabled)")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Key is empty")] [ReturnHintsFailure("Key is empty")]
[ReturnHintsFailure("Value is empty")] [ReturnHintsFailure("Value is empty")]
[ArgHints("Key", "URLARG", "the key we are trying to set")] [ArgHints("Key", "the key we are trying to set")]
[ArgHints("Value", "string", "the value we are tring to put on the key")] [ArgHints("Value", "the value we are tring to put on the key")]
[Route(HttpVerbs.Post, "/SetKeyValue/{Key}/{token}")] public object SetKeyValue(string Key, string Value)
public object SetKeyValue(string Key, [FormField] string Value, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (SecondbotHelpers.isempty(Key) == false) if (SecondbotHelpers.isempty(Key) == false)
{ {
return Failure("Key is empty", "SetKeyValue", new[] { Key, Value }); return Failure("Key is empty", "SetKeyValue", new[] { Key, Value });
@ -85,38 +63,30 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Value is empty", "SetKeyValue", new[] { Key, Value }); return Failure("Value is empty", "SetKeyValue", new[] { Key, Value });
} }
return Failure("@todo key value storage"); master.DataStoreService.SetKeyValue(Key, Value);
return BasicReply("ok");
} }
[About("Reads a value from the KeyValue storage (temp unless SQL is enabled)")] [About("Reads a value from the KeyValue storage (temp unless SQL is enabled)")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Key is empty")] [ReturnHintsFailure("Key is empty")]
[ArgHints("Key", "URLARG", "the key we are trying to clear")] [ArgHints("Key", "the key we are trying to clear")]
[Route(HttpVerbs.Get, "/ClearKeyValue/{Key}/{token}")] public object ClearKeyValue(string Key)
public object ClearKeyValue(string Key, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (SecondbotHelpers.isempty(Key) == false) if (SecondbotHelpers.isempty(Key) == false)
{ {
return Failure("Key is empty", "SetKeyValue", new[] { Key }); return Failure("Key is empty", "SetKeyValue", new[] { Key });
} }
return Failure("@todo key value storage"); master.DataStoreService.ClearKeyValue(Key);
return BasicReply("ok");
} }
[About("Makes the bot sit on the ground or on a object if it can see it")] [About("Makes the bot sit on the ground or on a object if it can see it")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Invaild object UUID")] [ReturnHintsFailure("Invaild object UUID")]
[ArgHints("target", "URLARG", "ground or a object UUID")] [ArgHints("target", "ground or a object UUID")]
[Route(HttpVerbs.Get, "/Sit/{target}/{token}")] public object Sit(string target)
public object Sit(string target, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (target == "ground") if (target == "ground")
{ {
getClient().Self.SitOnGround(); getClient().Self.SitOnGround();
@ -132,29 +102,19 @@ namespace SecondBotEvents.Commands
[About("Makes the bot stand up if sitting (also resets animations)")] [About("Makes the bot stand up if sitting (also resets animations)")]
[ReturnHints("ok")] [ReturnHints("ok")]
[Route(HttpVerbs.Get, "/Stand/{token}")] public object Stand()
public object Stand(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
getClient().Self.Stand(); getClient().Self.Stand();
return BasicReply("ok", "Stand"); return BasicReply("ok");
} }
[About("Makes the bot sit on the ground or on a object if it can see it")] [About("Makes the bot sit on the ground or on a object if it can see it")]
[ReturnHints("true|false")] [ReturnHints("true|false")]
[ReturnHintsFailure("Invaild object UUID")] [ReturnHintsFailure("Invaild object UUID")]
[ReturnHintsFailure("Unable to see object")] [ReturnHintsFailure("Unable to see object")]
[ArgHints("target", "URLARG", "object UUID")] [ArgHints("target", "object UUID")]
[Route(HttpVerbs.Get, "/ClickObject/{object}/{token}")] public object ClickObject(string target)
public object ClickObject(string target, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(target, out UUID objectuuid) == false) if (UUID.TryParse(target, out UUID objectuuid) == false)
{ {
return Failure("Invaild object UUID", "ClickObject", new [] { target }); return Failure("Invaild object UUID", "ClickObject", new [] { target });
@ -179,26 +139,16 @@ namespace SecondBotEvents.Commands
[About("Makes the bot kill itself you monster")] [About("Makes the bot kill itself you monster")]
[ReturnHints("ok")] [ReturnHints("ok")]
[Route(HttpVerbs.Get, "/Logoff/{token}")] public object Logoff()
public object Logoff(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
getClient().Network.BeginLogout(); getClient().Network.BeginLogout();
return BasicReply("ok", "Logoff"); return BasicReply("ok");
} }
[About("Gets the last 5 commands issued to the bot")] [About("Gets the last commands issued to the bot")]
[ReturnHints("list of commands")] [ReturnHints("list of commands")]
[Route(HttpVerbs.Get, "/GetLastCommands/{token}")]
public object GetLastCommands(string token) public object GetLastCommands(string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
SuccessNoReturn("GetLastCommands"); SuccessNoReturn("GetLastCommands");
return Failure("@todo command storage"); return Failure("@todo command storage");
} }
@ -214,17 +164,12 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Invaild state")] [ReturnHintsFailure("Invaild state")]
[ReturnHintsFailure("Invaild sticky")] [ReturnHintsFailure("Invaild sticky")]
[ReturnHintsFailure("Invaild flag")] [ReturnHintsFailure("Invaild flag")]
[ArgHints("avatar", "URLARG", "avatar uuid or Firstname Lastname")] [ArgHints("avatar", "avatar uuid or Firstname Lastname")]
[ArgHints("flag", "URLARG", "friend, group, animation, teleport, inventory or command")] [ArgHints("flag", "friend, group, animation, teleport, inventory or command")]
[ArgHints("state", "URLARG", "State to set the flag to true or false")] [ArgHints("state", "State to set the flag to true or false")]
[ArgHints("sticky", "URLARG", "if true the permissing will not expire after the first use otherwise false")] [ArgHints("sticky", "if true the permissing will not expire after the first use otherwise false")]
[Route(HttpVerbs.Get, "/SetPermFlag/{avatar}/{flag}/{state}/{sticky}/{token}")] public object SetPermFlag(string avatar, string flag, string state, string sticky)
public object SetPermFlag(string avatar, string flag, string state, string sticky, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {

View file

@ -1,7 +1,4 @@
using EmbedIO; using Newtonsoft.Json;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using Newtonsoft.Json;
using OpenMetaverse; using OpenMetaverse;
using RestSharp; using RestSharp;
using SecondBotEvents.Services; using SecondBotEvents.Services;
@ -24,15 +21,10 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("HTTP status code: ...")] [ReturnHintsFailure("HTTP status code: ...")]
[ReturnHintsFailure("Error: ...")] [ReturnHintsFailure("Error: ...")]
[ReturnHintsFailure("Notecard title is to short")] [ReturnHintsFailure("Notecard title is to short")]
[ArgHints("endpoint","Text","The end point")] [ArgHints("endpoint", "The end point")]
[ArgHints("endpointcode", "Text", "The end point code")] [ArgHints("endpointcode", "The end point code")]
[Route(HttpVerbs.Post, "/FetchNextNotecard/{token}")] public object FetchNextNotecard(string endpoint, string endpointcode)
public object FetchNextNotecard([FormField] string endpoint, [FormField] string endpointcode, string token)
{ {
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (SecondbotHelpers.notempty(endpoint) == false) if (SecondbotHelpers.notempty(endpoint) == false)
{ {
return Failure("Endpoint is empty", "FetchNextNotecard", new [] { endpoint, endpointcode }); return Failure("Endpoint is empty", "FetchNextNotecard", new [] { endpoint, endpointcode });
@ -43,7 +35,7 @@ namespace SecondBotEvents.Commands
} }
string attempt_endpoint = endpoint + "sys.php"; string attempt_endpoint = endpoint + "sys.php";
token = SecondbotHelpers.GetSHA1(SecondbotHelpers.UnixTimeNow().ToString() + "NotecardNext" + endpointcode); string token = SecondbotHelpers.GetSHA1(SecondbotHelpers.UnixTimeNow().ToString() + "NotecardNext" + endpointcode);
var client = new RestClient(attempt_endpoint); var client = new RestClient(attempt_endpoint);
var request = new RestRequest("Notecard/Next", Method.Post); var request = new RestRequest("Notecard/Next", Method.Post);
string unixtime = SecondbotHelpers.UnixTimeNow().ToString(); string unixtime = SecondbotHelpers.UnixTimeNow().ToString();

View file

@ -17,6 +17,31 @@ namespace SecondBotEvents.Config
settings.Add("NotecardStoragePurgeAfterMins"); settings.Add("NotecardStoragePurgeAfterMins");
settings.Add("PrefetchGroupMembers"); settings.Add("PrefetchGroupMembers");
settings.Add("PrefetchGroupRoles"); settings.Add("PrefetchGroupRoles");
settings.Add("PrefetchEstateBanlist");
settings.Add("AutoCleanKeyValueStore");
settings.Add("CleanKeyValueStoreAfterMins");
settings.Add("CommandHistoryLimit");
}
public int GetCommandHistoryLimit()
{
return ReadSettingAsInt("CommandHistoryLimit", 30);
}
public bool GetAutoCleanKeyValueStore()
{
return ReadSettingAsBool("AutoCleanKeyValueStore", true);
}
public int GetCleanKeyValueStoreAfterMins()
{
return ReadSettingAsInt("CleanKeyValueStoreAfterMins", 10);
}
public bool GetPrefetchEstateBanlist()
{
return ReadSettingAsBool("PrefetchEstateBanlist", true);
} }
public bool GetPrefetchGroupRoles() public bool GetPrefetchGroupRoles()

View file

@ -37,7 +37,6 @@ namespace SecondBotEvents.Services
protected virtual void LoadCommandEndpoint(Type endpointtype) protected virtual void LoadCommandEndpoint(Type endpointtype)
{ {
CommandsAPI controler = (CommandsAPI)Activator.CreateInstance(endpointtype, args: new object[] { master }); CommandsAPI controler = (CommandsAPI)Activator.CreateInstance(endpointtype, args: new object[] { master });
controler.disableIPlockout();
commandEndpoints.Add(endpointtype.Name, controler); commandEndpoints.Add(endpointtype.Name, controler);
foreach (MethodInfo M in endpointtype.GetMethods()) foreach (MethodInfo M in endpointtype.GetMethods())
{ {
@ -241,13 +240,11 @@ namespace SecondBotEvents.Services
C.command = commandnameLowerToReal[C.command.ToLowerInvariant()]; C.command = commandnameLowerToReal[C.command.ToLowerInvariant()];
try try
{ {
string ott = SingleUseToken();
CommandsAPI Endpoint = commandEndpoints[endpointcommandmap[C.command]]; CommandsAPI Endpoint = commandEndpoints[endpointcommandmap[C.command]];
MethodInfo theMethod = Endpoint.GetType().GetMethod(C.command); MethodInfo theMethod = Endpoint.GetType().GetMethod(C.command);
if (theMethod != null) if (theMethod != null)
{ {
List<string> argsList = C.args.ToList(); List<string> argsList = C.args.ToList();
argsList.Add(ott);
string reply = "Inconnect number of args expected: " + theMethod.GetParameters().Count().ToString() + " but got: " + argsList.Count.ToString(); string reply = "Inconnect number of args expected: " + theMethod.GetParameters().Count().ToString() + " but got: " + argsList.Count.ToString();
bool status = false; bool status = false;
if (argsList.Count == theMethod.GetParameters().Count()) if (argsList.Count == theMethod.GetParameters().Count())

View file

@ -41,37 +41,203 @@ namespace SecondBotEvents.Services
protected Dictionary<UUID, bool> chatWindowsIsGroup = new Dictionary<UUID, bool>(); // sess, bool protected Dictionary<UUID, bool> chatWindowsIsGroup = new Dictionary<UUID, bool>(); // sess, bool
protected Dictionary<UUID, UUID> chatWindowsOwner = new Dictionary<UUID, UUID>(); // sess, owner id protected Dictionary<UUID, UUID> chatWindowsOwner = new Dictionary<UUID, UUID>(); // sess, owner id
protected Dictionary<string, string> KeyValueStore = new Dictionary<string, string>();
protected Dictionary<string, long> KeyValueStoreLastUsed = new Dictionary<string, long>();
protected List<CommandHistory> commandHistories = new List<CommandHistory>();
public void addCommandToHistory(UUID Source, string command, string[] args)
{
CommandHistory A = new CommandHistory(Source, command, args, SecondbotHelpers.UnixTimeNow());
commandHistories.Add(A);
int c = commandHistories.Count;
while (c > myConfig.GetCommandHistoryLimit())
{
commandHistories.RemoveAt(0);
c--;
}
}
public string GetKeyValue(string key)
{
if(KeyValueStore.ContainsKey(key) == false)
{
return "";
}
KeyValueStoreLastUsed[key] = SecondbotHelpers.UnixTimeNow();
return KeyValueStore[key];
}
public void SetKeyValue(string key, string value)
{
if(KeyValueStore.ContainsKey(key) == false)
{
KeyValueStore.Add(key, "");
KeyValueStoreLastUsed.Add(key, 0);
}
KeyValueStore[key] = value;
KeyValueStoreLastUsed[key] = SecondbotHelpers.UnixTimeNow();
}
public void ClearKeyValue(string key)
{
if (KeyValueStore.ContainsKey(key) == false)
{
return;
}
KeyValueStore.Remove(key);
KeyValueStoreLastUsed.Remove(key);
}
public void AppendKeyValue(string key, string value)
{
if (KeyValueStore.ContainsKey(key) == false)
{
SetKeyValue(key, value);
return;
}
KeyValueStoreLastUsed[key] = SecondbotHelpers.UnixTimeNow();
KeyValueStore[key] = KeyValueStore[key] + value;
}
public Dictionary<UUID, string> GetGroups() public Dictionary<UUID, string> GetGroups()
{ {
return groupsKey2Name; return groupsKey2Name;
} }
public bool IsGroupMember(UUID Group, UUID avatar)
public List<UUID> GetAllGroupsChatWithUnread()
{ {
if(groupMembers.ContainsKey(Group) == false) List<UUID> reply = new List<UUID>();
foreach(KeyValuePair<UUID, bool> windowState in chatWindowsUnread)
{ {
groupMembers.Add(Group, new List<UUID>()); if(windowState.Value == false)
{
continue;
}
if(chatWindowsIsGroup[windowState.Key] == false)
{
continue;
}
reply.Add(windowState.Key);
} }
if(groupMembers[Group].Contains(avatar) == false) return reply;
}
public bool GetGroupChatHasUnread(UUID group)
{
if(chatWindowsUnread.ContainsKey(group) == false)
{
return false;
}
return chatWindowsUnread[group];
}
public bool GetGroupChatHasAnyUnread()
{
bool reply = false;
foreach(KeyValuePair<UUID,bool> check in chatWindowsIsGroup)
{
if(check.Value == false)
{
continue;
}
if(chatWindowsUnread[check.Key] == true)
{
reply = true;
break;
}
}
return reply;
}
public List<string> GetGroupChatHistory(UUID group)
{
if(chatWindows.ContainsKey(group) == false)
{
return new List<string>();
}
return chatWindows[group];
}
public void clearGroupChat()
{
foreach(UUID group in groupsKey2Name.Keys)
{
if (chatWindowsUnread.ContainsKey(group) == false)
{
continue;
}
chatWindowsUnread.Remove(group);
chatWindows.Remove(group);
chatWindowsIsGroup.Remove(group);
chatWindowsOwner.Remove(group);
}
}
public Dictionary<UUID, string> GetGroupRoles(UUID group)
{
Dictionary<UUID, string> reply = new Dictionary<UUID, string>();
if (groupRoles.ContainsKey(group) == false)
{
AutoResetEvent fetchEvent = new AutoResetEvent(false);
EventHandler<GroupRolesDataReplyEventArgs> callback =
delegate (object sender, GroupRolesDataReplyEventArgs e)
{
if (e.GroupID == group)
{
foreach(KeyValuePair<UUID,GroupRole> role in e.Roles)
{
reply[role.Value.ID] = role.Value.Name;
}
fetchEvent.Set();
}
};
getClient().Groups.GroupRoleDataReply += callback;
getClient().Groups.RequestGroupRoles(group);
fetchEvent.WaitOne(1000, false);
getClient().Groups.GroupRoleDataReply -= callback;
return reply;
}
foreach (KeyValuePair<UUID, GroupRole> role in groupRoles[group])
{
reply[role.Value.ID] = role.Value.Name;
}
return reply;
}
public bool IsGroupMember(UUID group, UUID avatar)
{
if(groupMembers.ContainsKey(group) == false)
{
groupMembers.Add(group, new List<UUID>());
}
if(groupMembers[group].Contains(avatar) == false)
{ {
bool found = false; bool found = false;
AutoResetEvent fetchEvent = new AutoResetEvent(false); AutoResetEvent fetchEvent = new AutoResetEvent(false);
EventHandler<GroupMembersReplyEventArgs> callback = EventHandler<GroupMembersReplyEventArgs> callback =
delegate (object sender, GroupMembersReplyEventArgs e) delegate (object sender, GroupMembersReplyEventArgs e)
{ {
if (e.GroupID == Group) if (e.GroupID == group)
{ {
foreach (KeyValuePair<UUID, GroupMember> a in e.Members) foreach (KeyValuePair<UUID, GroupMember> a in e.Members)
{ {
if (a.Value.ID == avatar) if (a.Value.ID == avatar)
{ {
found = true; found = true;
fetchEvent.Set();
break; break;
} }
} }
} }
}; };
getClient().Groups.GroupMembersReply += callback; getClient().Groups.GroupMembersReply += callback;
getClient().Groups.RequestGroupMembers(Group); getClient().Groups.RequestGroupMembers(group);
fetchEvent.WaitOne(1000, false); fetchEvent.WaitOne(1000, false);
getClient().Groups.GroupMembersReply -= callback; getClient().Groups.GroupMembersReply -= callback;
@ -434,7 +600,7 @@ namespace SecondBotEvents.Services
groupsKey2Name = new Dictionary<UUID, string>(); groupsKey2Name = new Dictionary<UUID, string>();
groupMembers = new Dictionary<UUID, List<UUID>>(); groupMembers = new Dictionary<UUID, List<UUID>>();
groupRoles = new Dictionary<UUID, Dictionary<UUID, string>>(); groupRoles = new Dictionary<UUID, Dictionary<UUID, GroupRole>>();
localChatHistory = new List<string>(); localChatHistory = new List<string>();
@ -444,7 +610,9 @@ namespace SecondBotEvents.Services
chatWindowsUnread = new Dictionary<UUID, bool>(); // sess, bool chatWindowsUnread = new Dictionary<UUID, bool>(); // sess, bool
chatWindowsIsGroup = new Dictionary<UUID, bool>(); // sess, bool chatWindowsIsGroup = new Dictionary<UUID, bool>(); // sess, bool
chatWindowsOwner = new Dictionary<UUID, UUID>(); // sess, owner id chatWindowsOwner = new Dictionary<UUID, UUID>(); // sess, owner id
}
estateBanlist = new List<UUID>();
}
protected void BotClientRestart(object o, BotClientNotice e) protected void BotClientRestart(object o, BotClientNotice e)
@ -466,7 +634,7 @@ namespace SecondBotEvents.Services
{ {
if(groupRoles.ContainsKey(e.GroupID) == false) if(groupRoles.ContainsKey(e.GroupID) == false)
{ {
groupRoles.Add(e.GroupID, new Dictionary<UUID, string>()); groupRoles.Add(e.GroupID, new Dictionary<UUID, GroupRole>());
} }
groupRoles[e.GroupID] = e.Roles; groupRoles[e.GroupID] = e.Roles;
} }
@ -484,6 +652,35 @@ namespace SecondBotEvents.Services
} }
} }
public List<UUID> GetEstateBans()
{
if (estateBanlist == null)
{
List<UUID> reply = new List<UUID>();
AutoResetEvent fetchEvent = new AutoResetEvent(false);
EventHandler<EstateBansReplyEventArgs> callback =
delegate (object sender, EstateBansReplyEventArgs e)
{
reply = e.Banned;
fetchEvent.Set();
};
getClient().Estate.EstateBansReply += callback;
getClient().Estate.RequestInfo();
fetchEvent.WaitOne(1000, false);
getClient().Estate.EstateBansReply -= callback;
return reply;
}
return estateBanlist;
}
List<UUID> estateBanlist = null;
protected void EstateBans(object o, EstateBansReplyEventArgs e)
{
estateBanlist = e.Banned;
}
protected void BotLoggedIn(object o, SimConnectedEventArgs e) protected void BotLoggedIn(object o, SimConnectedEventArgs e)
{ {
getClient().Network.SimConnected -= BotLoggedIn; getClient().Network.SimConnected -= BotLoggedIn;
@ -497,6 +694,7 @@ namespace SecondBotEvents.Services
getClient().Avatars.AvatarPickerReply += AvatarUUIDNamePicker; getClient().Avatars.AvatarPickerReply += AvatarUUIDNamePicker;
getClient().Groups.GroupMembersReply += GroupMembers; getClient().Groups.GroupMembersReply += GroupMembers;
getClient().Groups.GroupRoleDataReply += GroupRoles; getClient().Groups.GroupRoleDataReply += GroupRoles;
getClient().Estate.EstateBansReply += EstateBans;
getClient().Groups.RequestCurrentGroups(); getClient().Groups.RequestCurrentGroups();
botConnected = true; botConnected = true;
Console.WriteLine("DataStore Service [Active]"); Console.WriteLine("DataStore Service [Active]");
@ -671,11 +869,28 @@ namespace SecondBotEvents.Services
getClient().Avatars.AvatarPickerReply -= AvatarUUIDNamePicker; getClient().Avatars.AvatarPickerReply -= AvatarUUIDNamePicker;
getClient().Groups.GroupMembersReply -= GroupMembers; getClient().Groups.GroupMembersReply -= GroupMembers;
getClient().Groups.GroupRoleDataReply -= GroupRoles; getClient().Groups.GroupRoleDataReply -= GroupRoles;
getClient().Estate.EstateBansReply -= EstateBans;
} }
} }
Console.WriteLine("DataStore Service [Stopping]"); Console.WriteLine("DataStore Service [Stopping]");
} }
} }
public class CommandHistory
{
public UUID Source = UUID.Zero;
public string Command = "";
public string[] Args = new string[] { };
public long Unixtime = 0;
public CommandHistory(UUID setSource, string setCommand, string[] setArgs, long setUnixtime)
{
Source = setSource;
Command = setCommand;
Args = setArgs;
Unixtime = setUnixtime;
}
}
} }

View file

@ -2,24 +2,24 @@
using EmbedIO.Actions; using EmbedIO.Actions;
using EmbedIO.WebApi; using EmbedIO.WebApi;
using OpenMetaverse; using OpenMetaverse;
using SecondBotEvents.Commands;
using SecondBotEvents.Config; using SecondBotEvents.Config;
using Swan.Logging; using Swan.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using System.Threading; using System.Threading;
using SecondBotEvents.Commands;
namespace SecondBotEvents.Services namespace SecondBotEvents.Services
{ {
public class HttpService: Services public class HttpService : Services
{ {
protected WebServer HTTPendpoint = null; protected WebServer HTTPendpoint = null;
protected HttpConfig myConfig; protected HttpConfig myConfig;
protected bool acceptBotCommands = false; protected bool acceptBotCommands = false;
public HttpService(EventsSecondBot setMaster) : base(setMaster) public HttpService(EventsSecondBot setMaster) : base(setMaster)
{ {
myConfig = new HttpConfig(master.fromEnv,master.fromFolder); myConfig = new HttpConfig(master.fromEnv, master.fromFolder);
if (myConfig.GetEnabled() == false) if (myConfig.GetEnabled() == false)
{ {
Console.WriteLine(Status()); Console.WriteLine(Status());
@ -29,7 +29,7 @@ namespace SecondBotEvents.Services
public override string Status() public override string Status()
{ {
if(myConfig == null) if (myConfig == null)
{ {
return "HTTP service [Config status broken]"; return "HTTP service [Config status broken]";
} }
@ -38,7 +38,7 @@ namespace SecondBotEvents.Services
return "HTTP service [- Not requested -]"; return "HTTP service [- Not requested -]";
} }
// @todo HTTP server check here // @todo HTTP server check here
if(HTTPendpoint == null) if (HTTPendpoint == null)
{ {
return "HTTP endpoint not online"; return "HTTP endpoint not online";
} }
@ -106,30 +106,13 @@ namespace SecondBotEvents.Services
.WithUrlPrefix(myConfig.GetHost()) .WithUrlPrefix(myConfig.GetHost())
.WithMode(HttpListenerMode.EmbedIO)) .WithMode(HttpListenerMode.EmbedIO))
.WithCors() .WithCors()
.WithWebApi("/animation", m => m.WithController(() => new AnimationCommands(master)))
.WithWebApi("/avatars", m => m.WithController(() => new Avatars(master)))
.WithWebApi("/chat", m => m.WithController(() => new Chat(master)))
.WithWebApi("/core", m => m.WithController(() => new Core(master)))
.WithWebApi("/dialogs", m => m.WithController(() => new Dialogs(master)))
.WithWebApi("/discord", m => m.WithController(() => new DiscordCommands(master)))
.WithWebApi("/estate", m => m.WithController(() => new Estate(master)))
.WithWebApi("/friends", m => m.WithController(() => new Friends(master)))
.WithWebApi("/funds", m => m.WithController(() => new Funds(master)))
.WithWebApi("/group", m => m.WithController(() => new GroupCommands(master)))
.WithWebApi("/info", m => m.WithController(() => new Info(master)))
.WithWebApi("/inventory", m => m.WithController(() => new InventoryCommands(master)))
.WithWebApi("/movement", m => m.WithController(() => new Movement(master)))
.WithWebApi("/notecard", m => m.WithController(() => new Notecard(master)))
.WithWebApi("/parcel", m => m.WithController(() => new ParcelCommands(master)))
.WithWebApi("/self", m => m.WithController(() => new Self(master)))
.WithWebApi("/streamadmin", m => m.WithController(() => new StreamAdmin(master)))
.WithModule(new ActionModule("/", HttpVerbs.Any, ctx => ctx.SendDataAsync(new { Message = "Error" })) .WithModule(new ActionModule("/", HttpVerbs.Any, ctx => ctx.SendDataAsync(new { Message = "Error" }))
); );
HTTPendpoint.RunAsync(); HTTPendpoint.RunAsync();
} }
} }
public abstract class CommandsAPI : WebApiController public abstract class CommandsAPI
{ {
protected EventsSecondBot master; protected EventsSecondBot master;
public CommandsAPI(EventsSecondBot setmaster) public CommandsAPI(EventsSecondBot setmaster)
@ -137,40 +120,9 @@ namespace SecondBotEvents.Services
master = setmaster; master = setmaster;
} }
protected bool AllowToken(string token)
{
return master.CommandsService.AllowToken(token);
}
protected UUID avataruuid = UUID.Zero; protected UUID avataruuid = UUID.Zero;
protected Parcel targetparcel = null; protected Parcel targetparcel = null;
protected bool disableIPchecks = false;
public void disableIPlockout()
{
disableIPchecks = true;
}
public IPAddress handleGetClientIP()
{
try
{
if (disableIPchecks == true)
{
return IPAddress.Parse("127.0.0.1");
}
else
{
return HttpContext.Request.RemoteEndPoint.Address;
}
}
catch
{
Console.WriteLine("Error getting client ip");
return IPAddress.Parse("0.0.0.0");
}
}
protected GridClient getClient() protected GridClient getClient()
{ {
return master.botClient.client; return master.botClient.client;
@ -200,7 +152,7 @@ namespace SecondBotEvents.Services
{ {
avataruuid = UUID.Zero; avataruuid = UUID.Zero;
string UUIDfetch = master.DataStoreService.getAvatarUUID(avatar); string UUIDfetch = master.DataStoreService.getAvatarUUID(avatar);
if(UUIDfetch != "lookup") if (UUIDfetch != "lookup")
{ {
UUID.TryParse(UUIDfetch, out avataruuid); UUID.TryParse(UUIDfetch, out avataruuid);
} }
@ -240,7 +192,7 @@ namespace SecondBotEvents.Services
protected object Failure(string input) protected object Failure(string input)
{ {
// @todo Command history storage system // @todo Command history storage system
return new { reply = input, command= getCallingCommand(), status = false }; return new { reply = input, command = getCallingCommand(), status = false };
} }
protected string getCallingCommand() protected string getCallingCommand()
@ -272,16 +224,6 @@ namespace SecondBotEvents.Services
} }
} }
[AttributeUsage(AttributeTargets.Method)]
public class NeedsToken : Attribute
{
public bool needsToken = true;
public NeedsToken(bool needsToken)
{
this.needsToken = needsToken;
}
}
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class ReturnHints : Attribute public class ReturnHints : Attribute
{ {
@ -296,7 +238,7 @@ namespace SecondBotEvents.Services
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class ReturnHintsFailure : ReturnHints public class ReturnHintsFailure : ReturnHints
{ {
public ReturnHintsFailure(string hint): base(hint) public ReturnHintsFailure(string hint) : base(hint)
{ {
this.good = false; this.good = false;
} }
@ -306,13 +248,11 @@ namespace SecondBotEvents.Services
public class ArgHints : Attribute public class ArgHints : Attribute
{ {
public string name = ""; public string name = "";
public string typename = "";
public string about = ""; public string about = "";
public ArgHints(string name,string typename, string about) public ArgHints(string name, string about)
{ {
this.name = name; this.name = name;
this.typename = typename;
this.about = about; this.about = about;
} }
} }