n}QS`Xisv#Vg3g
z1{BB8pm~8Ug~3C@|Geh2HL@g!=3B}_DtV>MKqCrX5EpVW3sIK3?jo8+2U{y?!Izu@
zPp|CG)1o)Cai^Ca$)cxNUWIz8O}3|C^^t>*qZ_BgBZkJWy(tV|FFjNnQN$)~tc!xW
z&B`lmkwoaqNBx&%(cjKS&HARo@d|M;2nM?1GyF;>Z@)};Z_&_H7l}?18v6Jyi0<7P
zt&}zCQww5G;|PbkRvpoa6|7cohwa*txs0$ky&{Im4^ECgfj^VmYJJh?6nY0xe43d|
znfx0+iDn`)+L3w7`ldn$_Z*r6UyS9m!H~VPn9R;&(JClWe-L<>CD2&sNEx1w;%qm~c-ze4G0IB@3eM}I>pli20-WZGpul8L
zt>tS*2v`r%{_BrujFRWIutmr3eBt{hY8c8VEAIOs^k=E_|R?+J&Sq51igZ=kh1-qE{LaJAc+2SS&`qIkvt^2%FalpoDi_
z|C!f|i7ie0tb&XCWGs3+^tnMNz~dCl2?{WC6ehQH)z5|a79k|L;D8Pv@}#}%O>&0G
z3jK8*9i2`
-
-
diff --git a/CLI/HttpWebUi/theme/layout/cdn.js.layout b/CLI/HttpWebUi/theme/layout/cdn.js.layout
deleted file mode 100644
index a47b628..0000000
--- a/CLI/HttpWebUi/theme/layout/cdn.js.layout
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/CLI/HttpWebUi/theme/layout/full.layout b/CLI/HttpWebUi/theme/layout/full.layout
deleted file mode 100644
index 236b6d2..0000000
--- a/CLI/HttpWebUi/theme/layout/full.layout
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
- [[html_title]] - [[html_title_after]]
- [[html_cs_top_cdn]]
- [[html_cs_top]]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [[html_js_bottom_cdn]]
- [[html_js_bottom]]
-
-
-
-
diff --git a/CLI/HttpWebUi/theme/layout/login.block b/CLI/HttpWebUi/theme/layout/login.block
deleted file mode 100644
index 8a26ea4..0000000
--- a/CLI/HttpWebUi/theme/layout/login.block
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
Bot webUI auth required
-
-
-
diff --git a/CLI/HttpWebUi/theme/layout/sidemenu.layout b/CLI/HttpWebUi/theme/layout/sidemenu.layout
deleted file mode 100644
index 057fd2e..0000000
--- a/CLI/HttpWebUi/theme/layout/sidemenu.layout
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
- [[html_title]] - [[html_title_after]]
- [[html_cs_top_cdn]]
- [[html_cs_top]]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [[page_content]]
-
-
-
-
-
- [[html_js_bottom_cdn]]
- [[html_js_bottom]]
-
-
-
-
diff --git a/CLI/HttpWebUi/webui.cs b/CLI/HttpWebUi/webui.cs
deleted file mode 100644
index a58463d..0000000
--- a/CLI/HttpWebUi/webui.cs
+++ /dev/null
@@ -1,514 +0,0 @@
-using BetterSecondBot.HttpServer;
-using BetterSecondBotShared.Json;
-using BetterSecondBotShared.Static;
-using BSB.bottypes;
-using Microsoft.VisualBasic.CompilerServices;
-using Newtonsoft.Json;
-using OpenMetaverse;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net;
-using System.Reflection;
-using System.Text;
-using System.Threading;
-
-namespace BetterSecondBot.HttpWebUi
-{
- public class Webui
- {
- private JsonConfig siteconfig;
- private SecondBot bot;
- private Dictionary vaildlogincookies = new Dictionary();
- public Webui(JsonConfig setconfig, SecondBot setbot)
- {
- bot = setbot;
- siteconfig = setconfig;
- }
- protected KeyValuePair Logincookievaild(HttpListenerResponse resp)
- {
- return Logincookievaild(resp, false);
- }
- protected KeyValuePair Logincookievaild(HttpListenerResponse resp, bool force_logout)
- {
- foreach (Cookie C in resp.Cookies)
- {
- if (C.Name == "logincookie")
- {
- if (force_logout == true)
- {
- if (vaildlogincookies.ContainsKey(C.Value) == true)
- {
- vaildlogincookies.Remove(C.Value);
- }
- }
- else
- {
- if (vaildlogincookies.ContainsKey(C.Value) == true)
- {
- if (vaildlogincookies[C.Value] > helpers.UnixTimeNow())
- {
- return new KeyValuePair(true, true);
- }
- }
- }
- resp.Cookies.Remove(C);
- C.Expired = true;
- resp.Cookies.Add(C);
- return new KeyValuePair(true, false);
- }
- }
- return new KeyValuePair(false, false);
- }
- public bool Post_process(Json_http_reply reply, HttpListenerResponse resp, List args, Dictionary post_args)
- {
- bool processed = false;
- if (args != null)
- {
- if (args.Count >= 1)
- {
- if (args[0] == "ajax")
- {
- processed = true;
- // webui only cares about ajax post requests
- string mod = "none";
- string area = "none";
- if (args.Count >= 2)
- {
- mod = args[1];
- }
- if (args.Count >= 3)
- {
- area = args[2];
- }
- KeyValuePair logincheck = Logincookievaild(resp);
-
- if (logincheck.Key == false)
- {
- if (mod == "login")
- {
- if (post_args.ContainsKey("logincode") == true)
- {
- if (post_args["logincode"] == siteconfig.Security_WebUIKey)
- {
- reply.status = true;
- string newcookiecode = "";
- while ((newcookiecode == null) || (newcookiecode == "") || (vaildlogincookies.ContainsKey(newcookiecode) == true))
- {
- newcookiecode = helpers.GetSHA1(siteconfig.Security_WebUIKey + helpers.UnixTimeNow().ToString() + new Random().Next(12345).ToString());
- }
- vaildlogincookies.Add(newcookiecode, helpers.UnixTimeNow() + (5 * 60)); // auto logout after 5 mins
- Cookie logincookie = new Cookie("logincookie", newcookiecode)
- {
- Expires = DateTime.Now.AddDays(1),
- Path = "/"
- };
- resp.Cookies.Add(logincookie);
- Console.WriteLine("Cookie created: " + logincookie.Value + " <=> " + newcookiecode + "");
- reply.message = "ok";
- reply.redirect = "/";
- }
- else
- {
- reply.status = false;
- reply.message = "fail";
- }
- }
- else
- {
- reply.status = false;
- reply.message = "Missing code";
- }
- }
- else
- {
- reply.status = false;
- reply.message = "No access";
- }
- }
- else
- {
- if (logincheck.Value == true)
- {
- reply.status = true;
- // logged in
- if (mod == "logout")
- {
- Logincookievaild(resp, true);
- reply.message = "logged-out";
- reply.redirect = "/";
- reply.status = false;
- }
- else if(mod == "interface")
- {
- if (area == "get")
- {
- reply.message = JsonConvert.SerializeObject(bot.GetLastCommands(30));
- }
- else if(area == "send")
- {
- if (post_args.ContainsKey("message") == true)
- {
- string[] bits = post_args["message"].Split("|||");
- if(bits.Length == 2)
- {
- reply.status = bot.GetCommandsInterface.Call(bits[0], bits[1]);
- if(reply.status == true)
- {
- reply.message = "ok";
- }
- else
- {
- reply.message = "Failed";
- }
- }
- else
- {
- reply.status = bot.GetCommandsInterface.Call(post_args["message"]);
- if (reply.status == true)
- {
- reply.message = "ok";
- }
- else
- {
- reply.message = "Failed";
- }
- }
- }
- else
- {
- reply.message = "No message";
- reply.status = false;
- }
- }
- else
- {
- reply.message = "Unknown area";
- reply.status = false;
- }
- }
- else if (mod == "localchat")
- {
- if (area == "get")
- {
- reply.message = JsonConvert.SerializeObject(bot.getLocalChatHistory());
- }
- else if (area == "send")
- {
- if (post_args.ContainsKey("message") == true)
- {
- bot.AddToLocalChat("{Via WebGUI}", post_args["message"]);
- bot.GetClient.Self.Chat("{Via WebGUI} "+ post_args["message"], 0,ChatType.Normal);
- reply.message = "ok";
- reply.status = true;
- }
- else
- {
- reply.message = "No message";
- reply.status = false;
- }
- }
- else
- {
- reply.message = "Unknown area";
- reply.status = false;
- }
- }
- else if (mod == "groupchat")
- {
- if (area == "list")
- {
- Dictionary groupname_uuid = new Dictionary();
- foreach (KeyValuePair entry in bot.MyGroups)
- {
- groupname_uuid.Add(entry.Key.ToString(), entry.Value.Name);
- }
- reply.message = JsonConvert.SerializeObject(groupname_uuid);
- }
- if (area == "get")
- {
- if (post_args.ContainsKey("groupuuid") == true)
- {
- if (UUID.TryParse(post_args["groupuuid"], out UUID groupuuid) == true)
- {
- reply.message = JsonConvert.SerializeObject(bot.GetGroupchat(groupuuid));
- }
- else
- {
- reply.message = "Unable to process group uuid";
- reply.status = false;
- }
- }
- else
- {
- reply.message = "No groupuuid";
- reply.status = false;
- }
- }
- else if (area == "send")
- {
- if (post_args.ContainsKey("groupuuid") == true)
- {
- if (UUID.TryParse(post_args["groupuuid"], out UUID groupuuid) == true)
- {
- if (post_args.ContainsKey("message") == true)
- {
- bot.GetClient.Self.RequestJoinGroupChat(groupuuid);
- Thread.Sleep(100);
- bot.GetClient.Self.InstantMessageGroup(groupuuid, "{Via WebGUI} " + post_args["message"]);
- bot.AddToGroupchat(groupuuid, "{Via WebGUI}", post_args["message"]);
- reply.message = "ok";
- reply.status = true;
- }
- else
- {
- reply.message = "No message";
- reply.status = false;
- }
- }
- else
- {
- reply.message = "Unable to process group uuid";
- reply.status = false;
- }
- }
- else
- {
- reply.message = "No groupuuid";
- reply.status = false;
- }
- }
- else
- {
- reply.message = "Unknown area";
- reply.status = false;
- }
- }
- else if (mod == "im")
- {
- if (area == "list")
- {
- reply.message = JsonConvert.SerializeObject(bot.GetIMChatWindowKeyNames());
- }
- else if (area == "send")
- {
- if (post_args.ContainsKey("avataruuid") == true)
- {
- if (UUID.TryParse(post_args["avataruuid"], out UUID avataruuid) == true)
- {
- if (post_args.ContainsKey("message") == true)
- {
- bot.GetCommandsInterface.Call("im", "" + avataruuid.ToString() + "~#~{Via WebGUI} " + post_args["message"]);
- reply.message = "ok";
- reply.status = true;
- }
- else
- {
- reply.message = "No message";
-
- }
- }
- else
- {
- reply.message = "Unable to process avatar uuid";
- reply.status = false;
- }
- }
- else
- {
- reply.message = "No avataruuid";
- reply.status = false;
- }
- }
- else if (area == "get")
- {
- if (post_args.ContainsKey("avataruuid") == true)
- {
- if (UUID.TryParse(post_args["avataruuid"], out UUID avataruuid) == true)
- {
- reply.message = JsonConvert.SerializeObject(bot.GetIMChatWindow(avataruuid));
- }
- else
- {
- reply.message = "Unable to process avatar uuid";
- reply.status = false;
- }
- }
- else
- {
- reply.message = "No avataruuid";
- reply.status = false;
- }
- }
- else
- {
- reply.message = "Unknown area";
- reply.status = false;
- }
- }
- else
- {
- reply.message = "No action";
- reply.status = false;
- }
- }
- else
- {
- // login expired
- reply.message = "login-expired";
- reply.redirect = "/";
- Logincookievaild(resp, true);
- }
- }
- }
- }
- }
- return !processed;
- }
- public string Html_logged_in(string mod, string area)
- {
- string layout = helpers.ReadResourceFile(Assembly.GetExecutingAssembly(), "sidemenu.layout");
- Dictionary swaps = new Dictionary();
-
-
- string pagetitle = "Dashboard";
- string pagecontent = "";
- string pageactions = "";
- string js_onready = "";
- string[] menu_text = new string[] { "Localchat", "Groupchat", "IMs", "Interface" };
- string[] menu_links = new string[] { "localchat", "groupchat", "im", "interface" };
- string[] meni_icons = new string[] { "fas fa-comment", "fas fa-comments", "fas fa-users","fas fa-robot" };
- int loop = 0;
- string menu = "";
- while (loop < menu_text.Count())
- {
- string active = "";
- if (menu_links[loop] == mod) active = "active";
- menu = "" + menu + " " + menu_text[loop] + " ";
- loop++;
- }
- swaps.Add("html_menu", menu);
- if (mod == "none")
- {
- pagecontent = "Please select a menu item on the left
";
- }
- else if(mod == "localchat")
- {
- pagetitle = "Localchat";
- pagecontent = " " +
- "";
- js_onready = "setInterval(function(){ update_localchat(\"" + siteconfig.Http_PublicUrl+"\"); },400);";
-
- }
- else if (mod == "groupchat")
- {
- pagetitle = "Group chat";
- pagecontent = "";
- if (area == "none")
- {
-
- }
-
-
-
- }
- swaps.Add("html_title", pagetitle);
- swaps.Add("page_actions", pageactions);
- swaps.Add("page_content", pagecontent);
- swaps.Add("page_title", pagetitle);
- swaps.Add("html_cs_top", "");
- swaps.Add("html_js_bottom", "");
- swaps.Add("html_js_onready", js_onready);
- foreach (KeyValuePair A in swaps)
- {
- layout = layout.Replace("[[" + A.Key + "]]", A.Value);
- }
- return layout;
- }
- public string Html_logged_out()
- {
- string layout = helpers.ReadResourceFile(Assembly.GetExecutingAssembly(), "full.layout");
- layout = layout.Replace("[[page_content]]", helpers.ReadResourceFile(Assembly.GetExecutingAssembly(), "login.block"));
- layout = layout.Replace("[[html_js_onready]]", "");
- layout = layout.Replace("[[html_cs_top]]", "");
- layout = layout.Replace("[[html_js_bottom]]", "");
- layout = layout.Replace("[[html_title]]", siteconfig.Basic_BotUserName);
- return layout;
- }
- public KeyValuePair Get_Process(HttpListenerResponse resp, List args)
- {
-
- // get content
- if (args != null)
- {
- if (args.Count >= 1)
- {
- if (args[0] == "theme")
- {
- if (args.Count >= 2)
- {
- if (args[1] == "images")
- {
- return new KeyValuePair("image/png", helpers.ReadResourceFileBinary(Assembly.GetExecutingAssembly(), args[2]));
- }
- else if (args[1] == "css")
- {
- return new KeyValuePair("text/css", Encoding.UTF8.GetBytes(helpers.ReadResourceFile(Assembly.GetExecutingAssembly(), args[2])));
- }
- else if (args[1] == "js")
- {
- return new KeyValuePair("text/javascript", Encoding.UTF8.GetBytes(helpers.ReadResourceFile(Assembly.GetExecutingAssembly(), args[2])));
- }
- }
- }
- }
- }
- // get display
- KeyValuePair logincheck = Logincookievaild(resp);
- if (logincheck.Key == true)
- {
- if (logincheck.Value == false)
- {
- Logincookievaild(resp, true);
- }
- }
- string reply_with;
- if (logincheck.Value == false)
- {
- reply_with = Html_logged_out();
- }
- else
- {
- string mod = "none";
- string area = "none";
- if (args.Count >= 1)
- {
- mod = args[0];
- }
- if (args.Count >= 2)
- {
- area = args[1];
- }
-
- if (mod == "logout")
- {
- Logincookievaild(resp, true);
- reply_with = Html_logged_out();
- }
- else
- {
- // logged in
- reply_with = Html_logged_in(mod, area);
- }
- }
- reply_with = reply_with.Replace("[[url_base]]", siteconfig.Http_PublicUrl);
- reply_with = reply_with.Replace("[[html_title_after]]", "Secondbot web UI");
- reply_with = reply_with.Replace("[[html_cs_top_cdn]]", helpers.ReadResourceFile(Assembly.GetExecutingAssembly(), "cdn.css.layout"));
- reply_with = reply_with.Replace("[[html_js_bottom_cdn]]", helpers.ReadResourceFile(Assembly.GetExecutingAssembly(), "cdn.js.layout"));
- return new KeyValuePair("text/html", Encoding.UTF8.GetBytes(reply_with));
- }
- }
-}
diff --git a/CLI/WikiMake/wiki_header.txt b/CLI/WikiMake/wiki_header.txt
index 28a6b76..8e3fcf5 100644
--- a/CLI/WikiMake/wiki_header.txt
+++ b/CLI/WikiMake/wiki_header.txt
@@ -1,28 +1,28 @@
-
-
-Secondbot Wiki [[AREA]]
-
-
-
-
-
-
-
+
+
+Secondbot Wiki [[AREA]]
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CLI/WikiMake/wikimake.cs b/CLI/WikiMake/wikimake.cs
index 008cf95..8a4b531 100644
--- a/CLI/WikiMake/wikimake.cs
+++ b/CLI/WikiMake/wikimake.cs
@@ -17,7 +17,7 @@ namespace BetterSecondBot.WikiMake
protected string html_footer = "";
protected string buildVersion = "";
protected SimpleIO io;
- protected Dictionary
seen_command_names = new Dictionary();
+ protected Dictionary seen_command_names = new Dictionary();
public string CreateRoot()
@@ -28,7 +28,7 @@ namespace BetterSecondBot.WikiMake
sb.Append(buildVersion);
sb.Append(" ");
sb.Append("Interface Commands Status ");
- foreach (KeyValuePair> entry in api_reports)
+ foreach (KeyValuePair> entry in api_reports)
{
sb.Append("");
sb.Append("[[AREA]] ");
- if(workspace != "")
+ if (workspace != "")
{
sb.Append(" / [[WORKSPACE]] ");
}
@@ -103,7 +102,7 @@ namespace BetterSecondBot.WikiMake
int minargs = shared_interface.GetCommandArgs(c);
string[] arg_types = shared_interface.GetCommandArgTypes(c);
string[] arg_hints = shared_interface.GetCommandArgHints(c);
- if(area == "Core")
+ if (area == "Core")
{
StringBuilder ExampleCall = new StringBuilder();
ExampleCall.Append("Example: [[COMMAND]]");
@@ -194,9 +193,9 @@ namespace BetterSecondBot.WikiMake
sb.Append(buildVersion);
sb.Append(" ");
sb.Append("Command Min args ");
- foreach(string c in cmds)
+ foreach (string c in cmds)
{
- if(shared_interface.GetCommandWorkspace(c) == workspace)
+ if (shared_interface.GetCommandWorkspace(c) == workspace)
{
int args = shared_interface.GetCommandArgs(c);
sb.Append("Build: ");
+ sb.Append(buildVersion);
+ sb.Append(" ");
+ sb.Append("Interface: [[AREA]] ");
+ if (workspace != "")
+ {
+ sb.Append(" / [[WORKSPACE]] ");
+ }
+ sb.Append(" [[COMMAND]] ");
+ sb.Append("[[URLENDPOINT]]/[[WORKSPACE]]/[[COMMAND]]/[[URLADDON]] ");
+ sb.Append("Method: [[APIMETHOD]]");
+ sb.Append(" ");
+ sb.Append("[[HELP]]");
+ Dictionary> values = HTTP.getCommandArgs(workspace, c);
+ int ValueCount = values.Count;
+
+ if (ValueCount > 0)
+ {
+ sb.Append("Args helper ");
+ sb.Append("Name Type Hint ");
+ foreach (KeyValuePair> entry in values)
+ {
+ string hint = entry.Value.Value;
+ string type = entry.Value.Key;
+ if (entry.Value.Key.Contains("Optional") == true)
+ {
+ type = type.Replace("Optional", "{Optional} ");
+ }
+ else if (entry.Value.Key == "URLARG")
+ {
+ type = "URL arg";
+ }
+ sb.Append("" + entry.Key + " " + type + " " + hint + " ");
+ }
+ sb.Append("
");
+ }
+
+ string[] returnvalues = HTTP.getReturnsValues(workspace, c);
+ if (returnvalues.Length > 0)
+ {
+ sb.Append("Possible replys ");
+ sb.Append("");
+ foreach (string entry in returnvalues)
+ {
+ sb.Append(""+entry+" ");
+ }
+ sb.Append(" ");
+ }
+
+
+
+ sb = DebugModeCreateWiki.MenuActive(sb, area);
+ sb.Append(html_footer);
+ sb.Replace("[[COMMAND]]", c);
+ sb.Replace("[[URLENDPOINT]]", "http://localhost:8080");
+ sb.Replace("[[APIMETHOD]]", HTTP.getCommandMethod(workspace, c));
+ sb.Replace("[[URLADDON]]", getURLargs(values));
+ sb.Replace("[[HELP]]", HTTP.getCommandAbout(workspace, c));
+ sb.Replace("[[MINARGS]]", ValueCount.ToString());
+ sb.Replace("[[WORKSPACE]]", workspace);
+ sb.Replace("[[AREA]]", area);
+ sb.Replace("[[SUBFOLDER]]", "");
+ sb.Replace("[[RETURNROOT]]", "../");
+ string target_file = "" + area + "" + workspace + "" + c + ".html";
+ io.writefile(target_file, sb.ToString());
+ }
+ }
+ }
+
+ protected void HTTPmenu(string area, HTTPendpoint HTTP)
+ {
+ api_reports.Add(area, new KeyValuePair(HTTP.getFullCount(), "Basic"));
+
+ // create index
+ StringBuilder sb = new StringBuilder();
+ sb.Append(html_header);
+ sb.Append("Interface:");
+ sb.Append("HTTP");
+ sb.Append(" ");
+ sb.Append("Build: ");
+ sb.Append(buildVersion);
+ sb.Append(" ");
+ sb.Append("Workspace Commands ");
+ foreach (string workspace in HTTP.getEndPoints())
+ {
+ string workspace_link = "" + workspace + " ";
+ sb.Append("");
+ sb.Append(workspace_link);
+ sb.Append(" ");
+ sb.Append(HTTP.getEndpointCount(workspace).ToString());
+ sb.Append(" ");
+ }
+ sb.Append("
");
+ sb.Replace("[[SUBFOLDER]]", "");
+ sb.Replace("[[RETURNROOT]]", "../");
+ sb.Replace("[[AREA]]", area);
+ sb.Append(html_footer);
+ sb = DebugModeCreateWiki.MenuActive(sb, area);
+ io.writefile("" + area + ".html", sb.ToString());
+ }
+
+ protected void HTTPWorkspaces(string area, HTTPendpoint HTTP)
+ {
+ foreach (string workspace in HTTP.getEndPoints())
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(html_header);
+ sb.Append("Interface: [[AREA]] ");
+ if (workspace != "")
+ {
+ sb.Append(" / [[WORKSPACE]]");
+ }
+ sb.Append(" ");
+ sb.Append("Build: ");
+ sb.Append(buildVersion);
+ sb.Append(" ");
+ sb.Append("Command Min args ");
+ foreach (string c in HTTP.getEndpointCommands(workspace))
+ {
+ int args = HTTP.getCommandArgCount(workspace, c);
+ sb.Append("");
+ sb.Append(c);
+ sb.Append(" ");
+ sb.Append(args.ToString());
+ sb.Append(" ");
+ }
+ sb.Append("
");
+ sb.Replace("[[SUBFOLDER]]", "");
+ sb.Replace("[[RETURNROOT]]", "../");
+ sb.Replace("[[WORKSPACE]]", workspace);
+ sb.Replace("[[AREA]]", area);
+ sb.Append(html_footer);
+ sb = DebugModeCreateWiki.MenuActive(sb, area);
+ string target_file = "" + area + "" + workspace + ".html";
+ io.writefile(target_file, sb.ToString());
+ }
+ }
+ }
+
+ public class HTTPendpoint
+ {
+ protected List endpoints = new List();
+ public HTTPendpoint()
+ {
+ Endpoint core = new Endpoint();
+ core.name = "core";
+ core.callable.Add(new gettoken());
+ core.callable.Add(new logout());
+ core.callable.Add(new version());
+ core.callable.Add(new name());
+ core.callable.Add(new command());
+ endpoints.Add(core);
+ Endpoint inventory = new Endpoint();
+ inventory.name = "inventory";
+ inventory.callable.Add(new contents());
+ inventory.callable.Add(new folders());
+ endpoints.Add(inventory);
+ }
+
+ public string getCommandMethod(string endpoint, string command)
+ {
+ foreach (Endpoint End in endpoints)
+ {
+ if (End.name == endpoint)
+ {
+ foreach (APIcall api in End.callable)
+ {
+ if (api.name == command)
+ {
+ return api.type;
+ }
+ }
+ }
+ }
+ return "?";
+ }
+
+ public string getCommandAbout(string endpoint, string command)
+ {
+ foreach (Endpoint End in endpoints)
+ {
+ if (End.name == endpoint)
+ {
+ foreach (APIcall api in End.callable)
+ {
+ if (api.name == command)
+ {
+ return api.about;
+ }
+ }
+ }
+ }
+ return "?";
+ }
+
+ public string[] getReturnsValues(string endpoint, string command)
+ {
+ foreach (Endpoint End in endpoints)
+ {
+ if (End.name == endpoint)
+ {
+ foreach (APIcall api in End.callable)
+ {
+ if (api.name == command)
+ {
+ return api.returns.ToArray();
+ }
+ }
+ }
+ }
+ return new string[] { };
+ }
+
+
+
+ public int getCommandArgCount(string endpoint, string command)
+ {
+ foreach (Endpoint End in endpoints)
+ {
+ if (End.name == endpoint)
+ {
+ foreach (APIcall api in End.callable)
+ {
+ if (api.name == command)
+ {
+ return api.values.Count;
+ }
+ }
+ }
+ }
+ return 0;
+ }
+
+ public string[] getEndpointCommands(string endpointname)
+ {
+ List commands = new List();
+ foreach (Endpoint End in endpoints)
+ {
+ if (End.name == endpointname)
+ {
+ foreach (APIcall api in End.callable)
+ {
+ commands.Add(api.name);
+ }
+ }
+ }
+ return commands.ToArray();
+ }
+
+ public string[] getEndPoints()
+ {
+ List names = new List();
+ foreach (Endpoint End in endpoints)
+ {
+ names.Add(End.name);
+ }
+ return names.ToArray();
+ }
+
+ public int getEndpointCount(string endpointname)
+ {
+ foreach (Endpoint End in endpoints)
+ {
+ if (End.name == endpointname)
+ {
+ return End.callable.Count;
+ }
+ }
+ return 0;
+ }
+
+ public int getFullCount()
+ {
+ int count = 0;
+ foreach (Endpoint End in endpoints)
+ {
+ count += End.callable.Count;
+ }
+ return count;
+ }
+
+ public Dictionary> getCommandArgs(string endpoint, string command)
+ {
+ Dictionary> empty = new Dictionary>();
+ foreach (Endpoint End in endpoints)
+ {
+ if (End.name == endpoint)
+ {
+ foreach (APIcall api in End.callable)
+ {
+ if (api.name == command)
+ {
+ return api.values;
+ }
+ }
+ }
+ }
+ return empty;
+
+ }
+
+ }
+
+ public class Endpoint
+ {
+ public string name = "Notset";
+ public List callable = new List();
+ }
+
+ abstract public class APIcall
+ {
+ public string name { get { return GetType().Name.ToLowerInvariant(); } }
+ public string type = "get";
+ public string about = "A API call that is missing its about value";
+ public Dictionary> values = new Dictionary>();
+ public List returns = new List();
+ public bool RequiresToken = true;
+
+ public APIcall()
+ {
+ Setup();
+ }
+ public virtual void Setup()
+ {
+ if (RequiresToken == true)
+ {
+ returns.Add("Token not accepted");
+ values.Add(
+ "token",
+ new KeyValuePair(
+ "URLARG",
+ "the api access token")
+ );
+ }
+ }
+ }
+
+ abstract public class postAPIcall : APIcall
+ {
+ public override void Setup()
+ {
+ type = "post";
+ base.Setup();
+ }
+ }
+
+ public class gettoken : postAPIcall
+ {
+ public override void Setup()
+ {
+ RequiresToken = false;
+ about = "Requests a new token (Vaild for 10 mins) to use with all other requests";
+ values.Add("Authcode", new KeyValuePair("string", "the first 10 chars of SHA1(unixtime+WebUIkey) unixtime can be +- 30 of the bots time."));
+ returns = new List();
+ returns.Add("Authcode not accepted");
+ returns.Add("New API Token");
+ base.Setup();
+ }
+ }
+
+ public class logout : APIcall
+ {
+ public override void Setup()
+ {
+ about = "A API call that is missing its about value";
+ returns.Add("ok");
+ returns.Add("Failed to remove token");
+ base.Setup();
+ }
+ }
+
+ public class version : APIcall
+ {
+ public override void Setup()
+ {
+ about = "Gets the bots build version";
+ returns.Add("Bot build version");
+ base.Setup();
+ }
+ }
+
+ public class name : APIcall
+ {
+ public override void Setup()
+ {
+ about = "Gets the name of the bot";
+ returns.Add("Fistname Lastname");
+ base.Setup();
+ }
+ }
+
+ public class command : postAPIcall
+ {
+ public override void Setup()
+ {
+ about = "Makes a request to the core commands lib";
+ values.Add(
+ "body",
+ new KeyValuePair(
+ "JsonObject",
+ "A JSON object formated as follows Command: string Args: string[] AuthCode: string ======== See LSL example on how to create a core command auth code")
+ );
+ returns.Add("accepted");
+ base.Setup();
+ }
+ }
+
+ public class contents : APIcall
+ {
+ public override void Setup()
+ {
+ about = "Requests the contents of a folder as an array of InventoryMapItem Formated as follows InventoryMapItemid: UUID name: String typename: String ";
+ values.Add(
+ "folderUUID",
+ new KeyValuePair(
+ "URLARG",
+ "the folder to fetch (Found via: inventory/folders)")
+ );
+ returns.Add("array of InventoryMapItem");
+ base.Setup();
+ }
+ }
+
+ public class folders : APIcall
+ {
+ public override void Setup()
+ {
+ about = "Requests the inventory folder layout as a json object InventoryMapFolder Formated as follows InventoryMapItemid: UUID name: String subfolders: InventoryMapFolder[] ";
+ returns.Add("array of InventoryMapFolder");
+ base.Setup();
+ }
+ }
+
}
diff --git a/Core/BSB.csproj b/Core/BSB.csproj
index ce419aa..90e779d 100644
--- a/Core/BSB.csproj
+++ b/Core/BSB.csproj
@@ -21,8 +21,8 @@
false
linux-x64
-
-
+
+