From 2110987f73f8dc72427c7f00ccf7fec63e9909be Mon Sep 17 00:00:00 2001 From: Madpeterz <57852827+Madpeterz@users.noreply.github.com> Date: Tue, 16 Feb 2021 08:46:48 +0000 Subject: [PATCH] Update Estate.cs adds update-banlist --- BetterSecondbot/HttpService/Estate.cs | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/BetterSecondbot/HttpService/Estate.cs b/BetterSecondbot/HttpService/Estate.cs index a9a9556..240bc46 100644 --- a/BetterSecondbot/HttpService/Estate.cs +++ b/BetterSecondbot/HttpService/Estate.cs @@ -4,6 +4,7 @@ using EmbedIO; using EmbedIO.Routing; using System; using Newtonsoft.Json; +using OpenMetaverse; namespace BetterSecondBot.HttpService { @@ -28,5 +29,46 @@ namespace BetterSecondBot.HttpService } return BasicReply("Token not accepted"); } + + [About("Attempts to add/remove the avatar to/from the Estate banlist")] + [ReturnHints("Request accepted")] + [ReturnHints("Unable to find avatar UUID")] + [ReturnHints("Unable to process global value please use true or false")] + [ReturnHints("Not an estate manager on region {REGIONNAME}")] + [ArgHints("avatar", "uuid", "the avatar you wish to ban")] + [ArgHints("mode", "add|remove", "What action would you like to take
Defaults to remove if not given \"add\"")] + [ArgHints("global", "true|false", "if true this the ban/unban will be applyed to all estates the bot has access to")] + [Route(HttpVerbs.Get, "/update-banlist/{avatar}/{mode}/{global}/{token}")] + + public Object UpdateBanlist(string avatar, string mode, string global, string token) + { + if (tokens.Allow(token, "estate", "banlist-add", getClientIP()) == true) + { + if(bot.GetClient.Network.CurrentSim.IsEstateManager == false) + { + return BasicReply("Not an estate manager on region "+ bot.GetClient.Network.CurrentSim.Name); + } + UUID avataruuid = UUID.Zero; + if(UUID.TryParse(avatar,out avataruuid) == false) + { + return BasicReply("Unable to find avatar UUID"); + } + bool globalban = false; + if(bool.TryParse(global,out globalban) == false) + { + return BasicReply("Unable to process global value please use true or false"); + } + if(mode != "add") + { + bot.GetClient.Estate.UnbanUser(avataruuid, globalban); + } + else + { + bot.GetClient.Estate.BanUser(avataruuid, globalban); + } + return BasicReply("Request accepted"); + } + return BasicReply("Token not accepted"); + } } }