wip
This commit is contained in:
parent
ed516f5872
commit
82b451c15e
89 changed files with 556 additions and 2327 deletions
79
BetterSecondbot/HttpService/Animation.cs
Normal file
79
BetterSecondbot/HttpService/Animation.cs
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
using BetterSecondBot.bottypes;
|
||||
using BetterSecondBot.Static;
|
||||
using EmbedIO;
|
||||
using EmbedIO.Routing;
|
||||
using EmbedIO.WebApi;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
using Newtonsoft.Json;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BetterSecondBot.HttpService
|
||||
{
|
||||
public class HttpApiAnimation : WebApiControllerWithTokens
|
||||
{
|
||||
public HttpApiAnimation(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { }
|
||||
|
||||
[About("Toggles if animation requests from this avatar (used for remote poseballs) are accepted")]
|
||||
[ReturnHints("Granted perm animation")]
|
||||
[ReturnHints("Removed perm animation")]
|
||||
[ReturnHints("avatar lookup")]
|
||||
[ArgHints("avatar", "URLARG", "UUID (or Firstname Lastname)")]
|
||||
[Route(HttpVerbs.Get, "/AddToAllowAnimations/{avatar}/{token}")]
|
||||
public object AddToAllowAnimations(string avatar, string token)
|
||||
{
|
||||
if (tokens.Allow(token, "animation", "addtoallowanimations", getClientIP()) == false)
|
||||
{
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
ProcessAvatar(avatar);
|
||||
if (avataruuid == UUID.Zero)
|
||||
{
|
||||
return BasicReply("avatar lookup");
|
||||
}
|
||||
if (bot.Accept_action_from("animation", avataruuid) == false)
|
||||
{
|
||||
bot.Add_action_from("animation", avataruuid);
|
||||
return BasicReply("Granted perm animation");
|
||||
}
|
||||
bot.Remove_action_from("animation", avataruuid, true);
|
||||
return BasicReply("Removed perm animation");
|
||||
}
|
||||
|
||||
[About("Attempts to play a gesture")]
|
||||
[ReturnHints("Error with gesture")]
|
||||
[ReturnHints("Accepted")]
|
||||
[ArgHints("gesture", "URLARG", "Inventory UUID of the gesture")]
|
||||
[Route(HttpVerbs.Get, "/PlayGesture/{gesture}/{token}")]
|
||||
public object PlayGesture(string gesture, string token)
|
||||
{
|
||||
if (tokens.Allow(token, "animation", "gesture", getClientIP()) == false)
|
||||
{
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
if (UUID.TryParse(gesture, out UUID gestureUUID) == false)
|
||||
{
|
||||
return BasicReply("Error with gesture");
|
||||
}
|
||||
InventoryItem itm = bot.GetClient.Inventory.FetchItem(gestureUUID, bot.GetClient.Self.AgentID, (3 * 1000));
|
||||
bot.GetClient.Self.PlayGesture(itm.AssetUUID);
|
||||
return BasicReply("Accepted");
|
||||
}
|
||||
|
||||
[About("Resets the animation stack for the bot")]
|
||||
[ReturnHints("Accepted")]
|
||||
[Route(HttpVerbs.Get, "/ResetAnimations/{token}")]
|
||||
public object ResetAnimations(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "animation", "resetanimations", getClientIP()) == false)
|
||||
{
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
bot.ResetAnimations();
|
||||
return BasicReply("Accepted");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
112
BetterSecondbot/HttpService/Avatars.cs
Normal file
112
BetterSecondbot/HttpService/Avatars.cs
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
using BetterSecondBot.bottypes;
|
||||
using BetterSecondBot.Static;
|
||||
using EmbedIO;
|
||||
using EmbedIO.Routing;
|
||||
using EmbedIO.WebApi;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
using Newtonsoft.Json;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BetterSecondBot.HttpService
|
||||
{
|
||||
public class HTTP_Avatars : WebApiControllerWithTokens
|
||||
{
|
||||
public HTTP_Avatars(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { }
|
||||
|
||||
[About("an improved version of near me with extra details<br/>NearMeDetails is a object formated as follows<br/><ul><li>id</li><li>name</li><li>x</li><li>y</li><li>z</li><li>range</li></ul>")]
|
||||
[ReturnHints("array NearMeDetails")]
|
||||
[ReturnHints("Error not in a sim")]
|
||||
[Route(HttpVerbs.Get, "/NearmeWithDetails/{token}")]
|
||||
public object NearmeWithDetails(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "avatars", "nearmewithdetails", getClientIP()) == false)
|
||||
{
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
if (bot.GetClient.Network.CurrentSim == null)
|
||||
{
|
||||
return BasicReply("Error not in a sim");
|
||||
}
|
||||
List<NearMeDetails> BetterNearMe = new List<NearMeDetails>();
|
||||
Dictionary<uint, Avatar> avcopy = bot.GetClient.Network.CurrentSim.ObjectsAvatars.Copy();
|
||||
foreach (Avatar av in avcopy.Values)
|
||||
{
|
||||
if (av.ID != bot.GetClient.Self.AgentID)
|
||||
{
|
||||
NearMeDetails details = new NearMeDetails();
|
||||
details.id = av.ID.ToString();
|
||||
details.name = av.Name;
|
||||
details.x = (int)Math.Round(av.Position.X);
|
||||
details.y = (int)Math.Round(av.Position.Y);
|
||||
details.z = (int)Math.Round(av.Position.Z);
|
||||
details.range = (int)Math.Round(Vector3.Distance(av.Position, bot.GetClient.Self.SimPosition));
|
||||
BetterNearMe.Add(details);
|
||||
}
|
||||
}
|
||||
return BasicReply(JsonConvert.SerializeObject(BetterNearMe));
|
||||
}
|
||||
|
||||
[About("returns a list of all known avatars nearby")]
|
||||
[ReturnHints("array UUID = Name")]
|
||||
[ReturnHints("Error not in a sim")]
|
||||
[Route(HttpVerbs.Get, "/Nearme/{token}")]
|
||||
public object Nearme(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "avatars", "nearme", getClientIP()) == false)
|
||||
{
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
if (bot.GetClient.Network.CurrentSim == null)
|
||||
{
|
||||
return BasicReply("Error not in a sim");
|
||||
}
|
||||
Dictionary<UUID, string> NearMe = new Dictionary<UUID, string>();
|
||||
Dictionary<uint, Avatar> avcopy = bot.GetClient.Network.CurrentSim.ObjectsAvatars.Copy();
|
||||
foreach (Avatar av in avcopy.Values)
|
||||
{
|
||||
if (av.ID != bot.GetClient.Self.AgentID)
|
||||
{
|
||||
NearMe.Add(av.ID, av.Name);
|
||||
}
|
||||
}
|
||||
return BasicReply(JsonConvert.SerializeObject(NearMe));
|
||||
}
|
||||
|
||||
|
||||
[About("Makes the bot pay a avatar")]
|
||||
[ReturnHints("Accepted")]
|
||||
[ReturnHints("avatar lookup")]
|
||||
[ReturnHints("Invaild amount")]
|
||||
[ReturnHints("Transfer funds to avatars disabled")]
|
||||
[Route(HttpVerbs.Get, "/PayAvatar/{avatar}/{amount}/{token}")]
|
||||
public object PayAvatar(string avatar,string amount,string token)
|
||||
{
|
||||
if (tokens.Allow(token, "avatars", "payavatar", getClientIP()) == false)
|
||||
{
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
if (bot.GetAllowFunds == false)
|
||||
{
|
||||
return BasicReply("Transfer funds to avatars disabled");
|
||||
}
|
||||
ProcessAvatar(avatar);
|
||||
if (avataruuid == UUID.Zero)
|
||||
{
|
||||
return BasicReply("avatar lookup");
|
||||
}
|
||||
if (int.TryParse(amount, out int amountvalue) == false)
|
||||
{
|
||||
return BasicReply("Invaild amount");
|
||||
}
|
||||
if(amountvalue < 1)
|
||||
{
|
||||
return BasicReply("Invaild amount");
|
||||
}
|
||||
bot.GetClient.Self.GiveAvatarMoney(avataruuid, amountvalue);
|
||||
return BasicReply("Accepted");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
|||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
using Newtonsoft.Json;
|
||||
using BetterSecondBotShared.Static;
|
||||
|
||||
namespace BetterSecondBot.HttpService
|
||||
{
|
||||
|
|
@ -17,8 +18,8 @@ namespace BetterSecondBot.HttpService
|
|||
|
||||
[About("fetchs the last 20 localchat messages")]
|
||||
[ReturnHints("array string")]
|
||||
[Route(HttpVerbs.Get, "/localchathistory/{token}")]
|
||||
public object localchatHistory(string token)
|
||||
[Route(HttpVerbs.Get, "/LocalChatHistory/{token}")]
|
||||
public object LocalChatHistory(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "chat", "localchathistory", getClientIP()) == true)
|
||||
{
|
||||
|
|
@ -30,15 +31,52 @@ namespace BetterSecondBot.HttpService
|
|||
[About("sends a message to localchat")]
|
||||
[ArgHints("message", "URLARG", "the message to send")]
|
||||
[ReturnHints("array string")]
|
||||
[Route(HttpVerbs.Post, "/localchatsay/{token}")]
|
||||
public object localchatSay(string token, [FormField] string message)
|
||||
[ReturnHints("Message empty")]
|
||||
[ReturnHints("Invaild channel")]
|
||||
[Route(HttpVerbs.Post, "/Say/{channel}/{token}")]
|
||||
public object Say(string channel,[FormField] string message,string token)
|
||||
{
|
||||
if (tokens.Allow(token, "chat", "localchatsay", getClientIP()) == true)
|
||||
if (tokens.Allow(token, "chat", "localchatsay", getClientIP()) == false)
|
||||
{
|
||||
bot.GetCommandsInterface.Call("say", message);
|
||||
return BasicReply(JsonConvert.SerializeObject(bot.getLocalChatHistory()));
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
return BasicReply("Token not accepted");
|
||||
if (helpers.notempty(message) == false)
|
||||
{
|
||||
return BasicReply("Message empty");
|
||||
}
|
||||
if(int.TryParse(channel,out int channelnum) == false)
|
||||
{
|
||||
return BasicReply("Invaild channel");
|
||||
}
|
||||
bot.GetClient.Self.Chat(message, channelnum, ChatType.Normal);
|
||||
return BasicReply(JsonConvert.SerializeObject(bot.getLocalChatHistory()));
|
||||
|
||||
}
|
||||
|
||||
[About("sends a im to the selected avatar")]
|
||||
[ArgHints("avatar", "URLARG", "a UUID or Firstname Lastname")]
|
||||
[ArgHints("message", "Text", "the message to send")]
|
||||
[ReturnHints("ok")]
|
||||
[ReturnHints("Message empty")]
|
||||
[ReturnHints("avatar lookup")]
|
||||
[Route(HttpVerbs.Post, "/IM/{avatar}/{token}")]
|
||||
public object IM(string avatar, [FormField] string message, string token)
|
||||
{
|
||||
if (tokens.Allow(token, "chat", "im", getClientIP()) == false)
|
||||
{
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
ProcessAvatar(avatar);
|
||||
if(avataruuid == UUID.Zero)
|
||||
{
|
||||
return BasicReply("avatar lookup");
|
||||
}
|
||||
if (helpers.notempty(message) == false)
|
||||
{
|
||||
return BasicReply("Message empty");
|
||||
}
|
||||
bot.SendIM(avataruuid, message);
|
||||
return BasicReply("ok");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,9 +12,6 @@ using Newtonsoft.Json;
|
|||
|
||||
namespace BetterSecondBot.HttpService
|
||||
{
|
||||
|
||||
|
||||
|
||||
public class HttpApiCore : WebApiControllerWithTokens
|
||||
{
|
||||
|
||||
|
|
@ -30,7 +27,7 @@ namespace BetterSecondBot.HttpService
|
|||
[ReturnHints("A new token with full system scope")]
|
||||
[ArgHints("authcode", "text", "the first 10 chars of SHA1(unixtime+WebUIkey)<br/>unixtime can be +- 30 of the bots time.")]
|
||||
[ArgHints("unixtimegiven", "number", "the unixtime you made this request")]
|
||||
[Route(HttpVerbs.Post, "/gettoken")]
|
||||
[Route(HttpVerbs.Post, "/GetToken")]
|
||||
public Object GetToken([FormField] string authcode, [FormField] string unixtimegiven)
|
||||
{
|
||||
long now = helpers.UnixTimeNow();
|
||||
|
|
@ -56,7 +53,7 @@ namespace BetterSecondBot.HttpService
|
|||
|
||||
[About("Gets the friendslist <br/>Formated as follows<br/>friendreplyobject<br/><ul><li>name: String</li><li>id: String</li><li>online: bool</li></ul>")]
|
||||
[ReturnHints("array UUID = friendreplyobject")]
|
||||
[Route(HttpVerbs.Get, "/friends/{token}")]
|
||||
[Route(HttpVerbs.Get, "/Friends/{token}")]
|
||||
public object Friends(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "core", "friends", getClientIP()) == true)
|
||||
|
|
@ -72,7 +69,7 @@ namespace BetterSecondBot.HttpService
|
|||
[ArgHints("x", "URLARG", "X location to AutoPilot to")]
|
||||
[ArgHints("y", "URLARG", "y location to AutoPilot to")]
|
||||
[ArgHints("z", "URLARG", "z location to AutoPilot to")]
|
||||
[Route(HttpVerbs.Get, "/walkto/{x}/{y}/{z}/{token}")]
|
||||
[Route(HttpVerbs.Get, "/WalkTo/{x}/{y}/{z}/{token}")]
|
||||
public object WalkTo(string x, string y, string z, string token)
|
||||
{
|
||||
if (tokens.Allow(token, "core", "walkto", getClientIP()) == true)
|
||||
|
|
@ -87,24 +84,7 @@ namespace BetterSecondBot.HttpService
|
|||
return BasicReply("Token not accepted");
|
||||
}
|
||||
|
||||
[About("Attempts to play a gesture")]
|
||||
[ReturnHints("Invaild gesture UUID for arg 1")]
|
||||
[ReturnHints("Accepted")]
|
||||
[ArgHints("gesture", "URLARG", "Inventory UUID of the gesture")]
|
||||
[Route(HttpVerbs.Get, "/gesture/{gesture}/{token}")]
|
||||
public object Gesture(string gesture, string token)
|
||||
{
|
||||
if (tokens.Allow(token, "core", "gesture", getClientIP()) == true)
|
||||
{
|
||||
bool status = bot.GetCommandsInterface.Call("PlayGesture", gesture);
|
||||
if (status == true)
|
||||
{
|
||||
return BasicReply("Accepted");
|
||||
}
|
||||
return BasicReply("Error with gesture");
|
||||
}
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
|
||||
|
||||
[About("Attempt to teleport to a new region")]
|
||||
[ReturnHints("Error Unable to Teleport to location")]
|
||||
|
|
@ -113,7 +93,7 @@ namespace BetterSecondBot.HttpService
|
|||
[ArgHints("x", "URLARG", "X location to teleport to")]
|
||||
[ArgHints("y", "URLARG", "y location to teleport to")]
|
||||
[ArgHints("z", "URLARG", "z location to teleport to")]
|
||||
[Route(HttpVerbs.Get, "/teleport/{region}/{x}/{y}/{z}/{token}")]
|
||||
[Route(HttpVerbs.Get, "/Teleport/{region}/{x}/{y}/{z}/{token}")]
|
||||
public object Teleport(string region,string x, string y, string z, string token)
|
||||
{
|
||||
if (tokens.Allow(token, "core", "teleport", getClientIP()) == true)
|
||||
|
|
@ -132,7 +112,7 @@ namespace BetterSecondBot.HttpService
|
|||
[ReturnHints("Unable to find region")]
|
||||
[ReturnHints("Texture UUID")]
|
||||
[ArgHints("regionname", "URLARG", "the name of the region we are fetching")]
|
||||
[Route(HttpVerbs.Get, "/regiontile/{regionname}/{token}")]
|
||||
[Route(HttpVerbs.Get, "/Regiontile/{regionname}/{token}")]
|
||||
public object Regiontile(string regionname, string token)
|
||||
{
|
||||
if (tokens.Allow(token, "core", "regiontile", getClientIP()) == true)
|
||||
|
|
@ -149,69 +129,12 @@ namespace BetterSecondBot.HttpService
|
|||
return BasicReply("Token not accepted");
|
||||
}
|
||||
|
||||
[About("an improved version of near me with extra details<br/>NearMeDetails is a object formated as follows<br/><ul><li>id</li><li>name</li><li>x</li><li>y</li><li>z</li><li>range</li></ul>")]
|
||||
[ReturnHints("array NearMeDetails")]
|
||||
[ReturnHints("Error not in a sim")]
|
||||
[Route(HttpVerbs.Get, "/nearmewithdetails/{token}")]
|
||||
public object NearmeWithDetails(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "core", "nearmewithdetails", getClientIP()) == true)
|
||||
{
|
||||
if (bot.GetClient.Network.CurrentSim != null)
|
||||
{
|
||||
List<NearMeDetails> BetterNearMe = new List<NearMeDetails>();
|
||||
Dictionary<uint, Avatar> avcopy = bot.GetClient.Network.CurrentSim.ObjectsAvatars.Copy();
|
||||
foreach (Avatar av in avcopy.Values)
|
||||
{
|
||||
if (av.ID != bot.GetClient.Self.AgentID)
|
||||
{
|
||||
NearMeDetails details = new NearMeDetails();
|
||||
details.id = av.ID.ToString();
|
||||
details.name = av.Name;
|
||||
details.x = (int)Math.Round(av.Position.X);
|
||||
details.y = (int)Math.Round(av.Position.Y);
|
||||
details.z = (int)Math.Round(av.Position.Z);
|
||||
details.range = (int)Math.Round(Vector3.Distance(av.Position, bot.GetClient.Self.SimPosition));
|
||||
BetterNearMe.Add(details);
|
||||
}
|
||||
}
|
||||
return BasicReply(JsonConvert.SerializeObject(BetterNearMe));
|
||||
}
|
||||
return BasicReply("Error not in a sim");
|
||||
}
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
|
||||
[About("returns a list of all known avatars nearby")]
|
||||
[ReturnHints("array UUID = Name")]
|
||||
[ReturnHints("Error not in a sim")]
|
||||
[Route(HttpVerbs.Get, "/nearme/{token}")]
|
||||
public object Nearme(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "core", "nearme", getClientIP()) == true)
|
||||
{
|
||||
if (bot.GetClient.Network.CurrentSim != null)
|
||||
{
|
||||
Dictionary<UUID, string> NearMe = new Dictionary<UUID, string>();
|
||||
Dictionary<uint, Avatar> avcopy = bot.GetClient.Network.CurrentSim.ObjectsAvatars.Copy();
|
||||
foreach (Avatar av in avcopy.Values)
|
||||
{
|
||||
if (av.ID != bot.GetClient.Self.AgentID)
|
||||
{
|
||||
NearMe.Add(av.ID, av.Name);
|
||||
}
|
||||
}
|
||||
return BasicReply(JsonConvert.SerializeObject(NearMe));
|
||||
}
|
||||
return BasicReply("Error not in a sim");
|
||||
}
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
|
||||
[About("Used to check HTTP connections")]
|
||||
[ReturnHints("world")]
|
||||
[NeedsToken(false)]
|
||||
[Route(HttpVerbs.Get, "/hello")]
|
||||
[Route(HttpVerbs.Get, "/Hello")]
|
||||
public object Hello()
|
||||
{
|
||||
return BasicReply("world");
|
||||
|
|
@ -221,7 +144,7 @@ namespace BetterSecondBot.HttpService
|
|||
[About("Removes the given token from the accepted token pool")]
|
||||
[ReturnHints("Failed to remove token")]
|
||||
[ReturnHints("ok")]
|
||||
[Route(HttpVerbs.Get, "/logout/{token}")]
|
||||
[Route(HttpVerbs.Get, "/Logout/{token}")]
|
||||
public object Logout(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "core", "logout", getClientIP()) == true)
|
||||
|
|
@ -235,7 +158,7 @@ namespace BetterSecondBot.HttpService
|
|||
|
||||
[About("Fetchs the current bot")]
|
||||
[ReturnHints("The build ID of the bot")]
|
||||
[Route(HttpVerbs.Get, "/version/{token}")]
|
||||
[Route(HttpVerbs.Get, "/Version/{token}")]
|
||||
public object Version(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "core", "version", getClientIP()) == true)
|
||||
|
|
@ -247,7 +170,7 @@ namespace BetterSecondBot.HttpService
|
|||
|
||||
[About("Fetchs the name of the bot")]
|
||||
[ReturnHints("Firstname Lastname")]
|
||||
[Route(HttpVerbs.Get, "/name/{token}")]
|
||||
[Route(HttpVerbs.Get, "/Name/{token}")]
|
||||
public object Name(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "core", "name", getClientIP()) == true)
|
||||
|
|
@ -260,7 +183,7 @@ namespace BetterSecondBot.HttpService
|
|||
[About("Fetchs the current region name")]
|
||||
[ReturnHints("Regionname")]
|
||||
[ReturnHints("Error not in a sim")]
|
||||
[Route(HttpVerbs.Get, "/regionname/{token}")]
|
||||
[Route(HttpVerbs.Get, "/Regionname/{token}")]
|
||||
public object Regionname(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "core", "regionname", getClientIP()) == true)
|
||||
|
|
@ -277,7 +200,7 @@ namespace BetterSecondBot.HttpService
|
|||
[About("Fetchs the current location of the bot")]
|
||||
[ReturnHints("array of X,Y,Z values")]
|
||||
[ReturnHints("Error not in a sim")]
|
||||
[Route(HttpVerbs.Get, "/location/{token}")]
|
||||
[Route(HttpVerbs.Get, "/Location/{token}")]
|
||||
public object Location(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "core", "location", getClientIP()) == true)
|
||||
|
|
@ -301,8 +224,8 @@ namespace BetterSecondBot.HttpService
|
|||
[ReturnHints("accepted")]
|
||||
[ReturnHints("Auth not accepted")]
|
||||
[ReturnHints("Failed")]
|
||||
[Route(HttpVerbs.Post, "/command/{token}")]
|
||||
public async Task<object> command(string token)
|
||||
[Route(HttpVerbs.Post, "/Command/{token}")]
|
||||
public async Task<object> Command(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "core", "command", getClientIP()) == true)
|
||||
{
|
||||
|
|
|
|||
99
BetterSecondbot/HttpService/Dialogs.cs
Normal file
99
BetterSecondbot/HttpService/Dialogs.cs
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
using BetterSecondBot.bottypes;
|
||||
using BetterSecondBot.Static;
|
||||
using EmbedIO;
|
||||
using EmbedIO.Routing;
|
||||
using EmbedIO.WebApi;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
using Newtonsoft.Json;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BetterSecondBot.HttpService
|
||||
{
|
||||
public class HTTP_Dialogs : WebApiControllerWithTokens
|
||||
{
|
||||
public HTTP_Dialogs(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { }
|
||||
|
||||
[About("Updates the relay target (you can have 1 of each type)<br/>Clear will disable them all")]
|
||||
[ReturnHints("cleared")]
|
||||
[ReturnHints("set/avatar")]
|
||||
[ReturnHints("set/http")]
|
||||
[ReturnHints("set/channel")]
|
||||
[ReturnHints("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)
|
||||
{
|
||||
if (tokens.Allow(token, "dialogs", "DialogRelay", getClientIP()) == false)
|
||||
{
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
if (target == "clear")
|
||||
{
|
||||
bot.SetRelayDialogsAvatar(UUID.Zero);
|
||||
bot.SetRelayDialogsChannel(0);
|
||||
bot.SetRelayDialogsHTTP("");
|
||||
return BasicReply("cleared");
|
||||
}
|
||||
ProcessAvatar(target);
|
||||
if (avataruuid != UUID.Zero)
|
||||
{
|
||||
bot.SetRelayDialogsAvatar(avataruuid);
|
||||
return BasicReply("set/avatar");
|
||||
}
|
||||
if (target.StartsWith("http") == true)
|
||||
{
|
||||
bot.SetRelayDialogsHTTP(target);
|
||||
return BasicReply("set/http");
|
||||
}
|
||||
if (int.TryParse(target, out int channel) == true)
|
||||
{
|
||||
bot.SetRelayDialogsChannel(channel);
|
||||
return BasicReply("set/channel");
|
||||
}
|
||||
return BasicReply("Not a vaild option");
|
||||
|
||||
}
|
||||
|
||||
[About("Makes the bot interact with the dialog [dialogid] with the button [buttontext]")]
|
||||
[ReturnHints("true")]
|
||||
[ReturnHints("false")]
|
||||
[ReturnHints("bad dialog id")]
|
||||
[ArgHints("target", "URLARG", "Options: Channel (Any number),Avatar UUID,HTTPurl<br/>Clear")]
|
||||
[Route(HttpVerbs.Get, "/DialogResponce/{dialogid}/{buttontext}/{token}")]
|
||||
public object DialogResponce(string dialogid, string buttontext, string token)
|
||||
{
|
||||
if (tokens.Allow(token, "dialogs", "DialogResponce", getClientIP()) == false)
|
||||
{
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
if (int.TryParse(dialogid, out int dialogidnum) == false)
|
||||
{
|
||||
return BasicReply("bad dialog id");
|
||||
}
|
||||
return BasicReply(bot.DialogReply(dialogidnum, buttontext).ToString());
|
||||
}
|
||||
|
||||
[About("Should the bot track dialogs and send them to the relays setup?")]
|
||||
[ReturnHints("updated")]
|
||||
[ReturnHints("bad status")]
|
||||
[ArgHints("status", "URLARG", "true or false")]
|
||||
[Route(HttpVerbs.Get, "/DialogTrack/{status}/{token}")]
|
||||
public object DialogTrack(string status, string token)
|
||||
{
|
||||
if (tokens.Allow(token, "dialogs", "DialogTrack", getClientIP()) == false)
|
||||
{
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
if (bool.TryParse(status, out bool statuscode) == false)
|
||||
{
|
||||
return BasicReply("bad status");
|
||||
}
|
||||
bot.SetTrackDialogs(statuscode);
|
||||
return BasicReply("updated");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
105
BetterSecondbot/HttpService/Discord.cs
Normal file
105
BetterSecondbot/HttpService/Discord.cs
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
using BetterSecondBot.bottypes;
|
||||
using BetterSecondBot.Static;
|
||||
using EmbedIO;
|
||||
using EmbedIO.Routing;
|
||||
using EmbedIO.WebApi;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
using Newtonsoft.Json;
|
||||
using System.Reflection;
|
||||
using Discord.WebSocket;
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
|
||||
namespace BetterSecondBot.HttpService
|
||||
{
|
||||
public class HTTP_Discord : WebApiControllerWithTokens
|
||||
{
|
||||
public HTTP_Discord(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { }
|
||||
|
||||
[About("Adds a discord server role to the selected member")]
|
||||
[ReturnHints("Discord client not ready")]
|
||||
[ReturnHints("true")]
|
||||
[ReturnHints("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)
|
||||
{
|
||||
if (tokens.Allow(token, "discord", "Discord_AddRole", getClientIP()) == false)
|
||||
{
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
if (bot.discordReady() == false)
|
||||
{
|
||||
return BasicReply("Discord client not ready");
|
||||
}
|
||||
return BasicReply(addRoleToMember(serverid, roleid, memberid).Result.ToString());
|
||||
}
|
||||
|
||||
[About("Adds the selected user to the ban list - Disallows rejoining untill they are removed from the list")]
|
||||
[ReturnHints("Discord client not ready")]
|
||||
[ReturnHints("true")]
|
||||
[ReturnHints("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.Get, "/Discord_BanMember/{serverid}/{memberid}/{token}")]
|
||||
public object Discord_BanMember(string serverid, string memberid, [FormField] string why, string token)
|
||||
{
|
||||
if (tokens.Allow(token, "discord", "Discord_BanMember", getClientIP()) == false)
|
||||
{
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
if (bot.discordReady() == false)
|
||||
{
|
||||
return BasicReply("Discord client not ready");
|
||||
}
|
||||
return BasicReply(BanMember(serverid, memberid, why).Result.ToString());
|
||||
}
|
||||
|
||||
|
||||
protected async Task<bool> BanMember(string givenserverid, string givenmemberid, string why)
|
||||
{
|
||||
DiscordSocketClient Discord = bot.getDiscordClient();
|
||||
if (ulong.TryParse(givenserverid, out ulong serverid) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (ulong.TryParse(givenmemberid, out ulong memberid) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
SocketGuild server = Discord.GetGuild(serverid);
|
||||
SocketGuildUser user = server.GetUser(memberid);
|
||||
await user.BanAsync(7, why);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected async Task<bool> addRoleToMember(string givenserverid, string givenroleid, string givenmemberid)
|
||||
{
|
||||
DiscordSocketClient Discord = bot.getDiscordClient();
|
||||
if (ulong.TryParse(givenserverid, out ulong serverid) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (ulong.TryParse(givenroleid, out ulong roleid) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (ulong.TryParse(givenmemberid, out ulong memberid) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
SocketGuild server = Discord.GetGuild(serverid);
|
||||
SocketRole role = server.GetRole(roleid);
|
||||
SocketGuildUser user = server.GetUser(memberid);
|
||||
await user.AddRoleAsync(role); // ? Irole seems to accept SocketRole ?
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,8 +20,8 @@ namespace BetterSecondBot.HttpService
|
|||
|
||||
[About("Requests the estate banlist")]
|
||||
[ReturnHints("")]
|
||||
[Route(HttpVerbs.Get, "/banlist/{token}")]
|
||||
public Object Banlist(string token)
|
||||
[Route(HttpVerbs.Get, "/GetEstateBanList/{token}")]
|
||||
public Object GetEstateBanList(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "estate", "banlist", getClientIP()) == true)
|
||||
{
|
||||
|
|
@ -38,9 +38,9 @@ namespace BetterSecondBot.HttpService
|
|||
[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, "/update-banlist/{avatar}/{mode}/{global}/{token}")]
|
||||
[Route(HttpVerbs.Get, "/UpdateEstateBanlist/{avatar}/{mode}/{global}/{token}")]
|
||||
|
||||
public Object UpdateBanlist(string avatar, string mode, string global, string token)
|
||||
public Object UpdateEstateBanlist(string avatar, string mode, string global, string token)
|
||||
{
|
||||
if (tokens.Allow(token, "estate", "banlist-add", getClientIP()) == true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ using EmbedIO.Routing;
|
|||
using BetterSecondBotShared.logs;
|
||||
using BetterSecondBotShared.IO;
|
||||
using Newtonsoft.Json;
|
||||
using OpenMetaverse;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
|
||||
namespace BetterSecondBot.HttpService
|
||||
{
|
||||
|
|
@ -145,7 +148,7 @@ namespace BetterSecondBot.HttpService
|
|||
if (killedLogger == false)
|
||||
{
|
||||
killedLogger = true;
|
||||
Logger.UnregisterLogger<ConsoleLogger>();
|
||||
Swan.Logging.Logger.UnregisterLogger<ConsoleLogger>();
|
||||
}
|
||||
using (var server = CreateWebServer(Config.Http_Host))
|
||||
{
|
||||
|
|
@ -259,6 +262,24 @@ namespace BetterSecondBot.HttpService
|
|||
protected Dictionary<string, scopedTokenInfo> scopedtokens = new Dictionary<string, scopedTokenInfo>();
|
||||
|
||||
|
||||
protected List<string> OneTimeTokens = new List<string>();
|
||||
|
||||
public string OneTimeToken()
|
||||
{
|
||||
bool known = true;
|
||||
string last = "";
|
||||
while (known == true)
|
||||
{
|
||||
last = helpers.GetSHA1(last + helpers.UnixTimeNow() + new Random().Next(13256).ToString()).Substring(0, 10);
|
||||
if(OneTimeTokens.Contains(last) == false)
|
||||
{
|
||||
known = false;
|
||||
OneTimeTokens.Add(last);
|
||||
}
|
||||
}
|
||||
return last;
|
||||
}
|
||||
|
||||
public void AddScopedToken(string code, scopedTokenInfo info)
|
||||
{
|
||||
scopedtokens.Add(code, info);
|
||||
|
|
@ -308,6 +329,11 @@ namespace BetterSecondBot.HttpService
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if(OneTimeTokens.Contains(code) == true)
|
||||
{
|
||||
OneTimeTokens.Remove(code);
|
||||
return true;
|
||||
}
|
||||
return ScopeAllow(code, workgroup, command);
|
||||
}
|
||||
|
||||
|
|
@ -370,7 +396,43 @@ namespace BetterSecondBot.HttpService
|
|||
protected TokenStorage tokens;
|
||||
protected SecondBot bot;
|
||||
public bool needsToken { get; set; }
|
||||
protected UUID avataruuid = UUID.Zero;
|
||||
|
||||
protected string CallMethod(string name,string[] args)
|
||||
{
|
||||
MethodInfo[] methods = this.GetType().GetMethods();
|
||||
MethodInfo found = null;
|
||||
foreach(MethodInfo M in methods)
|
||||
{
|
||||
if(M.Name == name)
|
||||
{
|
||||
found = M;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(found == null)
|
||||
{
|
||||
return "Failed:Not Found";
|
||||
}
|
||||
List<string> settings = new List<string>(args);
|
||||
settings.Add(tokens.OneTimeToken());
|
||||
if(found.GetParameters().Length != settings.Count)
|
||||
{
|
||||
return "Failed:Incorrect args";
|
||||
}
|
||||
string reply = (string)found.Invoke(this, settings.Cast<object>().ToArray());
|
||||
return "Passed:"+ reply;
|
||||
}
|
||||
protected void ProcessAvatar(string avatar)
|
||||
{
|
||||
string[] bits = avatar.Split(' ');
|
||||
avataruuid = UUID.Zero;
|
||||
if (bits.Length == 2)
|
||||
{
|
||||
avatar = bot.FindAvatarName2Key(avatar);
|
||||
}
|
||||
UUID.TryParse(avatar, out avataruuid);
|
||||
}
|
||||
|
||||
protected Object BasicReply(string input)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,17 +15,16 @@ namespace BetterSecondBot.HttpService
|
|||
{
|
||||
public HttpApiIM(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { }
|
||||
|
||||
|
||||
[About("gets a full list of all chat windows")]
|
||||
[ReturnHints("array UUID = Name")]
|
||||
[Route(HttpVerbs.Get, "/chatwindows/{token}")]
|
||||
public object chatwindows(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "im", "chatwindows", getClientIP()) == true)
|
||||
if (tokens.Allow(token, "im", "chatwindows", getClientIP()) == false)
|
||||
{
|
||||
return BasicReply(JsonConvert.SerializeObject(bot.GetIMChatWindowKeyNames()));
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
return BasicReply("Token not accepted");
|
||||
return BasicReply(JsonConvert.SerializeObject(bot.GetIMChatWindowKeyNames()));
|
||||
}
|
||||
|
||||
[About("gets a list of chat windows with unread messages")]
|
||||
|
|
@ -33,19 +32,19 @@ namespace BetterSecondBot.HttpService
|
|||
[Route(HttpVerbs.Get, "/listwithunread/{token}")]
|
||||
public object listwithunread(string group, string token)
|
||||
{
|
||||
if (tokens.Allow(token, "im", "listwithunread", getClientIP()) == true)
|
||||
if (tokens.Allow(token, "im", "listwithunread", getClientIP()) == false)
|
||||
{
|
||||
List<UUID> unreadimwindows = new List<UUID>();
|
||||
foreach (UUID window in bot.IMChatWindows())
|
||||
{
|
||||
if (bot.ImChatWindowHasUnread(window) == true)
|
||||
{
|
||||
unreadimwindows.Add(window);
|
||||
}
|
||||
}
|
||||
return BasicReply(JsonConvert.SerializeObject(unreadimwindows));
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
return BasicReply("Token not accepted");
|
||||
List<UUID> unreadimwindows = new List<UUID>();
|
||||
foreach (UUID window in bot.IMChatWindows())
|
||||
{
|
||||
if (bot.ImChatWindowHasUnread(window) == true)
|
||||
{
|
||||
unreadimwindows.Add(window);
|
||||
}
|
||||
}
|
||||
return BasicReply(JsonConvert.SerializeObject(unreadimwindows));
|
||||
}
|
||||
|
||||
[About("gets if there are any unread im messages at all")]
|
||||
|
|
@ -53,20 +52,20 @@ namespace BetterSecondBot.HttpService
|
|||
[Route(HttpVerbs.Get, "/haveunreadims/{token}")]
|
||||
public object haveunreadims(string token)
|
||||
{
|
||||
if (tokens.Allow(token, "im", "haveunreadims", getClientIP()) == true)
|
||||
if (tokens.Allow(token, "im", "haveunreadims", getClientIP()) == false)
|
||||
{
|
||||
bool reply = false;
|
||||
foreach(UUID window in bot.IMChatWindows())
|
||||
{
|
||||
if(bot.ImChatWindowHasUnread(window) == true)
|
||||
{
|
||||
reply = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return BasicReply(reply.ToString());
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
return BasicReply("Token not accepted");
|
||||
bool reply = false;
|
||||
foreach (UUID window in bot.IMChatWindows())
|
||||
{
|
||||
if (bot.ImChatWindowHasUnread(window) == true)
|
||||
{
|
||||
reply = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return BasicReply(reply.ToString());
|
||||
}
|
||||
|
||||
[About("gets the chat from the selected window")]
|
||||
|
|
@ -76,32 +75,15 @@ namespace BetterSecondBot.HttpService
|
|||
[Route(HttpVerbs.Get, "/getimchat/{window}/{token}")]
|
||||
public object getimchat(string window, string token)
|
||||
{
|
||||
if (tokens.Allow(token, "im", "getimchat", getClientIP()) == true)
|
||||
if (tokens.Allow(token, "im", "getimchat", getClientIP()) == false)
|
||||
{
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
if (UUID.TryParse(window, out UUID windowUUID) == false)
|
||||
{
|
||||
if (UUID.TryParse(window, out UUID windowUUID) == true)
|
||||
{
|
||||
return BasicReply(JsonConvert.SerializeObject(bot.GetIMChatWindow(windowUUID)));
|
||||
}
|
||||
return BasicReply("Window UUID invaild");
|
||||
}
|
||||
return BasicReply("Token not accepted");
|
||||
return BasicReply(JsonConvert.SerializeObject(bot.GetIMChatWindow(windowUUID)));
|
||||
}
|
||||
|
||||
[About("sends a im to the selected avatar")]
|
||||
[ArgHints("avatar", "URLARG", "a UUID or Firstname Lastname")]
|
||||
[ArgHints("message", "Text", "the message to send")]
|
||||
[ReturnHints("ok")]
|
||||
[Route(HttpVerbs.Post, "/sendimchat/{avatar}/{token}")]
|
||||
public object sendimchat(string avatar, string token, [FormField] string message)
|
||||
{
|
||||
if (tokens.Allow(token, "im", "sendimchat", getClientIP()) == true)
|
||||
{
|
||||
bot.GetCommandsInterface.Call("im", avatar + "~#~" + message, UUID.Zero, "~#~");
|
||||
return BasicReply("ok");
|
||||
}
|
||||
return BasicReply("Token not accepted");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,11 +293,6 @@ namespace BetterSecondBot.WikiMake
|
|||
api_reports.Add("Core", new KeyValuePair<int, string>(cmd.ApiCommandsCount, "Good"));
|
||||
InterfaceWiki("Core", cmd, true);
|
||||
|
||||
// RLVapi
|
||||
BetterSecondBot.RLV.RLVcontrol RLVapi = new BetterSecondBot.RLV.RLVcontrol(null);
|
||||
api_reports.Add("RLVapi", new KeyValuePair<int, string>(RLVapi.ApiCommandsCount, "Limited"));
|
||||
InterfaceWiki("RLVapi", RLVapi, true);
|
||||
|
||||
// HTTP
|
||||
HTTPWiki();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
using OpenMetaverse;
|
||||
|
||||
namespace BetterSecondBot.Commands.Animation
|
||||
{
|
||||
public class PlayGesture : CoreCommand_1arg
|
||||
{
|
||||
public override string[] ArgTypes { get { return new[] { "UUID" }; } }
|
||||
public override string[] ArgHints { get { return new[] { "The UUID of the gesture to play" }; } }
|
||||
public override string Helpfile { get { return "Triggers a gesture [once]"; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (base.CallFunction(args) == true)
|
||||
{
|
||||
if (UUID.TryParse(args[0], out UUID gesture) == true)
|
||||
{
|
||||
InventoryItem itm = bot.GetClient.Inventory.FetchItem(gesture, bot.GetClient.Self.AgentID, (3 * 1000));
|
||||
bot.GetClient.Self.PlayGesture(itm.AssetUUID);
|
||||
return true;
|
||||
}
|
||||
return Failed("Invaild gesture UUID for arg 1");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
using OpenMetaverse;
|
||||
|
||||
namespace BetterSecondBot.Commands.Animation
|
||||
{
|
||||
public class AddToAllowAnimations : CoreCommand_1arg
|
||||
{
|
||||
public override string[] ArgTypes { get { return new[] { "Avatar" }; } }
|
||||
public override string[] ArgHints { get { return new[] { "Avatar UUID or Firstname Lastname" }; } }
|
||||
public override string Helpfile { get { return "Toggles if animation requests from this avatar (used for remote poseballs) are accepted<br/>Case sensitive also requires Lastname"; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if(base.CallFunction(args) == true)
|
||||
{
|
||||
if(UUID.TryParse(args[0],out UUID avatar) == true)
|
||||
{
|
||||
if(bot.Accept_action_from("animation",avatar) == false)
|
||||
{
|
||||
bot.Add_action_from("animation", avatar);
|
||||
InfoBlob = "Granted perm animation";
|
||||
}
|
||||
else
|
||||
{
|
||||
bot.Remove_action_from("animation", avatar,true);
|
||||
InfoBlob = "Removed perm animation";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return Failed("Invaild avatar for arg 1");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
namespace BetterSecondBot.Commands.Animation
|
||||
{
|
||||
public class ResetAnimations : CoreCommand
|
||||
{
|
||||
public override string Helpfile { get { return "Resets the animation stack for the bot"; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
bot.ResetAnimations();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using OpenMetaverse;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BetterSecondBot.Commands.Avatars
|
||||
{
|
||||
class RoleCreate : CoreCommand_SmartReply_1arg
|
||||
{
|
||||
public override string Helpfile { get { return "Gets a list of avatars near the bot"; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (base.CallFunction(args) == true)
|
||||
{
|
||||
Dictionary<string, string> collection = new Dictionary<string, string>();
|
||||
foreach(Avatar av in bot.GetClient.Network.CurrentSim.ObjectsAvatars.Copy().Values)
|
||||
{
|
||||
Vector3 pos = new Vector3(1, 1, 1);
|
||||
if(bot.GetClient.Network.CurrentSim.AvatarPositions.ContainsKey(av.ID) == true)
|
||||
{
|
||||
pos = bot.GetClient.Network.CurrentSim.AvatarPositions[av.ID];
|
||||
}
|
||||
Dictionary<string, string> entrys = new Dictionary<string, string>();
|
||||
entrys.Add("Username",av.Name);
|
||||
entrys.Add("Pos", pos.X.ToString() + "," + pos.Y.ToString() + "," + pos.Z.ToString());
|
||||
collection.Add(av.ID.ToString(), JsonConvert.SerializeObject(entrys));
|
||||
}
|
||||
return bot.GetCommandsInterface.SmartCommandReply(true, args[0], "ok", CommandName, collection);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using OpenMetaverse;
|
||||
|
||||
|
||||
namespace BetterSecondBot.Commands.Avatars
|
||||
{
|
||||
public class PayAvatar : CoreCommand_2arg
|
||||
{
|
||||
public override string[] ArgTypes { get { return new[] { "Avatar", "Number" }; } }
|
||||
public override string[] ArgHints { get { return new[] { "Avatar [UUID or Firstname Lastname]", "Amount to pay"}; } }
|
||||
public override string Helpfile { get { return "Makes the bot pay a avatar"; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (base.CallFunction(args) == true)
|
||||
{
|
||||
if (bot.GetAllowFunds == true)
|
||||
{
|
||||
if (UUID.TryParse(args[0], out UUID avataruuid) == true)
|
||||
{
|
||||
if (int.TryParse(args[1], out int amount) == true)
|
||||
{
|
||||
if (amount > 0)
|
||||
{
|
||||
bot.GetClient.Self.GiveAvatarMoney(avataruuid, amount);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return Failed("Invaild amount");
|
||||
}
|
||||
return Failed("Invaild avatar UUID");
|
||||
}
|
||||
return Failed("Transfer funds to avatars disabled");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace BetterSecondBot.Commands.Chat
|
||||
{
|
||||
class LocalChatHistory : CoreCommand_SmartReply_1arg
|
||||
{
|
||||
public override string Helpfile { get { return "Gets the last 20 localchat messages the bot has."; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if(base.CallFunction(args) == true)
|
||||
{
|
||||
return bot.GetCommandsInterface.SmartCommandReply(true, args[0], JsonConvert.SerializeObject(bot.getLocalChatHistory()), CommandName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
using OpenMetaverse;
|
||||
using BetterSecondBotShared.Static;
|
||||
|
||||
namespace BetterSecondBot.Commands.Chat
|
||||
{
|
||||
class IM : CoreCommand_2arg
|
||||
{
|
||||
public override string[] ArgTypes { get { return new[] { "Avatar", "Text" }; } }
|
||||
public override string[] ArgHints { get { return new[] { "Avatar [UUID or Firstname Lastname]","Message" }; } }
|
||||
public override string Helpfile { get { return "Makes the bot send a IM to an avatar<br/>Example: IM|||289c3e36-69b3-40c5-9229-0c6a5d230766~#~Hello Mad I am a bot"; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (base.CallFunction(args) == true)
|
||||
{
|
||||
if (UUID.TryParse(args[0], out UUID target_av) == true)
|
||||
{
|
||||
if (helpers.notempty(args[1]) == true)
|
||||
{
|
||||
bot.SendIM(target_av, args[1]);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Failed("Arg 2 is empty");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Failed("Not a vaild UUID");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
using System.Linq;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace BetterSecondBot.Commands.Chat
|
||||
{
|
||||
class Say : CoreCommand_1arg
|
||||
{
|
||||
public override string[] ArgTypes { get { return new[] { "Mixed","Text","Text" }; } }
|
||||
public override string[] ArgHints { get { return new[] { "Message or channel","Message","Chat level" }; } }
|
||||
public override string Helpfile { get { return "Makes the bot talk via chat<br/>Example: say|||Hello<br/>Example: say|||12~#~Goodbye<br/>Example: say|||12~#~Goodbye~#~Shout<br/>Chat levels [Arg 3]:<br/> Whisper<br/> Shout"; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if(base.CallFunction(args) == true)
|
||||
{
|
||||
string message = args[0];
|
||||
int channel = 0;
|
||||
ChatType ChatLevel = ChatType.Normal;
|
||||
if (args.Count() >= 2)
|
||||
{
|
||||
message = args[1];
|
||||
int.TryParse(args[0], out channel);
|
||||
if (args.Count() == 3)
|
||||
{
|
||||
if (args[2] == "Shout")
|
||||
{
|
||||
ChatLevel = ChatType.Shout;
|
||||
}
|
||||
else if (args[2] == "Whisper")
|
||||
{
|
||||
ChatLevel = ChatType.Whisper;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (channel == 0)
|
||||
{
|
||||
bot.AddToLocalChat(bot.GetClient.Self.Name, message);
|
||||
}
|
||||
bot.GetClient.Self.Chat(message, channel, ChatLevel);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
using OpenMetaverse;
|
||||
|
||||
namespace BetterSecondBot.Commands.Dialogs
|
||||
{
|
||||
class DialogRelay : CoreCommand_1arg
|
||||
{
|
||||
public override string[] ArgTypes { get { return new[] { "Smart" }; } }
|
||||
public override string[] ArgHints { get { return new[] { "Channel (Any number),Avatar UUID,Avatar name,HTTPurl<br/>Clear" }; } }
|
||||
public override string Helpfile { get { return "Updates the relay target (you can have 1 of each type)<br/>Clear will disable them all"; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (base.CallFunction(args) == true)
|
||||
{
|
||||
if(args[0] != "Clear")
|
||||
{
|
||||
if (UUID.TryParse(args[0], out UUID avatar) == true)
|
||||
{
|
||||
bot.SetRelayDialogsAvatar(avatar);
|
||||
}
|
||||
else if (args[0].StartsWith("http") == true)
|
||||
{
|
||||
bot.SetRelayDialogsHTTP(args[0]);
|
||||
}
|
||||
else if (int.TryParse(args[0], out int channel) == true)
|
||||
{
|
||||
bot.SetRelayDialogsChannel(channel);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Failed("Not a vaild option");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot.SetRelayDialogsAvatar(UUID.Zero);
|
||||
bot.SetRelayDialogsChannel(0);
|
||||
bot.SetRelayDialogsHTTP("");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
namespace BetterSecondBot.Commands.Dialogs
|
||||
{
|
||||
class DialogResponce : CoreCommand_2arg
|
||||
{
|
||||
public override string[] ArgTypes { get { return new[] { "Number","Text" }; } }
|
||||
public override string[] ArgHints { get { return new[] { "DialogID","Button to click" }; } }
|
||||
public override string Helpfile { get { return "Makes the bot interact with the dialog [ARG 1] with the button [ARG 2]"; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (base.CallFunction(args) == true)
|
||||
{
|
||||
if (int.TryParse(args[0], out int dialogid) == true)
|
||||
{
|
||||
return bot.DialogReply(dialogid, args[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Failed("Invaild dialog id");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
namespace BetterSecondBot.Commands.Dialogs
|
||||
{
|
||||
class DialogTrack : CoreCommand_1arg
|
||||
{
|
||||
public override string[] ArgTypes { get { return new[] { "True|False" }; } }
|
||||
public override string[] ArgHints { get { return new[] { "Status" }; } }
|
||||
public override string Helpfile { get { return "Should the bot track dialogs and send them to the relays setup?"; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (base.CallFunction(args) == true)
|
||||
{
|
||||
if(bool.TryParse(args[0],out bool status) == true)
|
||||
{
|
||||
bot.SetTrackDialogs(status);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using OpenMetaverse;
|
||||
using Newtonsoft.Json;
|
||||
using Discord.WebSocket;
|
||||
using Discord;
|
||||
using Discord.Rest;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetterSecondBot.Commands.DiscordAPI
|
||||
{
|
||||
class Discord_AddRole : CoreCommand_4arg
|
||||
{
|
||||
public override string[] ArgTypes { get { return new[] { "Smart", "Number", "Number", "Number" }; } }
|
||||
public override string[] ArgHints { get { return new[] { "Mixed [Channel|Avatar uuid|Avatar name|http url]", "Discord server id", "Role id", "Member id" }; } }
|
||||
public override string Helpfile { get { return "Adds the selected role to the member"; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (base.CallFunction(args) == true)
|
||||
{
|
||||
if (bot.discordReady() == false)
|
||||
{
|
||||
return bot.GetCommandsInterface.SmartCommandReply(false, args[0], bot.getDiscordWhyFailed(), CommandName);
|
||||
}
|
||||
bool reply = addRoleToMember(args).Result;
|
||||
return bot.GetCommandsInterface.SmartCommandReply(reply, args[0], "see status for state", CommandName);
|
||||
}
|
||||
return bot.GetCommandsInterface.SmartCommandReply(false, args[0], "incorrect args", CommandName);
|
||||
}
|
||||
|
||||
protected async Task<bool> addRoleToMember(string[] args)
|
||||
{
|
||||
DiscordSocketClient Discord = bot.getDiscordClient();
|
||||
if (ulong.TryParse(args[1], out ulong serverid) == true)
|
||||
{
|
||||
if(ulong.TryParse(args[2], out ulong roleid) == true)
|
||||
{
|
||||
if (ulong.TryParse(args[3], out ulong memberid) == true)
|
||||
{
|
||||
SocketGuild server = Discord.GetGuild(serverid);
|
||||
SocketRole role = server.GetRole(roleid);
|
||||
SocketGuildUser user = server.GetUser(memberid);
|
||||
await user.AddRoleAsync(role); // ? Irole seems to accept SocketRole ?
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using OpenMetaverse;
|
||||
using Newtonsoft.Json;
|
||||
using Discord.WebSocket;
|
||||
using Discord;
|
||||
using Discord.Rest;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetterSecondBot.Commands.DiscordAPI
|
||||
{
|
||||
class Discord_BanMember : CoreCommand_3arg
|
||||
{
|
||||
public override string[] ArgTypes { get { return new[] { "Smart", "Number", "Number","Text" }; } }
|
||||
public override string[] ArgHints { get { return new[] { "Mixed [Channel|Avatar uuid|Avatar name|http url]", "Discord server id", "Member id","Optional why message" }; } }
|
||||
public override string Helpfile { get { return "Adds the selected user to the ban list - Disallows rejoining untill they are removed from the list "; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (base.CallFunction(args) == true)
|
||||
{
|
||||
if (bot.discordReady() == false)
|
||||
{
|
||||
return bot.GetCommandsInterface.SmartCommandReply(false, args[0], bot.getDiscordWhyFailed(), CommandName);
|
||||
}
|
||||
bool reply = BanMember(args).Result;
|
||||
return bot.GetCommandsInterface.SmartCommandReply(reply, args[0], "see status for state", CommandName);
|
||||
}
|
||||
return bot.GetCommandsInterface.SmartCommandReply(false, args[0], "incorrect args", CommandName);
|
||||
}
|
||||
|
||||
protected async Task<bool> BanMember(string[] args)
|
||||
{
|
||||
DiscordSocketClient Discord = bot.getDiscordClient();
|
||||
if (ulong.TryParse(args[1], out ulong serverid) == true)
|
||||
{
|
||||
if (ulong.TryParse(args[2], out ulong memberid) == true)
|
||||
{
|
||||
SocketGuild server = Discord.GetGuild(serverid);
|
||||
SocketGuildUser user = server.GetUser(memberid);
|
||||
string why = "Secondbot API ban - see your own logs";
|
||||
if (args.Length == 4)
|
||||
{
|
||||
why = args[3];
|
||||
}
|
||||
await user.BanAsync(7, why);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Blacklist
|
||||
{
|
||||
public class GetBlacklist : RLV_command_1arg
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (base.CallFunction(args) == true)
|
||||
{
|
||||
int channel;
|
||||
string filter = "";
|
||||
if(args.Length == 2)
|
||||
{
|
||||
if(int.TryParse(args[1], out channel) == true)
|
||||
{
|
||||
filter = args[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int.TryParse(args[0], out channel);
|
||||
}
|
||||
if (channel >= 0)
|
||||
{
|
||||
string sendim = "";
|
||||
string recvim = "";
|
||||
if (filter == "")
|
||||
{
|
||||
sendim = String.Join('|', bot.Getblacklist_sendim);
|
||||
recvim = String.Join('|', bot.Getblacklist_recvim);
|
||||
}
|
||||
else
|
||||
{
|
||||
string addon = "";
|
||||
foreach (string a in bot.Getblacklist_sendim)
|
||||
{
|
||||
if (a.Contains(filter) == true)
|
||||
{
|
||||
sendim = "" + sendim + "" + addon + "" + a + "";
|
||||
addon = "|";
|
||||
}
|
||||
}
|
||||
addon = "";
|
||||
foreach (string a in bot.Getblacklist_recvim)
|
||||
{
|
||||
if (a.Contains(filter) == true)
|
||||
{
|
||||
recvim = "" + recvim + "" + addon + "" + a + "";
|
||||
addon = "|";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sendim == "")
|
||||
{
|
||||
sendim = "#";
|
||||
}
|
||||
if (recvim == "")
|
||||
{
|
||||
recvim = "#";
|
||||
}
|
||||
bot.GetClient.Self.Chat("" + sendim + "," + recvim + "", channel, OpenMetaverse.ChatType.Normal);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Failed("Invaild channel given");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Blacklist
|
||||
{
|
||||
public class VersionNumBL : RLV_command_1arg
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (base.CallFunction(args) == true)
|
||||
{
|
||||
_ = int.TryParse(args[0], out int channel);
|
||||
if (channel >= 0)
|
||||
{
|
||||
string sendim = String.Join('|', bot.Getblacklist_sendim);
|
||||
string recvim = String.Join('|', bot.Getblacklist_recvim);
|
||||
if (sendim == "") { sendim = "#"; }
|
||||
if (recvim == "") { recvim = "#"; }
|
||||
bot.GetClient.Self.Chat("209000," + sendim + "," + recvim + "", channel, OpenMetaverse.ChatType.Normal);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Failed("Invaild channel given");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class CamAvDist : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class CamDistMax : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class CamDistMin : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class CamDrawAlphaMax : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class CamDrawAlphaMin : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class CamDrawColor : RLV_UUID_flag_4arg_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class CamDrawMax : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class CamDrawMin : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class CamTextures : RLV_UUID_flag_optional_arg_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class CamUnlock : RLV_UUID_flag_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class CamZoomMax : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class CamZoomMin : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class GetCam_AvDistMax : RLV_UUID_flag_get
|
||||
{
|
||||
public override string LookupFlag { get { return "camavdistmax"; } }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class GetCam_AvDistMin : RLV_UUID_flag_get
|
||||
{
|
||||
public override string LookupFlag { get { return "camavdistmin"; } }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class GetCam_Fov : RLV_UUID_flag_get
|
||||
{
|
||||
public override string LookupFlag { get { return "camfov"; } }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class GetCam_FovMax : RLV_UUID_flag_get
|
||||
{
|
||||
public override string LookupFlag { get { return "camfovmax"; } }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class GetCam_FovMin : RLV_UUID_flag_get
|
||||
{
|
||||
public override string LookupFlag { get { return "camfovmin"; } }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class GetCam_ZoomMin : RLV_UUID_flag_get
|
||||
{
|
||||
public override string LookupFlag { get { return "camzoommin"; } }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class SetCam_AvDistMax : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
public override string SetFlagName { get { return "camavdistmax"; } }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class SetCam_AvDistMin : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
public override string SetFlagName { get { return "camavdistmin"; } }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class SetCam_Fov : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
public override string SetFlagName { get { return "camfov"; } }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class SetCam_FovMax : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
public override string SetFlagName { get { return "camfovmax"; } }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class SetCam_FovMin : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
public override string SetFlagName { get { return "camfovmin"; } }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class SetCam_Textures : RLV_UUID_flag_optional_arg_yn
|
||||
{
|
||||
public override string SetFlagName { get { return "camtextures"; } }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Camera
|
||||
{
|
||||
public class SetCam_Unlock : RLV_UUID_flag_yn
|
||||
{
|
||||
public override string SetFlagName { get { return "camunlock"; } }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Chat
|
||||
{
|
||||
public class ChatNormal : RLV_UUID_flag_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Chat
|
||||
{
|
||||
public class ChatShout : RLV_UUID_flag_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Chat
|
||||
{
|
||||
public class ChatWhisper : RLV_UUID_flag_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace BetterSecondBot.RLV.Chat
|
||||
{
|
||||
public class RecvChat : RLV_command_1arg
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (args.Length == 1)
|
||||
{
|
||||
if (args[0] == "y")
|
||||
{
|
||||
bot.SetLock("recvchat_channel_zero_lock", false);
|
||||
return true;
|
||||
}
|
||||
else if (args[0] == "n")
|
||||
{
|
||||
bot.SetLock("recvchat_channel_zero_lock", true);
|
||||
return true;
|
||||
}
|
||||
return Failed("y/n only");
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
if (UUID.TryParse(args[0], out UUID rec_uuid) == true)
|
||||
{
|
||||
return SetFlag(args[1], "set", rec_uuid);
|
||||
}
|
||||
return Failed("Unable to process target UUID");
|
||||
}
|
||||
return Failed("Unsupported number of args");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Chat
|
||||
{
|
||||
public class RecvChat_Sec : RLV_UUID_flag_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Chat
|
||||
{
|
||||
public class RecvChatFrom : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Chat
|
||||
{
|
||||
public class RedirChat : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Chat
|
||||
{
|
||||
public class SendChat : RLV_UUID_flag_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Chat
|
||||
{
|
||||
public class SendGesture : RLV_UUID_flag_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Emotes
|
||||
{
|
||||
public class Emote : RLV_UUID_flag_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace BetterSecondBot.RLV.Emotes
|
||||
{
|
||||
public class RecvEmote : RLV_UUID_flag_optional_arg_yn
|
||||
{
|
||||
public override bool AsExceptionRule { get { return true; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (args.Length == 1)
|
||||
{
|
||||
if (args[0] == "y")
|
||||
{
|
||||
bot.SetLock("recvemote_lock", false);
|
||||
return true;
|
||||
}
|
||||
else if (args[0] == "n")
|
||||
{
|
||||
bot.SetLock("recvemote_lock", true);
|
||||
return true;
|
||||
}
|
||||
return Failed("y/n only");
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
if (UUID.TryParse(args[0], out UUID rec_uuid) == true)
|
||||
{
|
||||
return SetFlag(args[1], "set", rec_uuid);
|
||||
}
|
||||
return Failed("Unable to process target UUID");
|
||||
}
|
||||
return Failed("Unsupported number of args");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Emotes
|
||||
{
|
||||
public class RecvEmote_Sec : RLV_UUID_flag_yn
|
||||
{
|
||||
public override string SetFlagName { get { return "recvemote"; } }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Emotes
|
||||
{
|
||||
public class RedirEmote : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
public override string SetFlagName { get { return CommandName; } }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.InstantMessages
|
||||
{
|
||||
public class SendIm : RLV_command_1arg
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (args.Length == 1)
|
||||
{
|
||||
if (args[0] == "y")
|
||||
{
|
||||
bot.SetLock("sendim_lock", false);
|
||||
return true;
|
||||
}
|
||||
else if (args[0] == "n")
|
||||
{
|
||||
bot.SetLock("sendim_lock", true);
|
||||
return true;
|
||||
}
|
||||
return Failed("y/n only");
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
if (UUID.TryParse(args[0], out UUID rec_uuid) == true)
|
||||
{
|
||||
return SetFlag(args[1], "set", rec_uuid);
|
||||
}
|
||||
return Failed("Unable to process target UUID");
|
||||
}
|
||||
return Failed("Unsupported number of args");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.InstantMessages
|
||||
{
|
||||
public class SendIm_Sec : RLV_command_1arg
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (args[0] == "y") { bot.SetLock("sendim_lock", false); }
|
||||
else if (args[0] == "n") { bot.SetLock("sendim_lock", true); }
|
||||
else { return Failed("y/n only"); }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace BetterSecondBot.RLV.Miscellaneous
|
||||
{
|
||||
public class Clear : RLV_command
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
bot.Clearrule(false, caller_uuid);
|
||||
bot.Clearrule(true, caller_uuid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace BetterSecondBot.RLV.Miscellaneous
|
||||
{
|
||||
public class GetStatus : RLV_command_1arg
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
string part = "#";
|
||||
string split = "/";
|
||||
int channel = -1;
|
||||
if (args.Length == 1)
|
||||
{
|
||||
_ = int.TryParse(args[0], out channel);
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
part = args[0];
|
||||
_ = int.TryParse(args[1], out channel);
|
||||
}
|
||||
else if (args.Length == 3)
|
||||
{
|
||||
part = args[0];
|
||||
split = args[1];
|
||||
_ = int.TryParse(args[2], out channel);
|
||||
}
|
||||
if (channel > -1)
|
||||
{
|
||||
string reply = "";
|
||||
string addon = "";
|
||||
if (bot.Getuuid_rules.ContainsKey(caller_uuid) == true)
|
||||
{
|
||||
foreach (string rule in bot.Getuuid_rules[caller_uuid].Keys)
|
||||
{
|
||||
if ((part == "#") || (rule.Contains(part) == true))
|
||||
{
|
||||
reply = "" + reply + "" + addon + "" + rule + "";
|
||||
addon = split;
|
||||
}
|
||||
}
|
||||
}
|
||||
bot.GetClient.Self.Chat(reply, channel, ChatType.Normal);
|
||||
return true;
|
||||
}
|
||||
return Failed("Invaild channel given");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace BetterSecondBot.RLV.Miscellaneous
|
||||
{
|
||||
public class GetStatusAll : RLV_command_1arg
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (base.CallFunction(args) == true)
|
||||
{
|
||||
string part = "#";
|
||||
string split = "/";
|
||||
int channel = -1;
|
||||
if (args.Length == 1)
|
||||
{
|
||||
int.TryParse(args[0], out channel);
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
part = args[0];
|
||||
int.TryParse(args[1], out channel);
|
||||
}
|
||||
else if (args.Length == 3)
|
||||
{
|
||||
part = args[0];
|
||||
split = args[1];
|
||||
int.TryParse(args[2], out channel);
|
||||
}
|
||||
if (channel > -1)
|
||||
{
|
||||
string reply = "";
|
||||
string addon = "";
|
||||
foreach (UUID a in bot.Getuuid_rules.Keys)
|
||||
{
|
||||
foreach (string rule in bot.Getuuid_rules[a].Keys)
|
||||
{
|
||||
if ((part == "#") || (rule.Contains(part) == true))
|
||||
{
|
||||
reply = "" + reply + "" + addon + "" + rule + "";
|
||||
addon = split;
|
||||
}
|
||||
}
|
||||
}
|
||||
bot.GetClient.Self.Chat(reply, channel, ChatType.Normal);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Failed("Invaild channel given");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Miscellaneous
|
||||
{
|
||||
public class Notify : RLV_command_2arg
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
_ = int.TryParse(args[0], out int channel);
|
||||
if (channel >= 0)
|
||||
{
|
||||
string word = "#";
|
||||
string action;
|
||||
if (args.Length == 3)
|
||||
{
|
||||
word = args[1];
|
||||
action = args[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
action = args[1];
|
||||
}
|
||||
if ((action == "add") || (action == "n"))
|
||||
{
|
||||
bot.NotifyUpdate(true, word, channel);
|
||||
return true;
|
||||
}
|
||||
else if ((action == "rem") || (action == "y"))
|
||||
{
|
||||
bot.NotifyUpdate(false, word, channel);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Failed("unknown action add/rem only! Action:" + action + " Channel:" + channel.ToString() + " Word: " + word + "");
|
||||
}
|
||||
}
|
||||
return Failed("Invaild channel given");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace BetterSecondBot.RLV.Miscellaneous
|
||||
{
|
||||
public class Permissive : RLV_command_1arg
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
string action = args[0];
|
||||
if ((action == "y") || (action == "n"))
|
||||
{
|
||||
if (action == "n")
|
||||
{
|
||||
bot.SetPermissiveMode(caller_uuid, true);
|
||||
}
|
||||
else if (action == "y")
|
||||
{
|
||||
bot.SetPermissiveMode(caller_uuid, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return Failed("Permissive requires y/n!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Movement
|
||||
{
|
||||
public class AdjustHeight : RLV_command_3arg
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
int distance_pelvis_to_foot_in_meters = 0;
|
||||
double factor = 0;
|
||||
double offset = 0;
|
||||
if (args[^1] == "force")
|
||||
{
|
||||
if(args.Length == 3)
|
||||
{
|
||||
int.TryParse(args[0], out distance_pelvis_to_foot_in_meters);
|
||||
double.TryParse(args[1], out factor);
|
||||
}
|
||||
else if (args.Length == 4)
|
||||
{
|
||||
int.TryParse(args[0], out distance_pelvis_to_foot_in_meters);
|
||||
double.TryParse(args[1], out factor);
|
||||
double.TryParse(args[2], out offset);
|
||||
}
|
||||
Double hh = distance_pelvis_to_foot_in_meters * factor;
|
||||
hh += offset;
|
||||
if (hh > 2.0)
|
||||
{
|
||||
hh = 2.0;
|
||||
}
|
||||
else if (hh < -2.0)
|
||||
{
|
||||
hh = -2.0;
|
||||
}
|
||||
bot.GetClient.Self.SetHoverHeight(hh);
|
||||
return true;
|
||||
}
|
||||
return Failed("Required magic word force missing");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Movement
|
||||
{
|
||||
public class AlwaysRun : RLV_UUID_flag_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Movement
|
||||
{
|
||||
public class Fly : RLV_UUID_flag_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace BetterSecondBot.RLV.Movement
|
||||
{
|
||||
public class SetRot : RLV_command_2arg
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (base.CallFunction(args) == true)
|
||||
{
|
||||
if (args[1] == "force")
|
||||
{
|
||||
return bot.GetCommandsInterface.Call("rotateto", args[0], UUID.Zero);
|
||||
}
|
||||
return Failed("magic word force is required [dont ask me]");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Movement
|
||||
{
|
||||
public class TempRun : RLV_UUID_flag_yn
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.PrivateChannels
|
||||
{
|
||||
public class SendChannel : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.PrivateChannels
|
||||
{
|
||||
public class SendChannel_Except : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
public override string SetFlagName { get { return "sendchannel"; } }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.PrivateChannels
|
||||
{
|
||||
public class SendChannel_Sec : RLV_UUID_flag_arg_yn
|
||||
{
|
||||
public override string SetFlagName { get { return "sendchannel"; } }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,230 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using OpenMetaverse;
|
||||
using BetterSecondBot.bottypes;
|
||||
using BetterSecondBotShared.API;
|
||||
using BetterSecondBotShared.logs;
|
||||
|
||||
namespace BetterSecondBot.RLV
|
||||
{
|
||||
public class RLVcontrol : API_supported_interface
|
||||
{
|
||||
protected RLVbot bot;
|
||||
protected UUID last_caller_uuid = UUID.Zero;
|
||||
protected string last_caller_name = "";
|
||||
|
||||
public void SetCallerDetails(UUID callerUUID, string callerName)
|
||||
{
|
||||
last_caller_name = callerName;
|
||||
last_caller_uuid = callerUUID;
|
||||
}
|
||||
|
||||
public RLVcontrol(RLVbot linktobot)
|
||||
{
|
||||
bot = linktobot;
|
||||
API_type = typeof(RLV_command);
|
||||
LoadCommandsList();
|
||||
}
|
||||
|
||||
protected List<string> suppress_warning = new List<string>();
|
||||
public bool Call(string command, string[] args)
|
||||
{
|
||||
command = command.ToLowerInvariant();
|
||||
RLV_command cmd = (RLV_command)GetCommand(command);
|
||||
if (cmd != null)
|
||||
{
|
||||
if (args.Length >= cmd.Min_Required_args)
|
||||
{
|
||||
cmd.Setup(bot, last_caller_uuid, last_caller_name);
|
||||
return cmd.CallFunction(args);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFormater.Warn("[RLVapi/Failed] " + command + ": Incorrect number of args");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(suppress_warning.Contains(command) == false)
|
||||
{
|
||||
suppress_warning.Add(command);
|
||||
LogFormater.Warn("[RLVapi/Failed] " + command + ": I have no fucking idea what you are talking about");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public abstract class RLV_command_1arg : RLV_command
|
||||
{
|
||||
public override int Min_Required_args { get { return 1; } }
|
||||
}
|
||||
public abstract class RLV_command_2arg : RLV_command
|
||||
{
|
||||
public override int Min_Required_args { get { return 2; } }
|
||||
}
|
||||
public abstract class RLV_command_3arg : RLV_command
|
||||
{
|
||||
public override int Min_Required_args { get { return 3; } }
|
||||
}
|
||||
public abstract class RLV_command_4arg : RLV_command
|
||||
{
|
||||
public override int Min_Required_args { get { return 4; } }
|
||||
}
|
||||
public abstract class RLV_command : API_interface
|
||||
{
|
||||
public override string Helpfile { get { return "[Class helpfile] an RLV_command."; } }
|
||||
public virtual string SetFlagName { get { return CommandName.ToLowerInvariant(); } }
|
||||
protected RLVbot bot;
|
||||
protected UUID caller_uuid = UUID.Zero;
|
||||
protected string caller_name = "";
|
||||
|
||||
public virtual bool AsExceptionRule { get { return false; } }
|
||||
|
||||
|
||||
public void Setup(RLVbot setBot, UUID callerUUID, string callerName)
|
||||
{
|
||||
bot = setBot;
|
||||
caller_name = callerName;
|
||||
caller_uuid = callerUUID;
|
||||
}
|
||||
|
||||
public virtual bool CallFunction(string[] args)
|
||||
{
|
||||
return Failed("Function not overridden");
|
||||
}
|
||||
|
||||
public bool Failed(string why_failed)
|
||||
{
|
||||
LogFormater.Warn("[RLVapi/Failed] " + CommandName + ": " + why_failed);
|
||||
return false;
|
||||
}
|
||||
|
||||
protected bool SetFlag(string signal,string arg)
|
||||
{
|
||||
return SetFlag(signal, arg, caller_uuid);
|
||||
}
|
||||
protected bool SetFlag(string signal, string arg,UUID caller)
|
||||
{
|
||||
if ((signal == "y") || (signal == "rem"))
|
||||
{
|
||||
return bot.RemoveRule(AsExceptionRule, SetFlagName, caller);
|
||||
}
|
||||
else if ((signal == "n") || (signal == "add"))
|
||||
{
|
||||
return bot.UpdateRule(AsExceptionRule, SetFlagName, arg, caller);
|
||||
}
|
||||
return Failed("[RLV/Debug] arg only accepts y/n or add/rem for control signaling [Sig: " + signal+" Arg: "+arg+"]");
|
||||
}
|
||||
}
|
||||
public abstract class RLV_1arg_force : RLV_command_1arg
|
||||
{
|
||||
public override string Helpfile { get { return "[Class helpfile] Requires you send =force at the end of the command..."; } }
|
||||
public override string[] ArgTypes { get { return new[] { "TEXT" }; } }
|
||||
public override string[] ArgHints { get { return new[] { "The word force"}; } }
|
||||
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (args.Length > 0)
|
||||
{
|
||||
if (args[0] == "force")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return Failed("Magic word force is missing");
|
||||
}
|
||||
return Failed("[RLV/WARN] RLV_1arg_force invaild number of args");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract class RLV_UUID_flag_4arg_yn : RLV_UUID_flag_optional_arg_yn
|
||||
{
|
||||
public override int Min_Required_args { get { return 4; } }
|
||||
public override string Helpfile { get { return "[Class helpfile] RLV / 4arg"; } }
|
||||
public override string[] ArgTypes { get { return new[] { "Unknown", "Unknown", "Unknown", "Unknown" }; } }
|
||||
public override string[] ArgHints { get { return new[] { "Unknown", "Unknown", "Unknown", "Unknown" }; } }
|
||||
}
|
||||
|
||||
public abstract class RLV_UUID_flag_optional_arg_yn : RLV_command_1arg
|
||||
{
|
||||
public override string Helpfile { get { return "[Class helpfile] RLV / UUID_flag_optional_arg_yn"; } }
|
||||
public override string[] ArgTypes { get { return new[] { "Unknown", "Unknown"}; } }
|
||||
public override string[] ArgHints { get { return new[] { "Unknown", "Unknown" }; } }
|
||||
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (args.Length == 2)
|
||||
{
|
||||
return SetFlag(args[^1], args[0]);
|
||||
}
|
||||
else if (args.Length > 0)
|
||||
{
|
||||
return SetFlag(args[^1], "set");
|
||||
}
|
||||
return Failed("[RLV/WARN] RLV_UUID_flag_optional_arg_yn invaild number of args");
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class RLV_UUID_flag_yn : RLV_command_1arg
|
||||
{
|
||||
public override string Helpfile { get { return "[Class helpfile] RLV / UUID_flag_yn "; } }
|
||||
public override string[] ArgTypes { get { return new[] { "Unknown", "Unknown" }; } }
|
||||
public override string[] ArgHints { get { return new[] { "Unknown", "Unknown" }; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (args.Length >= 1)
|
||||
{
|
||||
return SetFlag(args[0], "set");
|
||||
}
|
||||
return Failed("[RLV/WARN] RLV_UUID_flag_yn invaild number of args");
|
||||
}
|
||||
}
|
||||
public abstract class RLV_UUID_flag_get : RLV_command_1arg
|
||||
{
|
||||
public abstract string LookupFlag { get; }
|
||||
public override string Helpfile { get { return "[Class helpfile]<br/>Gets the flag value "+LookupFlag+" and returns it on channel [ARG 1]"; } }
|
||||
public override string[] ArgTypes { get { return new[] { "Number"}; } }
|
||||
public override string[] ArgHints { get { return new[] { "Channel" }; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (args.Length == 1)
|
||||
{
|
||||
_ = int.TryParse(args[0], out int channel);
|
||||
if (channel >= 0)
|
||||
{
|
||||
if (bot.Getuuid_rules.ContainsKey(caller_uuid) == true)
|
||||
{
|
||||
if (bot.Getuuid_rules[caller_uuid].ContainsKey(LookupFlag) == true)
|
||||
{
|
||||
bot.GetClient.Self.Chat(bot.Getuuid_rules[caller_uuid][LookupFlag], channel, ChatType.Normal);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Failed("Channel number not vaild");
|
||||
}
|
||||
}
|
||||
return Failed("[RLV/WARN] RLV_UUID_flag_get invaild number of args");
|
||||
}
|
||||
}
|
||||
public abstract class RLV_UUID_flag_arg_yn : RLV_command_2arg
|
||||
{
|
||||
public override string Helpfile { get { return "[Class helpfile]<br/> RLV / UUID_flag_arg_yn<br/>When clearing please set [ARG 1] to Anything<br/>Flags are tracked per object"; } }
|
||||
public override string[] ArgTypes { get { return new[] { "Mixed", "Flag" }; } }
|
||||
public override string[] ArgHints { get { return new[] { "The arg value you are setting", "[Y/N] or [Rem/Add]" }; } }
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (args.Length == 2)
|
||||
{
|
||||
return SetFlag(args[1], args[0]);
|
||||
}
|
||||
return Failed("[RLV/WARN] RLV_UUID_flag_arg_yn invaild number of args");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Sitting
|
||||
{
|
||||
class GetSitId : RLV_command_1arg
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
_ = int.TryParse(args[0], out int channel);
|
||||
if (channel > -1)
|
||||
{
|
||||
if(bot.GetClient.Self.SittingOn > 0)
|
||||
{
|
||||
if(bot.GetClient.Network.CurrentSim.ObjectsPrimitives.ContainsKey(bot.GetClient.Self.SittingOn))
|
||||
{
|
||||
Primitive obj = bot.GetClient.Network.CurrentSim.ObjectsPrimitives[bot.GetClient.Self.SittingOn];
|
||||
|
||||
bot.GetClient.Self.Chat(obj.ID.ToString(), channel, OpenMetaverse.ChatType.Normal);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
bot.GetClient.Self.Chat(UUID.Zero.ToString(), channel, OpenMetaverse.ChatType.Normal);
|
||||
return true;
|
||||
}
|
||||
return Failed("Invaild channel given");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Sitting
|
||||
{
|
||||
public class Sit : RLV_command_1arg
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (args.Length == 1)
|
||||
{
|
||||
return SetFlag(args[0], "set");
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
if (args[1] == "force")
|
||||
{
|
||||
return bot.GetCommandsInterface.Call("BotSit", args[0], UUID.Zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Failed("Magic keyword force missing.");
|
||||
}
|
||||
}
|
||||
return Failed("Badly formatted command.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Sitting
|
||||
{
|
||||
public class UnSit : RLV_command_1arg
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
if (args[0] == "force")
|
||||
{
|
||||
return bot.GetCommandsInterface.Call("stand", "", UUID.Zero);
|
||||
}
|
||||
else if ((args[0] == "y") || (args[0] == "n"))
|
||||
{
|
||||
return SetFlag(args[0], "set");
|
||||
}
|
||||
return Failed("Magic keyword force missing.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Version
|
||||
{
|
||||
public class Version : RLV_command
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
int channel = 0;
|
||||
if (args.Length == 1)
|
||||
{
|
||||
_ = int.TryParse(args[0], out channel);
|
||||
}
|
||||
if (channel >= 0)
|
||||
{
|
||||
bot.GetClient.Self.Chat("RestrainedLife BOT (RLVa 2.9)", channel, OpenMetaverse.ChatType.Normal);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Failed("Invaild channel given");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Version
|
||||
{
|
||||
public class VersionNew : RLV_command
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
int channel = 0;
|
||||
if (args.Length == 1)
|
||||
{
|
||||
_ = int.TryParse(args[0], out channel);
|
||||
}
|
||||
if (channel >= 0)
|
||||
{
|
||||
bot.GetClient.Self.Chat("RestrainedLove BOT (RLVa 2.9)", channel, OpenMetaverse.ChatType.Normal);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Failed("Invaild channel given");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterSecondBot.RLV.Version
|
||||
{
|
||||
public class VersionNum : RLV_command
|
||||
{
|
||||
public override bool CallFunction(string[] args)
|
||||
{
|
||||
int channel = 0;
|
||||
if (args.Length == 1)
|
||||
{
|
||||
_ = int.TryParse(args[0], out channel);
|
||||
}
|
||||
if (channel >= 0)
|
||||
{
|
||||
bot.GetClient.Self.Chat("209000", channel, OpenMetaverse.ChatType.Normal);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Failed("Invaild channel given");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -287,38 +287,6 @@ namespace BetterSecondBot.bottypes
|
|||
}
|
||||
}
|
||||
|
||||
protected string httpLookupKey(string avatar_name)
|
||||
{
|
||||
if (myconfig.Name2Key_Enable == true)
|
||||
{
|
||||
var client = new RestClient(myconfig.Name2Key_Url);
|
||||
var request = new RestRequest("name2key/" + avatar_name + "/" + myconfig.Name2Key_Key + "", Method.GET);
|
||||
client.Timeout = 3000; // ? does this even do anything
|
||||
request.Timeout = 3000;
|
||||
IRestResponse endpoint_checks = client.Get(request);
|
||||
if (endpoint_checks.StatusCode == System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
namekeyservicereply server_reply = JsonConvert.DeserializeObject<namekeyservicereply>(endpoint_checks.Content);
|
||||
if (server_reply.status == true)
|
||||
{
|
||||
if (server_reply.found == true)
|
||||
{
|
||||
AddAvatarToDB((UUID)server_reply.uuid, server_reply.name);
|
||||
return server_reply.uuid;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
protected string FindAvatarUUIDInStorage(string avatar_name)
|
||||
{
|
||||
if (AvatarStorageLastUsed.ContainsKey(avatar_name) == true)
|
||||
|
|
@ -355,11 +323,6 @@ namespace BetterSecondBot.bottypes
|
|||
{
|
||||
return uuid;
|
||||
}
|
||||
uuid = httpLookupKey(avatar_name);
|
||||
if (uuid != "")
|
||||
{
|
||||
return uuid;
|
||||
}
|
||||
if (PendingAvatarFinds_vianame.ContainsKey(avatar_name) == false)
|
||||
{
|
||||
PendingAvatarFinds_vianame.Add(avatar_name, new KeyValuePair<long, int>(helpers.UnixTimeNow(), 0));
|
||||
|
|
@ -383,38 +346,6 @@ namespace BetterSecondBot.bottypes
|
|||
return "";
|
||||
}
|
||||
|
||||
protected string httpLookupName(UUID avatar_uuid)
|
||||
{
|
||||
if (myconfig.Name2Key_Enable == true)
|
||||
{
|
||||
var client = new RestClient(myconfig.Name2Key_Url);
|
||||
var request = new RestRequest("key2name/" + avatar_uuid.ToString() + "/" + myconfig.Name2Key_Key + "", Method.GET);
|
||||
client.Timeout = 3000; // ? does this even do anything
|
||||
request.Timeout = 3000;
|
||||
IRestResponse endpoint_checks = client.Get(request);
|
||||
if (endpoint_checks.StatusCode == System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
namekeyservicereply server_reply = JsonConvert.DeserializeObject<namekeyservicereply>(endpoint_checks.Content);
|
||||
if (server_reply.status == true)
|
||||
{
|
||||
if (server_reply.found == true)
|
||||
{
|
||||
AddAvatarToDB((UUID)server_reply.uuid, server_reply.name);
|
||||
return server_reply.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public string FindAvatarKey2Name(UUID avatar_uuid)
|
||||
{
|
||||
|
|
@ -423,11 +354,6 @@ namespace BetterSecondBot.bottypes
|
|||
{
|
||||
return avatar_name;
|
||||
}
|
||||
avatar_name = httpLookupName(avatar_uuid);
|
||||
if (avatar_name != "")
|
||||
{
|
||||
return avatar_name;
|
||||
}
|
||||
if (PendingAvatarFinds_viauuid.ContainsKey(avatar_uuid) == false)
|
||||
{
|
||||
PendingAvatarFinds_viauuid.Add(avatar_uuid, new KeyValuePair<long, int>(helpers.UnixTimeNow(), 0));
|
||||
|
|
@ -442,16 +368,6 @@ namespace BetterSecondBot.bottypes
|
|||
}
|
||||
}
|
||||
|
||||
public class namekeyservicereply
|
||||
{
|
||||
public string lookingfor { get; set; }
|
||||
public string uuid { get; set; }
|
||||
public string name { get; set; }
|
||||
public bool found { get; set; }
|
||||
public bool status { get; set; }
|
||||
public string message { get; set; }
|
||||
}
|
||||
|
||||
public class friendreplyobject
|
||||
{
|
||||
public string name;
|
||||
|
|
|
|||
|
|
@ -1,298 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BetterSecondBotShared.Json;
|
||||
using OpenMetaverse;
|
||||
using BetterSecondBotShared.logs;
|
||||
|
||||
namespace BetterSecondBot.bottypes
|
||||
{
|
||||
public abstract class RLVbot : RLVbotHelper
|
||||
{
|
||||
// normal bot stuff
|
||||
protected RLV.RLVcontrol RLVinterface;
|
||||
public RLV.RLVcontrol GetRLVinterface { get { return RLVinterface; } }
|
||||
|
||||
public override void Setup(JsonConfig config, string Version)
|
||||
{
|
||||
base.Setup(config, Version);
|
||||
if (reconnect == false)
|
||||
{
|
||||
if (myconfig.Setting_AllowRLV == true)
|
||||
{
|
||||
Info("RLV: Enabled");
|
||||
RLVinterface = new RLV.RLVcontrol(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ChatInputHandler(object sender, ChatEventArgs e)
|
||||
{
|
||||
base.ChatInputHandler(sender, e);
|
||||
if (e.Type == ChatType.OwnerSay)
|
||||
{
|
||||
if (myconfig.Setting_AllowRLV == true)
|
||||
{
|
||||
if (e.Message.StartsWith("@") == true)
|
||||
{
|
||||
string message_text = e.Message.Substring(1);
|
||||
bool permissive_allow = true;
|
||||
if (permissive_allow == true)
|
||||
{
|
||||
string[] requested_commands = message_text.Split(',');
|
||||
foreach (string R in requested_commands)
|
||||
{
|
||||
List<string> args = new List<string>();
|
||||
string command = "";
|
||||
string[] build = R.Split('=');
|
||||
string[] build2 = build[0].Split(':');
|
||||
if (build2.Length == 2)
|
||||
{
|
||||
string[] build3 = build2[1].Split(';');
|
||||
foreach (string build_arg in build3)
|
||||
{
|
||||
args.Add(build_arg);
|
||||
}
|
||||
}
|
||||
command = build2[0];
|
||||
if (build.Length == 2)
|
||||
{
|
||||
args.Add(build[1]);
|
||||
}
|
||||
if (blacklist_recvim.Contains(command) == false)
|
||||
{
|
||||
if (Notify.ContainsKey("#") == true)
|
||||
{
|
||||
foreach (int channel in Notify["#"])
|
||||
{
|
||||
Client.Self.Chat("/" + message_text, channel, ChatType.Normal);
|
||||
}
|
||||
}
|
||||
if (Notify.ContainsKey(command) == true)
|
||||
{
|
||||
foreach (int channel in Notify[command])
|
||||
{
|
||||
Client.Self.Chat("/" + message_text, channel, ChatType.Normal);
|
||||
}
|
||||
}
|
||||
RLVinterface.SetCallerDetails(e.SourceID, e.FromName);
|
||||
RLVinterface.Call(command, args.ToArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug("RLV API -> blacklisted [" + command + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class RLVbotHelper : AwaitReplyEventBot
|
||||
{
|
||||
#region PermissiveMode
|
||||
// permissive
|
||||
protected bool permissive_mode = true;
|
||||
protected UUID permissive_mode_set_by = UUID.Zero;
|
||||
public UUID Getpermissive_mode_set_by { get { return permissive_mode_set_by; } }
|
||||
|
||||
public void SetPermissiveMode(UUID caller)
|
||||
{
|
||||
SetPermissiveMode(caller, false);
|
||||
}
|
||||
public void SetPermissiveMode(UUID caller, bool status)
|
||||
{
|
||||
bool allow = true;
|
||||
if((permissive_mode == false) && (caller != permissive_mode_set_by))
|
||||
{
|
||||
allow = false;
|
||||
}
|
||||
if(allow == true)
|
||||
{
|
||||
permissive_mode = status;
|
||||
if (status == false)
|
||||
{
|
||||
permissive_mode_set_by = UUID.Zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
permissive_mode_set_by = caller;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region blacklist
|
||||
// Blacklist
|
||||
protected List<string> blacklist_sendim = new List<string>();
|
||||
protected List<string> blacklist_recvim = new List<string>();
|
||||
public List<string> Getblacklist_sendim { get { return blacklist_sendim; } }
|
||||
public List<string> Getblacklist_recvim { get { return blacklist_recvim; } }
|
||||
#endregion
|
||||
|
||||
#region UUID rules Exceptions
|
||||
// UUID based rules / Exceptions
|
||||
protected Dictionary<UUID, Dictionary<string, string>> uuid_rules = new Dictionary<UUID, Dictionary<string, string>>();
|
||||
protected Dictionary<UUID, Dictionary<string, string>> uuid_exceptions = new Dictionary<UUID, Dictionary<string, string>>();
|
||||
public Dictionary<UUID, Dictionary<string, string>> Getuuid_rules { get { return uuid_rules; } }
|
||||
public Dictionary<UUID, Dictionary<string, string>> Getuuid_exceptions { get { return uuid_exceptions; } }
|
||||
public bool Clearrule(bool as_exception, UUID soruce)
|
||||
{
|
||||
return RemoveRule(as_exception, null, soruce);
|
||||
}
|
||||
public bool UpdateRule(bool as_exception, string rule, string arg, UUID source)
|
||||
{
|
||||
if (as_exception == false)
|
||||
{
|
||||
lock (uuid_rules)
|
||||
{
|
||||
if (uuid_rules.ContainsKey(source) == false)
|
||||
{
|
||||
uuid_rules.Add(source, new Dictionary<string, string>());
|
||||
}
|
||||
if (uuid_rules[source].ContainsKey(rule) == true)
|
||||
{
|
||||
uuid_rules[source].Remove(rule);
|
||||
}
|
||||
uuid_rules[source].Add(rule, arg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (uuid_exceptions)
|
||||
{
|
||||
if (uuid_exceptions.ContainsKey(source) == false)
|
||||
{
|
||||
uuid_exceptions.Add(source, new Dictionary<string, string>());
|
||||
}
|
||||
if (uuid_exceptions[source].ContainsKey(rule) == true)
|
||||
{
|
||||
uuid_exceptions[source].Remove(rule);
|
||||
}
|
||||
uuid_exceptions[source].Add(rule, arg);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool RemoveRule(bool as_exception, string rule, UUID source)
|
||||
{
|
||||
if (as_exception == false)
|
||||
{
|
||||
lock (uuid_rules)
|
||||
{
|
||||
if (uuid_rules.ContainsKey(source) == true)
|
||||
{
|
||||
if (rule != null)
|
||||
{
|
||||
if (uuid_rules[source].ContainsKey(rule) == true)
|
||||
{
|
||||
uuid_rules[source].Remove(rule);
|
||||
}
|
||||
if (uuid_rules[source].Count == 0)
|
||||
{
|
||||
uuid_rules.Remove(source);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uuid_rules.Remove(source);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (uuid_exceptions)
|
||||
{
|
||||
if (rule != null)
|
||||
{
|
||||
if (uuid_exceptions[source].ContainsKey(rule) == true)
|
||||
{
|
||||
uuid_exceptions[source].Remove(rule);
|
||||
}
|
||||
if (uuid_exceptions[source].Count == 0)
|
||||
{
|
||||
uuid_exceptions.Remove(source);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uuid_exceptions.Remove(source);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Flags
|
||||
// Flags
|
||||
protected bool recvchat_channel_zero_lock = true;
|
||||
protected bool sendchannel_lock;
|
||||
protected bool recvemote_lock;
|
||||
protected bool sendim_lock;
|
||||
public void SetLock(string name, bool status)
|
||||
{
|
||||
if (name == "sendim_lock") { sendim_lock = status; }
|
||||
else if (name == "recvemote_lock") { recvemote_lock = status; }
|
||||
else if (name == "sendchannel_lock") { sendchannel_lock = status; }
|
||||
else if (name == "recvchat_channel_zero_lock") { recvchat_channel_zero_lock = status; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Notify
|
||||
// Notify
|
||||
protected Dictionary<string, List<int>> Notify = new Dictionary<string, List<int>>();
|
||||
public Dictionary<string, List<int>> Getnotify { get { return Notify; } }
|
||||
|
||||
public void NotifyUpdate(bool Add, string word)
|
||||
{
|
||||
NotifyUpdate(Add, word, -1);
|
||||
}
|
||||
|
||||
public void NotifyUpdate(bool Add, string word,int channel)
|
||||
{
|
||||
lock (Notify)
|
||||
{
|
||||
if (Add == true)
|
||||
{
|
||||
if (Notify.ContainsKey(word) == false)
|
||||
{
|
||||
Notify.Add(word, new List<int>());
|
||||
}
|
||||
if (channel > -1)
|
||||
{
|
||||
if (Notify[word].Contains(channel) == false)
|
||||
{
|
||||
Notify[word].Add(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Notify.ContainsKey(word) == true)
|
||||
{
|
||||
if (Notify[word].Contains(channel) == true)
|
||||
{
|
||||
Notify[word].Remove(channel);
|
||||
if(Notify[word].Count == 0)
|
||||
{
|
||||
Notify.Remove(word);
|
||||
}
|
||||
}
|
||||
if (channel == -1)
|
||||
{
|
||||
Notify.Remove(word);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ using System.Linq;
|
|||
|
||||
namespace BetterSecondBot.bottypes
|
||||
{
|
||||
public abstract class ChatRelay : RLVbot
|
||||
public abstract class ChatRelay : AwaitReplyEventBot
|
||||
{
|
||||
#region GroupIMs
|
||||
protected int localchatlimit = 20;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
SecondBot -> DialogsBot -> ChatRelay -> RLVbot -> RLVbotHelper ->
|
||||
AwaitReplyEventBot -> CommandsBot -> AVstorageBot -> AttachableBot ->
|
||||
SecondBot -> DialogsBot -> ChatRelay -> AwaitReplyEventBot -> CommandsBot -> AVstorageBot -> AttachableBot ->
|
||||
MessageSwitcherBot -> EventsBot -> VoidEventBot -> AnimationsBot ->
|
||||
VirtualsBot -> Log2FileBot -> ActionsAutoAcceptBot -> BasicBot
|
||||
Loading…
Reference in a new issue