From f98b11915a0d2a5099e458d3840dd68cdc216f5a Mon Sep 17 00:00:00 2001 From: Madpeter Date: Mon, 26 Oct 2020 04:15:53 +0000 Subject: [PATCH] new command SetPermFlag --- Core/Commands/Self/SetPermFlag.cs | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Core/Commands/Self/SetPermFlag.cs diff --git a/Core/Commands/Self/SetPermFlag.cs b/Core/Commands/Self/SetPermFlag.cs new file mode 100644 index 0000000..ab7541c --- /dev/null +++ b/Core/Commands/Self/SetPermFlag.cs @@ -0,0 +1,51 @@ +using OpenMetaverse; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BSB.Commands.Self +{ + public class SetPermFlag : CoreCommand_3arg + { + public override string[] ArgTypes { get { return new[] { "Avatar", "Text","Text (True|Flase)", "Text (True|Flase)" }; } } + public override string[] ArgHints { get { return new[] { "Avatar [UUID or Firstname Lastname]", "Flag", "State to set the flag to","Make the permission sticky" }; } } + public override string Helpfile { get { return "Makes the bot pay a avatar"; } } + public override bool CallFunction(string[] args) + { + if (base.CallFunction(args) == true) + { + if(UUID.TryParse(args[0],out UUID targetUUID) == true) + { + string[] AcceptedFlags = new string[] { "friend", "group", "animation", "teleport", "commands" }; + if(AcceptedFlags.Contains(args[1]) == true) + { + if(bool.TryParse(args[2],out bool stateflag) == true) + { + bool sticky = false; + if(args.Length == 4) + { + bool.TryParse(args[3], out sticky); + } + if(stateflag == true) + { + bot.Add_action_from(args[1], targetUUID, sticky); + InfoBlob = "Added perm: "+args[1]+" Sticky: " + sticky.ToString(); + } + else + { + bot.Remove_action_from(args[1], targetUUID, sticky); + InfoBlob = "Removed perm: " + args[1] + " Sticky: " + sticky.ToString(); + } + return true; + } + return Failed("Failed to process state flag value"); + } + return Failed("Not an accepted flag"); + } + return Failed("Unable to process UUID"); + } + return false; + } + } +}