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

View file

@ -1,6 +1,4 @@
using EmbedIO;
using EmbedIO.Routing;
using System;
using System;
using System.Collections.Generic;
using OpenMetaverse;
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>")]
[ReturnHints("array NearMeDetails")]
[ReturnHintsFailure("Error not in a sim")]
[Route(HttpVerbs.Get, "/NearmeWithDetails/{token}")]
public object NearmeWithDetails(string token)
public object NearmeWithDetails()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (getClient().Network.CurrentSim == null)
{
return BasicReply("Error not in a sim");
@ -50,13 +43,8 @@ namespace SecondBotEvents.Commands
[About("returns a list of all known avatars nearby")]
[ReturnHints("array UUID = Name")]
[ReturnHintsFailure("Error not in a sim")]
[Route(HttpVerbs.Get, "/Nearme/{token}")]
public object Nearme(string token)
public object Nearme()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (getClient().Network.CurrentSim == null)
{
return BasicReply("Error not in a sim");
@ -73,17 +61,13 @@ namespace SecondBotEvents.Commands
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("lookup")]
[ReturnHintsFailure("Not a vaild UUID")]
[Route(HttpVerbs.Get, "/Key2Name/{uuid}/{token}")]
public object Key2Name(string uuid, string token)
public object Key2Name(string uuid)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
UUID avUUID = UUID.Zero;
if (UUID.TryParse(uuid, out avUUID) == false)
{
@ -92,17 +76,13 @@ namespace SecondBotEvents.Commands
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("lookup")]
[ReturnHintsFailure("Not a vaild name")]
[Route(HttpVerbs.Get, "/Name2Key/{name}/{token}")]
public object Name2Key(string name, string token)
[ArgHints("name", "the name to find the uuid for")]
public object Name2Key(string name)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if(name == null)
{
return Failure("Not a vaild name");

View file

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

View file

@ -1,9 +1,4 @@
using EmbedIO;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using OpenMetaverse;
using SecondBotEvents.Services;
using System.Threading;
using SecondBotEvents.Services;
namespace SecondBotEvents.Commands
{
@ -12,28 +7,12 @@ namespace SecondBotEvents.Commands
public Core(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("Used to check HTTP connections")]
[About("Used to check connections")]
[ReturnHints("world")]
[NeedsToken(false)]
[Route(HttpVerbs.Get, "/Hello")]
public object 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

View file

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

View file

@ -1,10 +1,4 @@
using EmbedIO;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using OpenMetaverse;
using SecondBotEvents.Services;
using System;
using System.Collections.Generic;
using SecondBotEvents.Services;
namespace SecondBotEvents.Commands
{
@ -16,16 +10,11 @@ namespace SecondBotEvents.Commands
[About("Adds a discord server role to the selected member")]
[ReturnHintsFailure("Discord client not ready")]
[ReturnHints("true|false")]
[ArgHints("serverid","URLARG","the server id to apply this action to")]
[ArgHints("roleid", "URLARG", "the role id we are giving")]
[ArgHints("memberid", "URLARG", "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,string token)
[ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("roleid", "the role id we are giving")]
[ArgHints("memberid", "who we are giving it to")]
public object Discord_AddRole(string serverid,string roleid,string memberid)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false)
{
return Failure("Discord client not ready");
@ -37,16 +26,11 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Discord client not ready")]
[ReturnHintsFailure("Why empty")]
[ReturnHints("true|false")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")]
[ArgHints("memberid", "URLARG", "who we are giving it to")]
[ArgHints("why", "string", "why they are being banned")]
[Route(HttpVerbs.Post, "/Discord_BanMember/{serverid}/{memberid}/{token}")]
public object Discord_BanMember(string serverid, string memberid, [FormField] string why, string token)
[ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("memberid", "who we are giving it to")]
[ArgHints("why", "why they are being banned")]
public object Discord_BanMember(string serverid, string memberid, string why)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false)
{
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")]
[ReturnHintsFailure("Discord client not ready")]
[ReturnHints("true|false")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")]
[ArgHints("memberid", "URLARG", "who we are giving it to")]
[Route(HttpVerbs.Get, "/Discord_BulkClear_Messages/{serverid}/{memberid}/{token}")]
public object Discord_BulkClear_Messages(string serverid, string memberid, string token)
[ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("memberid", "who we are giving it to")]
public object Discord_BulkClear_Messages(string serverid, string memberid)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false)
{
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")]
[ReturnHintsFailure("Discord client not ready")]
[ReturnHints("true|false")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")]
[ArgHints("memberid", "URLARG", "who we are giving it to")]
[ArgHints("message", "Text", "what we are sending")]
[Route(HttpVerbs.Post, "/Discord_Dm_Member/{serverid}/{memberid}/{token}")]
public object Discord_Dm_Member(string serverid, string memberid, [FormField] string message, string token)
[ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("memberid", "who we are giving it to")]
[ArgHints("message", "what we are sending")]
public object Discord_Dm_Member(string serverid, string memberid, string message)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false)
{
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 !!!")]
[ReturnHintsFailure("Discord client not ready")]
[ReturnHints("mixed array of userid: nickname|username or userid:username")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")]
[Route(HttpVerbs.Get, "/Discord_MembersList/{serverid}/{token}")]
public object Discord_MembersList(string serverid, string token)
[ArgHints("serverid", "the server id to apply this action to")]
public object Discord_MembersList(string serverid)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false)
{
return Failure("Discord client not ready");
@ -123,17 +92,12 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Discord client not ready")]
[ReturnHintsFailure("message empty")]
[ReturnHints("true|false")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")]
[ArgHints("channelid", "URLARG", "the channel id to apply this action to")]
[ArgHints("tts", "URLARG", "shoud tts be enabled true or false")]
[ArgHints("message", "Text", "what we are sending")]
[Route(HttpVerbs.Post, "/Discord_MembersList/{serverid}/{tts}/{token}")]
public object Discord_MessageChannel(string serverid, string channelid, string tts, [FormField] string message, string token)
[ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("channelid", "the channel id to apply this action to")]
[ArgHints("tts", "shoud tts be enabled true or false")]
[ArgHints("message", "what we are sending")]
public object Discord_MessageChannel(string serverid, string channelid, string tts, string message)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false)
{
return Failure("Discord client not ready");
@ -148,16 +112,11 @@ namespace SecondBotEvents.Commands
[About("Sends a message to the selected channel - Optional TTS usage")]
[ReturnHints("mixed array of userid: nickname|username or userid:username")]
[ReturnHintsFailure("Discord client not ready")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")]
[ArgHints("memberid", "URLARG", "who we are giving it to")]
[ArgHints("mode", "URLARG", "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, string token)
[ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("memberid", "who we are giving it to")]
[ArgHints("mode", "should we mute them \"true\" or unmute \"false\"")]
public object Discord_MuteMember(string serverid, string memberid, string mode)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false)
{
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")]
[ReturnHints("KeyPair of status: KeyPair[] item = value")]
[ReturnHintsFailure("Discord client not ready")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")]
[ArgHints("memberid", "URLARG", "who we are giving it to")]
[ArgHints("mode", "URLARG", "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, string token)
[ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("memberid", "who we are giving it to")]
[ArgHints("mode", "should we mute them \"true\" or unmute \"false\"")]
public object Discord_Role_GetSettings(string serverid, string roleid)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false)
{
return Failure("Discord client not ready");
@ -190,16 +144,11 @@ namespace SecondBotEvents.Commands
" This command requires Discord full client mode enabled and connected")]
[ReturnHints("true|false")]
[ReturnHintsFailure("Discord client not ready")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")]
[ArgHints("roleid", "URLARG", "who we are giving it to")]
[ArgHints("flagscsv", "Text", "what we are setting")]
[Route(HttpVerbs.Post, "/Discord_Role_UpdatePerms/{serverid}/{roleid}/{token}")]
public object Discord_Role_UpdatePerms(string serverid, string roleid, [FormField] string flagscsv, string token)
[ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("roleid", "who we are giving it to")]
[ArgHints("flagscsv", "what we are setting")]
public object Discord_Role_UpdatePerms(string serverid, string roleid, string flagscsv)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false)
{
return Failure("Discord client not ready");
@ -211,15 +160,10 @@ namespace SecondBotEvents.Commands
" This command requires Discord full client mode enabled and connected")]
[ReturnHints("KeyPair of statusmessage=roleid or 0")]
[ReturnHintsFailure("Discord client not ready")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")]
[ArgHints("role", "URLARG", "the name of the role we are creating")]
[Route(HttpVerbs.Get, "/Discord_RoleCreate/{serverid}/{role}/{token}")]
public object Discord_RoleCreate(string serverid, string role, string token)
[ArgHints("serverid", "the server id to apply this action to")]
[ArgHints("role", "the name of the role we are creating")]
public object Discord_RoleCreate(string serverid, string role)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false)
{
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")]
[ReturnHints("KeyPair of status: KeyPair of roleid: rolename")]
[ReturnHintsFailure("Discord client not ready")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")]
[Route(HttpVerbs.Get, "/Discord_RoleList/{serverid}/{token}")]
public object Discord_RoleList(string serverid, string token)
[ArgHints("serverid", "the server id to apply this action to")]
public object Discord_RoleList(string serverid)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false)
{
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")]
[ReturnHints("true|false")]
[ReturnHintsFailure("Discord client not ready")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")]
[Route(HttpVerbs.Get, "/Discord_RoleRemove/{serverid}/{roleid}/{token}")]
public object Discord_RoleRemove(string serverid, string roleid, string token)
[ArgHints("serverid", "the server id to apply this action to")]
public object Discord_RoleRemove(string serverid, string roleid)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false)
{
return Failure("Discord client not ready");
@ -267,14 +201,9 @@ namespace SecondBotEvents.Commands
[About("Returns a list of text channels in a server")]
[ReturnHints("array of channelid: name")]
[ReturnHintsFailure("Discord client not ready")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")]
[Route(HttpVerbs.Get, "/Discord_TextChannels_List/{serverid}/{roleid}/{token}")]
public object Discord_TextChannels_List(string serverid, string token)
[ArgHints("serverid", "the server id to apply this action to")]
public object Discord_TextChannels_List(string serverid)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (master.DiscordService.DiscordReady() == false)
{
return Failure("Discord client not ready");

View file

@ -1,7 +1,4 @@
using EmbedIO;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using Newtonsoft.Json;
using Newtonsoft.Json;
using OpenMetaverse;
using SecondBotEvents.Services;
using System.Collections.Generic;
@ -17,16 +14,11 @@ namespace SecondBotEvents.Commands
[ReturnHints("restarting")]
[ReturnHintsFailure("Not an estate manager here")]
[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!")]
[ArgHints("mode", "URLARG", "true to start a restart, false to cancel")]
[Route(HttpVerbs.Get, "/SimRestart/{delay}/{mode}/{token}")]
public object SimRestart(string delay, string mode, string token)
[ArgHints("mode", "true to start a restart, false to cancel")]
public object SimRestart(string delay, string mode)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (getClient().Network.CurrentSim.IsEstateManager == false)
{
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("Message empty")]
[ReturnHints("ok")]
[ArgHints("message", "Text", "What the message is")]
[Route(HttpVerbs.Post, "/SimMessage/{token}")]
public object SimMessage([FormField] string message, string token)
[ArgHints("message", "What the message is")]
public object SimMessage(string message, string token)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (SecondbotHelpers.notempty(message) == false)
{
return Failure("Message empty", "SimMessage", new [] { message });
@ -74,14 +61,9 @@ namespace SecondBotEvents.Commands
[About("Fetchs the regions map tile")]
[ReturnHintsFailure("Unable to find region")]
[ReturnHints("Texture UUID")]
[ArgHints("regionname", "URLARG", "the name of the region we are fetching")]
[Route(HttpVerbs.Get, "/GetSimTexture/{regionname}/{token}")]
public object GetSimTexture(string regionname, string token)
[ArgHints("regionname", "the name of the region we are fetching")]
public object GetSimTexture(string regionname)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (getClient().Grid.GetGridRegion(regionname, GridLayerType.Objects, out GridRegion region) == false)
{
return Failure("Unable to find region", "GetSimTexture", new [] { regionname });
@ -92,32 +74,23 @@ namespace SecondBotEvents.Commands
[About("Reclaims ownership of the current parcel")]
[ReturnHintsFailure("Not an estate manager here")]
[ReturnHints("ok")]
[Route(HttpVerbs.Get, "/EstateParcelReclaim/{token}")]
public object EstateParcelReclaim(string token)
public object EstateParcelReclaim()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
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);
getClient().Parcels.Reclaim(getClient().Network.CurrentSim, localid);
return BasicReply("ok", "EstateParcelReclaim");
return BasicReply("ok");
}
[About("Reclaims ownership of the current parcel")]
[ReturnHintsFailure("Not an estate manager here")]
[ReturnHints("ok")]
[Route(HttpVerbs.Get, "/GetSimGlobalPos/{regionname}/{token}")]
public object GetSimGlobalPos(string regionname, string token)
[About("Gets the global location of a sim [region]")]
[ArgHints("regionname", "the region we want")]
[ReturnHintsFailure("Unable to find region")]
[ReturnHints("a json object with the x,y and region name")]
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)
{
return Failure("Unable to find region", "GetSimGlobalPos", new [] { regionname });
@ -126,20 +99,14 @@ namespace SecondBotEvents.Commands
reply.Add("region", regionname);
reply.Add("X", region.X.ToString());
reply.Add("Y", region.Y.ToString());
SuccessNoReturn("GetSimGlobalPos", new [] { regionname });
return reply;
return BasicReply(JsonConvert.SerializeObject(reply));
}
[About("Requests the estate banlist")]
[ReturnHints("ban list json")]
[Route(HttpVerbs.Get, "/GetEstateBanList/{token}")]
public object GetEstateBanList(string token)
public object GetEstateBanList()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return Failure("@todo estate blacklist");
return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetEstateBans()));
}
[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 process global value please use true or false")]
[ReturnHintsFailure("Not an estate manager on region {REGIONNAME}")]
[ArgHints("avatar", "URLARG", "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("global", "URLARG", "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}")]
[ArgHints("avatar", "the uuid avatar you wish to ban")]
[ArgHints("mode", "What action would you like to take<br/>Defaults to remove if not given \"add\"")]
[ArgHints("global", "if true this the ban/unban will be applyed to all estates the bot has access to")]
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)
{
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 EmbedIO.Routing;
using OpenMetaverse;
using OpenMetaverse;
using SecondBotEvents.Services;
using Newtonsoft.Json;
@ -12,33 +10,24 @@ namespace SecondBotEvents.Commands
public Friends(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("Gets the friendslist")]
[ReturnHints("array UUID = friendreplyobject")]
[Route(HttpVerbs.Get, "/Friendslist/{token}")]
public object Friendslist(string token)
public object Friendslist()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
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")]
[ArgHints("avatar", "URLARG", "A avatar uuid or Firstname Lastname")]
[ArgHints("state", "URLARG", "true: Grant perms, false: Remove perms")]
[ArgHints("avatar", "A avatar uuid or Firstname Lastname")]
[ArgHints("state", "true: Grant perms, false: Remove perms")]
[ReturnHints("granted")]
[ReturnHints("removed")]
[ReturnHintsFailure("Not A friend")]
[ReturnHintsFailure("state invaild")]
[ReturnHintsFailure("avatar lookup")]
[Route(HttpVerbs.Get, "/FriendFullPerms/{avatar}/{state}/{token}")]
public object FriendFullPerms(string avatar, string state, string token)
public object FriendFullPerms(string avatar, string state)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar);
if (avataruuid == UUID.Zero)
{
@ -69,15 +58,10 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Not in friendslist")]
[ReturnHintsFailure("state invaild")]
[ReturnHintsFailure("avatar lookup")]
[ArgHints("avatar", "URLARG", "A avatar uuid or Firstname Lastname")]
[ArgHints("state", "URLARG", "true: Send invite, false: Remove from friendslist")]
[Route(HttpVerbs.Get, "/FriendRequest/{avatar}/{state}/{token}")]
public object FriendRequest(string avatar, string state, string token)
[ArgHints("avatar", "A avatar uuid or Firstname Lastname")]
[ArgHints("state", "true: Send invite, false: Remove from friendslist")]
public object FriendRequest(string avatar, string state)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar);
if (avataruuid == UUID.Zero)
{
@ -105,6 +89,4 @@ namespace SecondBotEvents.Commands
}
}
}

View file

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

View file

@ -1,11 +1,7 @@
using EmbedIO;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using Newtonsoft.Json;
using Newtonsoft.Json;
using OpenMetaverse;
using SecondBotEvents.Services;
using System.Collections.Generic;
using System.Threading;
namespace SecondBotEvents.Commands
{
@ -21,15 +17,10 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Unknown group")]
[ReturnHintsFailure("Invaild group UUID")]
[ReturnHintsFailure("avatar lookup")]
[ArgHints("group", "URLARG", "the UUID of the group")]
[ArgHints("avatar", "URLARG", "the UUID of the avatar you wish to check with")]
[Route(HttpVerbs.Get, "/IsGroupMember/{group}/{avatar}/{token}")]
public object IsGroupMember(string group, string avatar, string token)
[ArgHints("group", "the UUID of the group")]
[ArgHints("avatar", "the UUID of the avatar you wish to check with")]
public object IsGroupMember(string group, string avatar)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false)
{
return Failure("Invaild group UUID", "IsGroupMember", new [] { group, avatar });
@ -44,14 +35,9 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Unknown group")]
[ReturnHintsFailure("Invaild group UUID")]
[ReturnHintsFailure("avatar lookup")]
[ArgHints("group", "URLARG", "the UUID of the group")]
[Route(HttpVerbs.Get, "/GetGroupMembers/{group}/{token}")]
public object GetGroupMembers(string group, string token)
[ArgHints("group", "the UUID of the group")]
public object GetGroupMembers(string group)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false)
{
return Failure("Invaild group UUID", "GetGroupMembers", new [] { group });
@ -66,16 +52,11 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Invaild group UUID")]
[ReturnHintsFailure("avatar lookup")]
[ReturnHintsFailure("Missing group GroupBanAccess power")]
[ArgHints("group", "URLARG", "the UUID of the group")]
[ArgHints("avatar", "URLARG", "the UUID of the avatar or Firstname Lastname")]
[ArgHints("state", "URLARG", "true to ban false to unban")]
[Route(HttpVerbs.Get, "/GroupBan/{group}/{avatar}/{state}/{token}")]
public object GroupBan(string group, string avatar, string state, string token)
[ArgHints("group", "the UUID of the group")]
[ArgHints("avatar", "the UUID of the avatar or Firstname Lastname")]
[ArgHints("state", "true to ban false to unban")]
public object GroupBan(string group, string avatar, string state)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false)
{
return Failure("Invaild group UUID", "GroupBan", new[] { group, avatar, state });
@ -110,15 +91,10 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Not in group")]
[ReturnHintsFailure("avatar lookup")]
[ReturnHintsFailure("Missing group Eject power")]
[ArgHints("group", "URLARG", "the UUID of the group")]
[ArgHints("avatar", "URLARG", "the UUID of the avatar you wish to check with")]
[Route(HttpVerbs.Get, "/GroupEject/{group}/{avatar}/{token}")]
public object GroupEject(string group, string avatar, string token)
[ArgHints("group", "the UUID of the group")]
[ArgHints("avatar", "the UUID of the avatar you wish to check with")]
public object GroupEject(string group, string avatar)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false)
{
return Failure("Invaild group UUID", "GroupEject", new [] { group, avatar });
@ -144,15 +120,10 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Invaild group UUID")]
[ReturnHintsFailure("Invaild role UUID")]
[ReturnHintsFailure("avatar lookup")]
[ArgHints("group", "URLARG", "the UUID of the group")]
[ArgHints("avatar", "URLARG", "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, string token)
[ArgHints("group", "the UUID of the group")]
[ArgHints("avatar", "the UUID of the avatar you wish to check with")]
public object GroupAddRole(string group, string avatar, string role)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false)
{
return Failure("Invaild group UUID", "GroupAddRole", new [] { group, avatar });
@ -183,16 +154,11 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Invaild group UUID")]
[ReturnHintsFailure("avatar lookup")]
[ReturnHintsFailure("Missing group Invite power")]
[ArgHints("group", "URLARG", "the UUID of the group")]
[ArgHints("avatar", "URLARG", "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\"")]
[Route(HttpVerbs.Get, "/GroupInvite/{group}/{avatar}/{role}/{token}")]
public object GroupInvite(string group, string avatar, string role, string token)
[ArgHints("group", "the UUID of the group")]
[ArgHints("avatar", "the UUID of the avatar you wish to check with")]
[ArgHints("role", "the UUID of the role to invite them at the word \"everyone\"")]
public object GroupInvite(string group, string avatar, string role)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false)
{
return Failure("Invaild group UUID", "GroupInvite", new [] { group, avatar, role });
@ -228,16 +194,11 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Title empty")]
[ReturnHintsFailure("Message empty")]
[ReturnHintsFailure("Missing group Notice power")]
[ArgHints("group", "URLARG", "the UUID of the group")]
[ArgHints("title", "Text", "The title of the group notice")]
[ArgHints("message", "Text", "The body of the group notice")]
[Route(HttpVerbs.Post, "/Groupnotice/{group}/{token}")]
public object Groupnotice(string group, [FormField] string title, [FormField] string message, string token)
[ArgHints("group", "the UUID of the group")]
[ArgHints("title", "The title of the group notice")]
[ArgHints("message", "The body of the group notice")]
public object Groupnotice(string group, string title, string message)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false)
{
return Failure("Invaild group UUID", "Groupnotice", new [] { group, title, message });
@ -267,15 +228,10 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Unknown group")]
[ReturnHintsFailure("Invaild group UUID")]
[ReturnHintsFailure("Invaild role UUID")]
[ArgHints("group", "URLARG", "the UUID of the group")]
[ArgHints("role", "URLARG", "tje UUID of the role")]
[Route(HttpVerbs.Get, "/GroupActiveTitle/{group}/{token}")]
public object GroupActiveTitle(string group, string role, string token)
[ArgHints("group", "the UUID of the group")]
[ArgHints("role", "the UUID of the role")]
public object GroupActiveTitle(string group, string role)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false)
{
return Failure("Invaild group UUID", "GroupActiveTitle", new [] { group, role });
@ -296,14 +252,9 @@ namespace SecondBotEvents.Commands
[ReturnHints("Switching active group")]
[ReturnHintsFailure("Unknown group")]
[ReturnHintsFailure("Invaild group UUID")]
[ArgHints("group", "URLARG", "the UUID of the group")]
[Route(HttpVerbs.Get, "/GroupActiveGroup/{group}/{token}")]
public object GroupActiveGroup(string group, string token)
[ArgHints("group", "the UUID of the group")]
public object GroupActiveGroup(string group)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false)
{
return Failure("Invaild group UUID", "GroupActiveGroup", new [] { group });
@ -324,17 +275,12 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Title empty")]
[ReturnHintsFailure("Message empty")]
[ReturnHintsFailure("Missing group Notice power")]
[ArgHints("group", "URLARG", "the UUID of the group")]
[ArgHints("title", "Text", "The title of the group notice")]
[ArgHints("message", "Text", "The body of the group notice")]
[ArgHints("attachment", "URLARG", "the UUID of inventory you wish to attach")]
[Route(HttpVerbs.Post, "/Groupnotice/{group}/{attachment}/{token}")]
public object GroupnoticeWithAttachment(string group, [FormField] string title, [FormField] string message, string attachment, string token)
[ArgHints("group", "the UUID of the group")]
[ArgHints("title", "The title of the group notice")]
[ArgHints("message", "The body of the group notice")]
[ArgHints("attachment", "the UUID of inventory you wish to attach")]
public object GroupnoticeWithAttachment(string group, string title, string message, string attachment)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false)
{
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")]
[ReturnHints("array UUID=name")]
[Route(HttpVerbs.Get, "/GetGroupList/{token}")]
public object GetGroupList(string token)
public object GetGroupList()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroups()));
}
@ -382,14 +323,9 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Group is not currently known")]
[ReturnHintsFailure("Invaild group UUID")]
[ReturnHintsFailure("Updating")]
[ArgHints("group", "URLARG", "the UUID of the group")]
[Route(HttpVerbs.Get, "/GetGroupRoles/{group}/{token}")]
public object GetGroupRoles(string group, string token)
[ArgHints("group", "the UUID of the group")]
public object GetGroupRoles(string group)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupuuid) == false)
{
return Failure("Invaild group UUID", "GetGroupRoles", new [] { group });
@ -398,65 +334,23 @@ namespace SecondBotEvents.Commands
{
return Failure("Unknown group", "GetGroupRoles", new [] { group });
}
return Failure("@todo group role storage");
/*
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 });
*/
return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroupRoles(groupuuid)));
}
[About("fetchs a list of all groups with unread messages")]
[ReturnHints("array UUID")]
[Route(HttpVerbs.Get, "/GroupchatListAllUnreadGroups/{token}")]
public object GroupchatListAllUnreadGroups(string token)
public object GroupchatListAllUnreadGroups()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return Failure("@todo group message storage");
return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetAllGroupsChatWithUnread()));
}
[About("fetchs a list of all groups with unread messages")]
[ReturnHints("true|false")]
[ReturnHintsFailure("Unknown group")]
[ReturnHintsFailure("group value is invaild")]
[ArgHints("group", "URLARG", "the UUID of the group")]
[Route(HttpVerbs.Get, "/GroupchatGroupHasUnread/{group}/{token}")]
public object GroupchatGroupHasUnread(string group,string token)
[ArgHints("group", "the UUID of the group")]
public object GroupchatGroupHasUnread(string group)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
UUID groupUUID = UUID.Zero;
if(UUID.TryParse(group,out groupUUID) == false)
{
@ -466,66 +360,46 @@ namespace SecondBotEvents.Commands
{
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")]
[ReturnHints("True|False")]
[Route(HttpVerbs.Get, "/GroupchatAnyUnread/{token}")]
public object GroupchatAnyUnread(string token)
public object GroupchatAnyUnread()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return Failure("@todo group message storage");
return BasicReply(master.DataStoreService.GetGroupChatHasAnyUnread().ToString());
}
[About("Clears all group chat buffers at once")]
[ReturnHints("ok")]
[Route(HttpVerbs.Get, "/GroupchatClearAll/{token}")]
public object GroupchatClearAll(string token)
public object GroupchatClearAll()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return Failure("@todo group message storage");
master.DataStoreService.clearGroupChat();
return BasicReply("ok");
}
[About("fetchs the groupchat history")]
[ReturnHintsFailure("Group UUID invaild")]
[ReturnHints("Group Chat")]
[ArgHints("group", "URLARG", "the UUID of the group")]
[Route(HttpVerbs.Get, "/GroupchatHistory/{group}/{token}")]
public object GroupchatHistory(string group, string token)
[ArgHints("group", "the UUID of the group")]
public object GroupchatHistory(string group)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(group, out UUID groupUUID) == false)
{
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")]
[ArgHints("group", "URLARG", "UUID of the group")]
[ArgHints("message", "Text", "the message to send")]
[ArgHints("group", "UUID of the group")]
[ArgHints("message", "the message to send")]
[ReturnHints("Sending")]
[ReturnHintsFailure("Group UUID invaild")]
[ReturnHintsFailure("Opening groupchat - Please retry later")]
[ReturnHintsFailure("Missing group JoinChat power")]
[Route(HttpVerbs.Post, "/Groupchat/{group}/{token}")]
public object Groupchat(string group, [FormField] string message, string token)
[ReturnHintsFailure("Unknown group")]
public object Groupchat(string group, string message)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
UUID groupUUID = UUID.Zero;
if (UUID.TryParse(group, out groupUUID) == false)
{
@ -535,7 +409,12 @@ namespace SecondBotEvents.Commands
{
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 EmbedIO.Routing;
using Newtonsoft.Json;
using Newtonsoft.Json;
using OpenMetaverse;
using SecondBotEvents.Services;
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")]
[ReturnHints("A json object")]
[Route(HttpVerbs.Get, "/ListSculptys/{token}")]
public object ListSculptys(string token)
public object ListSculptys()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
Dictionary<uint, Primitive> objects_copy = getClient().Network.CurrentSim.ObjectsPrimitives.Copy();
Dictionary<uint, uint> mapLocalID = new Dictionary<uint, uint>();
@ -72,107 +65,77 @@ namespace SecondBotEvents.Commands
}
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")]
[ReturnHints("The build ID of the bot")]
[Route(HttpVerbs.Get, "/Version/{token}")]
public object Version(string token)
public object Version()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return BasicReply(master.GetVersion(), "Version");
return BasicReply(master.GetVersion());
}
[About("Fetchs the name of the bot")]
[ReturnHints("Firstname Lastname")]
[Route(HttpVerbs.Get, "/Name/{token}")]
public object Name(string token)
public object Name()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return BasicReply(getClient().Self.FirstName + " " + getClient().Self.LastName, "Name");
return BasicReply(getClient().Self.FirstName + " " + getClient().Self.LastName);
}
[About("Fetchs the current parcels name")]
[ReturnHints("Parcelname")]
[ReturnHintsFailure("Error parcel not found")]
[ReturnHintsFailure("Error not in a sim")]
[Route(HttpVerbs.Get, "/ParcelName/{token}")]
public object ParcelName(string token)
public object ParcelName()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
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);
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")]
[ReturnHints("Unixtime")]
[Route(HttpVerbs.Get, "/UnixTimeNow/{token}")]
public object UnixTimeNow(string token)
public object UnixTimeNow()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return BasicReply(SecondbotHelpers.UnixTimeNow().ToString(), "UnixTimeNow");
return BasicReply(SecondbotHelpers.UnixTimeNow().ToString());
}
[About("Fetchs the current region name")]
[ReturnHints("Regionname")]
[ReturnHintsFailure("Error not in a sim")]
[Route(HttpVerbs.Get, "/SimName/{token}")]
public object SimName(string token)
public object SimName()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
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")]
[ReturnHints("array of X,Y,Z values")]
[ReturnHintsFailure("Error not in a sim")]
[Route(HttpVerbs.Get, "/GetPosition/{token}")]
public object GetPosition(string token)
public object GetPosition()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
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>();
pos.Add("x", (int)Math.Round(getClient().Self.SimPosition.X));
pos.Add("y", (int)Math.Round(getClient().Self.SimPosition.Y));
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 EmbedIO;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using OpenMetaverse;
using OpenMetaverse.Assets;
using SecondBotEvents.Services;
@ -22,29 +19,19 @@ namespace SecondBotEvents.Commands
[ReturnHints("cleared")]
[ReturnHints("No action")]
[ReturnHints("Event added")]
[ArgHints("inventoryType", "URLARG", "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")]
[Route(HttpVerbs.Post, "/SetInventoryUpdate/{inventoryType}/{token}")]
public object SetInventoryUpdate(string inventoryType, [FormField] string outputTarget, string token)
[ArgHints("inventoryType", "Types: texture,sound,callcard,landmark,clothing,object,notecard,lsltext,lslbyte,animatn,gesture,mesh")]
[ArgHints("outputTarget", "HTTP url, channel, avatar UUID or clear to remove all events for the selected type")]
public object SetInventoryUpdate(string inventoryType, string outputTarget)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
return Failure("@todo inventory update events");
}
[About("Uploads a new sound file to inventory")]
[ReturnHints("ok")]
[ArgHints("sourcePath", "Text", "accepts a file path to a wave PCM file @ 44100")]
[ArgHints("inventoryName", "URLARG", "the name in secondlife")]
[Route(HttpVerbs.Post, "/UploadMediaWave/{inventoryName}/{token}")]
public object UploadMediaWave([FormField] string sourcePath, string inventoryName, string token)
[ArgHints("sourcePath", "accepts a file path to a wave PCM file @ 44100")]
[ArgHints("inventoryName", "the name in secondlife")]
public object UploadMediaWave(string sourcePath, string inventoryName)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
byte[] audioData = File.ReadAllBytes(sourcePath);
InventoryFolder AA = getClient().Inventory.Store.RootFolder;
List<InventoryBase> T = getClient().Inventory.Store.GetContents(AA);
@ -70,14 +57,9 @@ namespace SecondBotEvents.Commands
[ReturnHints("UUID of rezzed item")]
[ReturnHints("Invaild item UUID")]
[ReturnHints("Unable to find item")]
[ArgHints("item", "URLARG", "UUID of item to rez")]
[Route(HttpVerbs.Get, "/RezObject/{item}/{token}")]
public object RezObject(string item, string token)
[ArgHints("item", "UUID of item to rez")]
public object RezObject(string item)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(item, out UUID targetitem) == false)
{
return Failure("Invaild item UUID: "+ item, "RezObject", new [] { item });
@ -97,15 +79,10 @@ namespace SecondBotEvents.Commands
[ReturnHints("invaild item uuid")]
[ReturnHints("Item name is to short")]
[ReturnHints("Unable to find inventory item")]
[ArgHints("item", "URLARG", "UUID of item/folder to name")]
[ArgHints("newname", "Text", "What we are changing it to")]
[Route(HttpVerbs.Post, "/RenameInventory/{item}/{token}")]
public object RenameInventory(string item, [FormField] string newname, string token)
[ArgHints("item", "UUID of item/folder to name")]
[ArgHints("newname", "What we are changing it to")]
public object RenameInventory(string item, string newname)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(item, out UUID target) == false)
{
return Failure("invaild item uuid", "RenameInventory", new [] { item, newname });
@ -127,14 +104,9 @@ namespace SecondBotEvents.Commands
[About("Attempts to Remove the given inventory item")]
[ReturnHints("ok")]
[ReturnHints("invaild item uuid")]
[ArgHints("item", "URLARG", "UUID of item")]
[Route(HttpVerbs.Get, "/DeleteInventoryItem/{item}/{token}")]
public object DeleteInventoryItem(string item, string token)
[ArgHints("item", "UUID of item")]
public object DeleteInventoryItem(string item)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(item, out UUID target) == false)
{
return Failure("invaild item uuid", "DeleteInventoryItem", new [] { item });
@ -146,14 +118,9 @@ namespace SecondBotEvents.Commands
[About("Attempts to Remove the given inventory folder")]
[ReturnHints("ok")]
[ReturnHints("invaild folder uuid")]
[ArgHints("folder", "URLARG", "UUID of folder")]
[Route(HttpVerbs.Get, "/DeleteInventoryFolder/{folder}/{token}")]
public object DeleteInventoryFolder(string folder, string token)
[ArgHints("folder", "UUID of folder")]
public object DeleteInventoryFolder(string folder)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(folder, out UUID target) == false)
{
return Failure("invaild folder uuid", "DeleteInventoryFolder", new [] { folder });
@ -165,14 +132,9 @@ namespace SecondBotEvents.Commands
[About("Attempts to attach the given inventory item")]
[ReturnHints("ok")]
[ReturnHints("invaild item uuid")]
[ArgHints("item", "URLARG", "UUID of item")]
[Route(HttpVerbs.Get, "/Attach/{item}/{token}")]
public object Attach(string item, string token)
[ArgHints("item", "UUID of item")]
public object Attach(string item)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(item,out UUID itemuuid) == false)
{
return Failure("invaild item uuid", "Attach", new [] { item });
@ -185,14 +147,9 @@ namespace SecondBotEvents.Commands
[About("Attempts to Remove the given inventory folder")]
[ReturnHints("ok")]
[ReturnHints("invaild item uuid")]
[ArgHints("item", "URLARG", "UUID of item")]
[Route(HttpVerbs.Get, "/Detach/{item}/{token}")]
public object Detach(string item, string token)
[ArgHints("item", "UUID of item")]
public object Detach(string item)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(item, out UUID itemuuid) == false)
{
return Failure("invaild item uuid", "Detach", new [] { item });
@ -208,14 +165,9 @@ namespace SecondBotEvents.Commands
[ReturnHints("Cant find Clothing folder")]
[ReturnHints("Cant find target folder")]
[ReturnHints("target folder is empty or so full I cant get it in 5 secs...")]
[ArgHints("name", "URLARG", "Name of the folder")]
[Route(HttpVerbs.Get, "/Outfit/{name}/{token}")]
public object Outfit(string name, string token)
[ArgHints("name", "Name of the folder")]
public object Outfit(string name)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (SecondbotHelpers.notempty(name) == false)
{
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!")]
[ReturnHints("ok")]
[ReturnHints("Unable to find notecard folder")]
[Route(HttpVerbs.Get, "/InventoryPurgeNotecards/{token}")]
[Obsolete]
public object InventoryPurgeNotecards(string token)
public object InventoryPurgeNotecards()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
List<InventoryBase> T = getClient().Inventory.Store.GetContents(getClient().Inventory.Store.RootFolder);
InventoryBase NotecardFolder = null;
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")]
[ReturnHints("Asset UUID or UUID zero")]
[ReturnHints("Invaild item uuid")]
[ArgHints("item", "URLARG", "inventory level UUID of item")]
[Route(HttpVerbs.Get, "/getRealUUID/{item}/{token}")]
public object getRealUUID(string item, string token)
[ArgHints("item", "inventory level UUID of item")]
public object getRealUUID(string item)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(item, out UUID itemUUID) == false)
{
return Failure("Invaild item uuid", "getRealUUID", new [] { item });
@ -341,15 +282,10 @@ namespace SecondBotEvents.Commands
[ReturnHints("Invaild avatar uuid")]
[ReturnHints("Invaild item uuid")]
[ReturnHints("Unable to find item")]
[ArgHints("item", "URLARG", "UUID of item")]
[ArgHints("avatar", "URLARG", "a UUID or Firstname Lastname")]
[Route(HttpVerbs.Get, "/SendItem/{item}/{avatar}/{token}")]
public object SendItem(string item, string avatar, string token)
[ArgHints("item", "UUID of item")]
[ArgHints("avatar", "a UUID or Firstname Lastname")]
public object SendItem(string item, string avatar)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar);
if(avataruuid == UUID.Zero)
{
@ -374,15 +310,10 @@ namespace SecondBotEvents.Commands
[ReturnHints("Invaild avatar uuid")]
[ReturnHints("Invaild folter uuid")]
[ReturnHints("Unable to find folder")]
[ArgHints("item", "URLARG", "UUID of item")]
[ArgHints("avatar", "URLARG", "a UUID or Firstname Lastname")]
[Route(HttpVerbs.Get, "/SendFolder/{folder}/{avatar}/{token}")]
public object SendFolder(string folder, string avatar, string token)
[ArgHints("item", "UUID of item")]
[ArgHints("avatar", "a UUID or Firstname Lastname")]
public object SendFolder(string folder, string avatar)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
ProcessAvatar(avatar);
if (avataruuid == UUID.Zero)
{
@ -401,8 +332,6 @@ namespace SecondBotEvents.Commands
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])")]
[ReturnHints("Transfering running script")]
[ReturnHints("Transfering inventory")]
@ -411,17 +340,11 @@ namespace SecondBotEvents.Commands
[ReturnHints("Unable to find inventory")]
[ReturnHints("Unable to find object")]
[ReturnHints("Invaild running")]
[ArgHints("item", "URLARG", "UUID of item")]
[ArgHints("object", "URLARG", "the uuid of the object")]
[ArgHints("running", "URLARG", "true if you wish the transfered script to be running otherwise false")]
[Route(HttpVerbs.Get, "/TransferInventoryToObject/{item}/{objectuuid}/{running}/{token}")]
public object TransferInventoryToObject(string item, string objectuuid, string running, string token)
[ArgHints("item", "UUID of item")]
[ArgHints("object", "the uuid of the object")]
[ArgHints("running", "true if you wish the transfered script to be running otherwise false")]
public object TransferInventoryToObject(string item, string objectuuid, string running)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(item, out UUID itemuuid) == false)
{
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>")]
[ReturnHints("array of InventoryMapFolder")]
[ReturnHints("Error")]
[Route(HttpVerbs.Get, "/InventoryFolders/{token}")]
public object InventoryFolders(string token)
public object InventoryFolders()
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
string reply = HelperInventory.MapFolderJson(getClient());
if (reply != null) return BasicReply(reply, "InventoryFolders");
return Failure("Error", "InventoryFolders");
}
[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("Error")]
[Route(HttpVerbs.Get, "/InventoryFoldersLimited/{targetfolder}/{token}")]
public object InventoryFoldersLimited(string targetfolder,string token)
public object InventoryFoldersLimited(string targetfolder)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
string reply = HelperInventory.MapFolderJson(getClient(), targetfolder,false);
if (reply != null) return BasicReply(reply, "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>")]
[ReturnHints("array of InventoryMapItem")]
[ReturnHints("Invaild folder UUID")]
[ArgHints("folderUUID", "URLARG", "the folder to fetch (Found via: inventory/folders)")]
[Route(HttpVerbs.Get, "/InventoryContents/{folderUUID}/{token}")]
public object InventoryContents(string folderUUID, string token)
[ArgHints("folderUUID", "the folder to fetch (Found via: inventory/folders)")]
public object InventoryContents(string folderUUID)
{
if (AllowToken(token) == false)
{
return Failure("Token not accepted");
}
if (UUID.TryParse(folderUUID, out UUID folder) == false)
{
return Failure("Invaild folder UUID", "InventoryContents", new [] { folderUUID });

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -17,6 +17,31 @@ namespace SecondBotEvents.Config
settings.Add("NotecardStoragePurgeAfterMins");
settings.Add("PrefetchGroupMembers");
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()

View file

@ -37,7 +37,6 @@ namespace SecondBotEvents.Services
protected virtual void LoadCommandEndpoint(Type endpointtype)
{
CommandsAPI controler = (CommandsAPI)Activator.CreateInstance(endpointtype, args: new object[] { master });
controler.disableIPlockout();
commandEndpoints.Add(endpointtype.Name, controler);
foreach (MethodInfo M in endpointtype.GetMethods())
{
@ -241,13 +240,11 @@ namespace SecondBotEvents.Services
C.command = commandnameLowerToReal[C.command.ToLowerInvariant()];
try
{
string ott = SingleUseToken();
CommandsAPI Endpoint = commandEndpoints[endpointcommandmap[C.command]];
MethodInfo theMethod = Endpoint.GetType().GetMethod(C.command);
if (theMethod != null)
{
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();
bool status = false;
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, 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()
{
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;
AutoResetEvent fetchEvent = new AutoResetEvent(false);
EventHandler<GroupMembersReplyEventArgs> callback =
delegate (object sender, GroupMembersReplyEventArgs e)
{
if (e.GroupID == Group)
if (e.GroupID == group)
{
foreach (KeyValuePair<UUID, GroupMember> a in e.Members)
{
if (a.Value.ID == avatar)
{
found = true;
fetchEvent.Set();
break;
}
}
}
};
getClient().Groups.GroupMembersReply += callback;
getClient().Groups.RequestGroupMembers(Group);
getClient().Groups.RequestGroupMembers(group);
fetchEvent.WaitOne(1000, false);
getClient().Groups.GroupMembersReply -= callback;
@ -434,7 +600,7 @@ namespace SecondBotEvents.Services
groupsKey2Name = new Dictionary<UUID, string>();
groupMembers = new Dictionary<UUID, List<UUID>>();
groupRoles = new Dictionary<UUID, Dictionary<UUID, string>>();
groupRoles = new Dictionary<UUID, Dictionary<UUID, GroupRole>>();
localChatHistory = new List<string>();
@ -444,7 +610,9 @@ namespace SecondBotEvents.Services
chatWindowsUnread = new Dictionary<UUID, bool>(); // sess, bool
chatWindowsIsGroup = new Dictionary<UUID, bool>(); // sess, bool
chatWindowsOwner = new Dictionary<UUID, UUID>(); // sess, owner id
}
estateBanlist = new List<UUID>();
}
protected void BotClientRestart(object o, BotClientNotice e)
@ -466,7 +634,7 @@ namespace SecondBotEvents.Services
{
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;
}
@ -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)
{
getClient().Network.SimConnected -= BotLoggedIn;
@ -497,6 +694,7 @@ namespace SecondBotEvents.Services
getClient().Avatars.AvatarPickerReply += AvatarUUIDNamePicker;
getClient().Groups.GroupMembersReply += GroupMembers;
getClient().Groups.GroupRoleDataReply += GroupRoles;
getClient().Estate.EstateBansReply += EstateBans;
getClient().Groups.RequestCurrentGroups();
botConnected = true;
Console.WriteLine("DataStore Service [Active]");
@ -671,11 +869,28 @@ namespace SecondBotEvents.Services
getClient().Avatars.AvatarPickerReply -= AvatarUUIDNamePicker;
getClient().Groups.GroupMembersReply -= GroupMembers;
getClient().Groups.GroupRoleDataReply -= GroupRoles;
getClient().Estate.EstateBansReply -= EstateBans;
}
}
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.WebApi;
using OpenMetaverse;
using SecondBotEvents.Commands;
using SecondBotEvents.Config;
using Swan.Logging;
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using SecondBotEvents.Commands;
namespace SecondBotEvents.Services
{
public class HttpService: Services
public class HttpService : Services
{
protected WebServer HTTPendpoint = null;
protected HttpConfig myConfig;
protected bool acceptBotCommands = false;
public HttpService(EventsSecondBot setMaster) : base(setMaster)
{
myConfig = new HttpConfig(master.fromEnv,master.fromFolder);
myConfig = new HttpConfig(master.fromEnv, master.fromFolder);
if (myConfig.GetEnabled() == false)
{
Console.WriteLine(Status());
@ -29,7 +29,7 @@ namespace SecondBotEvents.Services
public override string Status()
{
if(myConfig == null)
if (myConfig == null)
{
return "HTTP service [Config status broken]";
}
@ -38,7 +38,7 @@ namespace SecondBotEvents.Services
return "HTTP service [- Not requested -]";
}
// @todo HTTP server check here
if(HTTPendpoint == null)
if (HTTPendpoint == null)
{
return "HTTP endpoint not online";
}
@ -96,7 +96,7 @@ namespace SecondBotEvents.Services
HTTPendpoint.Dispose();
HTTPendpoint = null;
Console.WriteLine("HTTP service [Stopping]");
}
}
}
private void CreateWebServer()
@ -106,30 +106,13 @@ namespace SecondBotEvents.Services
.WithUrlPrefix(myConfig.GetHost())
.WithMode(HttpListenerMode.EmbedIO))
.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" }))
);
HTTPendpoint.RunAsync();
}
}
public abstract class CommandsAPI : WebApiController
public abstract class CommandsAPI
{
protected EventsSecondBot master;
public CommandsAPI(EventsSecondBot setmaster)
@ -137,40 +120,9 @@ namespace SecondBotEvents.Services
master = setmaster;
}
protected bool AllowToken(string token)
{
return master.CommandsService.AllowToken(token);
}
protected UUID avataruuid = UUID.Zero;
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()
{
return master.botClient.client;
@ -200,7 +152,7 @@ namespace SecondBotEvents.Services
{
avataruuid = UUID.Zero;
string UUIDfetch = master.DataStoreService.getAvatarUUID(avatar);
if(UUIDfetch != "lookup")
if (UUIDfetch != "lookup")
{
UUID.TryParse(UUIDfetch, out avataruuid);
}
@ -240,7 +192,7 @@ namespace SecondBotEvents.Services
protected object Failure(string input)
{
// @todo Command history storage system
return new { reply = input, command= getCallingCommand(), status = false };
return new { reply = input, command = getCallingCommand(), status = false };
}
protected string getCallingCommand()
@ -261,7 +213,7 @@ namespace SecondBotEvents.Services
}
[AttributeUsage(AttributeTargets.Method)]
public class About : Attribute
{
@ -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)]
public class ReturnHints : Attribute
{
@ -296,7 +238,7 @@ namespace SecondBotEvents.Services
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class ReturnHintsFailure : ReturnHints
{
public ReturnHintsFailure(string hint): base(hint)
public ReturnHintsFailure(string hint) : base(hint)
{
this.good = false;
}
@ -306,13 +248,11 @@ namespace SecondBotEvents.Services
public class ArgHints : Attribute
{
public string name = "";
public string typename = "";
public string about = "";
public ArgHints(string name,string typename, string about)
public ArgHints(string name, string about)
{
this.name = name;
this.typename = typename;
this.about = about;
}
}