function name changes plus cleanup
This commit is contained in:
parent
1f96060e72
commit
4d03589345
11 changed files with 60 additions and 62 deletions
|
|
@ -16,7 +16,7 @@ namespace BetterSecondBotShared.bottypes
|
|||
LastStatusMessage = "No status";
|
||||
}
|
||||
protected List<string> SubMasters = new List<string>();
|
||||
public bool is_avatar_master(string name)
|
||||
public bool Is_avatar_master(string name)
|
||||
{
|
||||
if (name == myconfig.Security_MasterUsername)
|
||||
{
|
||||
|
|
@ -202,7 +202,7 @@ namespace BetterSecondBotShared.bottypes
|
|||
{
|
||||
name = "" + name + " " + stage1[1].FirstCharToUpper() + "";
|
||||
}
|
||||
if(is_avatar_master(name) == true)
|
||||
if(Is_avatar_master(name) == true)
|
||||
{
|
||||
GroupInvitationEventArgs G = new GroupInvitationEventArgs(e.Simulator, e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message);
|
||||
Client.Self.GroupInviteRespond(G.AgentID, e.IM.IMSessionID, true);
|
||||
|
|
@ -211,7 +211,7 @@ namespace BetterSecondBotShared.bottypes
|
|||
}
|
||||
protected virtual void FriendshipOffer(UUID IMSessionID, string FromAgentName, UUID FromAgentID)
|
||||
{
|
||||
if (is_avatar_master(FromAgentName) == true)
|
||||
if (Is_avatar_master(FromAgentName) == true)
|
||||
{
|
||||
Client.Friends.AcceptFriendship(FromAgentID, IMSessionID);
|
||||
}
|
||||
|
|
@ -219,14 +219,14 @@ namespace BetterSecondBotShared.bottypes
|
|||
|
||||
protected virtual void RequestLure(UUID IMSessionID, string FromAgentName, UUID FromAgentID)
|
||||
{
|
||||
if (is_avatar_master(FromAgentName) == true)
|
||||
if (Is_avatar_master(FromAgentName) == true)
|
||||
{
|
||||
Client.Self.SendTeleportLure(FromAgentID);
|
||||
}
|
||||
}
|
||||
|
||||
protected List<UUID> accept_next_teleport_from = new List<UUID>();
|
||||
public void add_uuid_to_teleport_list(UUID avatar)
|
||||
public void Add_uuid_to_teleport_list(UUID avatar)
|
||||
{
|
||||
if (accept_next_teleport_from.Contains(avatar) == false)
|
||||
{
|
||||
|
|
@ -237,7 +237,7 @@ namespace BetterSecondBotShared.bottypes
|
|||
protected virtual void RequestTeleport(UUID IMSessionID, string FromAgentName, UUID FromAgentID)
|
||||
{
|
||||
bool allow = false;
|
||||
if (is_avatar_master(FromAgentName) == true)
|
||||
if (Is_avatar_master(FromAgentName) == true)
|
||||
{
|
||||
allow = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ namespace BetterSecondBotShared.Json
|
|||
|
||||
}
|
||||
|
||||
protected JsonConfig process_prop(JsonConfig reply,string arg,string arg_value_default)
|
||||
protected JsonConfig Process_prop(JsonConfig reply,string arg,string arg_value_default)
|
||||
{
|
||||
string arg_type = GetCommandArgTypes(arg).First();
|
||||
if (arg_type != "")
|
||||
|
|
@ -378,7 +378,7 @@ namespace BetterSecondBotShared.Json
|
|||
return reply;
|
||||
}
|
||||
|
||||
public static JsonConfig http_config_check(JsonConfig jsonConfig)
|
||||
public static JsonConfig Http_config_check(JsonConfig jsonConfig)
|
||||
{
|
||||
if (helpers.notempty(jsonConfig.Security_WebUIKey) == true)
|
||||
{
|
||||
|
|
@ -437,7 +437,7 @@ namespace BetterSecondBotShared.Json
|
|||
arg_value_default = arg_value_default.Replace("]", "");
|
||||
arg_value_default = arg_value_default.Replace("\"", "");
|
||||
}
|
||||
reply = process_prop(reply, arg, arg_value_default);
|
||||
reply = Process_prop(reply, arg, arg_value_default);
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace BetterSecondBotShared.logs
|
|||
}
|
||||
public static string Debug(string message, bool send_to_console)
|
||||
{
|
||||
return Add(message, ConsoleLogLogLevel.Debug, true);
|
||||
return Add(message, ConsoleLogLogLevel.Debug, send_to_console);
|
||||
}
|
||||
public static string Warn(string message)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace BetterSecondBot
|
|||
Thread.Sleep(3000);
|
||||
LogFormater.Status("-> Getting config from Docker");
|
||||
JsonConfig Config = MakeJsonConfig.FromENV();
|
||||
Config = MakeJsonConfig.http_config_check(Config);
|
||||
Config = MakeJsonConfig.Http_config_check(Config);
|
||||
new CliExitOnLogout(Config);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ namespace BetterSecondBot
|
|||
}
|
||||
if(ok_to_try_start == true)
|
||||
{
|
||||
Config = MakeJsonConfig.http_config_check(Config);
|
||||
Config = MakeJsonConfig.Http_config_check(Config);
|
||||
new CliExitOnLogout(Config);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ using System.Web;
|
|||
|
||||
namespace BetterSecondBot.HttpServer
|
||||
{
|
||||
public class json_http_reply
|
||||
public class Json_http_reply
|
||||
{
|
||||
public bool status;
|
||||
public string message;
|
||||
|
|
@ -100,7 +100,7 @@ namespace BetterSecondBot.HttpServer
|
|||
|
||||
protected async Task HandleIncomingConnections()
|
||||
{
|
||||
webui myUI = new webui(Config,Bot);
|
||||
Webui myUI = new Webui(Config,Bot);
|
||||
while (Bot.KillMe == false)
|
||||
{
|
||||
HttpListenerContext ctx = await listener.GetContextAsync().ConfigureAwait(true);
|
||||
|
|
@ -114,22 +114,20 @@ namespace BetterSecondBot.HttpServer
|
|||
test = test.Replace(Config.Http_PublicUrl, "");
|
||||
|
||||
//rproxy weirdness
|
||||
string use_http_url = Config.Http_PublicUrl.Replace("http://", "");
|
||||
use_http_url = Config.Http_PublicUrl.Replace("https://", "");
|
||||
test = test.Replace(":" + Config.Http_Port.ToString(), "");
|
||||
test = test.Replace(use_http_url, "");
|
||||
test = test.Replace("https://", "");
|
||||
test = test.Replace("http://", "");
|
||||
|
||||
test = test.Replace(Config.Http_PublicUrl, "");
|
||||
Config.Http_PublicUrl = Config.Http_PublicUrl.Replace("http://", "");
|
||||
Config.Http_PublicUrl = Config.Http_PublicUrl.Replace("https://", "");
|
||||
test = test.Replace(Config.Http_PublicUrl, "");
|
||||
test = test.Replace(":" + Config.Http_Port.ToString(), "");
|
||||
}
|
||||
json_http_reply reply = new json_http_reply();
|
||||
Json_http_reply reply = new Json_http_reply();
|
||||
List<string> http_args = test.Split('/', StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
byte[] data;
|
||||
resp.StatusCode = 200;
|
||||
resp.ContentType = "text/html";
|
||||
if (req.HttpMethod == "GET")
|
||||
{
|
||||
KeyValuePair<string, byte[]> replydata = myUI.Get_Process(req, resp, http_args);
|
||||
KeyValuePair<string, byte[]> replydata = myUI.Get_Process(resp, http_args);
|
||||
if (replydata.Value != null)
|
||||
{
|
||||
resp.ContentType = replydata.Key;
|
||||
|
|
@ -166,7 +164,7 @@ namespace BetterSecondBot.HttpServer
|
|||
}
|
||||
}
|
||||
resp.StatusCode = 200;
|
||||
if (myUI.Post_process(reply, req, resp, http_args, post_args) == true)
|
||||
if (myUI.Post_process(reply, resp, http_args, post_args) == true)
|
||||
{
|
||||
bool accept_request = false;
|
||||
string why_request_failed = "Bad signing request";
|
||||
|
|
|
|||
|
|
@ -15,27 +15,26 @@ using System.Threading;
|
|||
|
||||
namespace BetterSecondBot.HttpWebUi
|
||||
{
|
||||
public class webui
|
||||
public class Webui
|
||||
{
|
||||
JsonConfig siteconfig;
|
||||
SecondBot bot;
|
||||
Dictionary<string, long> vaildlogincookies = new Dictionary<string, long>();
|
||||
public webui(JsonConfig setconfig, SecondBot setbot)
|
||||
private JsonConfig siteconfig;
|
||||
private SecondBot bot;
|
||||
private Dictionary<string, long> vaildlogincookies = new Dictionary<string, long>();
|
||||
public Webui(JsonConfig setconfig, SecondBot setbot)
|
||||
{
|
||||
bot = setbot;
|
||||
siteconfig = setconfig;
|
||||
}
|
||||
protected KeyValuePair<bool, bool> logincookievaild(HttpListenerRequest reqs, HttpListenerResponse resp)
|
||||
protected KeyValuePair<bool, bool> Logincookievaild(HttpListenerResponse resp)
|
||||
{
|
||||
return logincookievaild(reqs, resp, false);
|
||||
return Logincookievaild(resp, false);
|
||||
}
|
||||
protected KeyValuePair<bool, bool> logincookievaild(HttpListenerRequest reqs, HttpListenerResponse resp, bool force_logout)
|
||||
protected KeyValuePair<bool, bool> Logincookievaild(HttpListenerResponse resp, bool force_logout)
|
||||
{
|
||||
foreach (Cookie C in resp.Cookies)
|
||||
{
|
||||
if (C.Name == "logincookie")
|
||||
{
|
||||
Cookie old = C;
|
||||
if (force_logout == true)
|
||||
{
|
||||
if (vaildlogincookies.ContainsKey(C.Value) == true)
|
||||
|
|
@ -61,7 +60,7 @@ namespace BetterSecondBot.HttpWebUi
|
|||
}
|
||||
return new KeyValuePair<bool, bool>(false, false);
|
||||
}
|
||||
public bool Post_process(json_http_reply reply, HttpListenerRequest reqs, HttpListenerResponse resp, List<string> args, Dictionary<string, string> post_args)
|
||||
public bool Post_process(Json_http_reply reply, HttpListenerResponse resp, List<string> args, Dictionary<string, string> post_args)
|
||||
{
|
||||
bool processed = false;
|
||||
if (args != null)
|
||||
|
|
@ -82,7 +81,7 @@ namespace BetterSecondBot.HttpWebUi
|
|||
{
|
||||
area = args[2];
|
||||
}
|
||||
KeyValuePair<bool, bool> logincheck = logincookievaild(reqs, resp);
|
||||
KeyValuePair<bool, bool> logincheck = Logincookievaild(resp);
|
||||
|
||||
if (logincheck.Key == false)
|
||||
{
|
||||
|
|
@ -99,9 +98,11 @@ namespace BetterSecondBot.HttpWebUi
|
|||
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);
|
||||
logincookie.Expires = DateTime.Now.AddDays(1);
|
||||
logincookie.Path = "/";
|
||||
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";
|
||||
|
|
@ -133,7 +134,7 @@ namespace BetterSecondBot.HttpWebUi
|
|||
// logged in
|
||||
if (mod == "logout")
|
||||
{
|
||||
logincookievaild(reqs, resp, true);
|
||||
Logincookievaild(resp, true);
|
||||
reply.message = "logged-out";
|
||||
reply.redirect = "/";
|
||||
reply.status = false;
|
||||
|
|
@ -356,7 +357,7 @@ namespace BetterSecondBot.HttpWebUi
|
|||
// login expired
|
||||
reply.message = "login-expired";
|
||||
reply.redirect = "/";
|
||||
logincookievaild(reqs, resp, true);
|
||||
Logincookievaild(resp, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -364,7 +365,7 @@ namespace BetterSecondBot.HttpWebUi
|
|||
}
|
||||
return !processed;
|
||||
}
|
||||
public string html_logged_in(string mod, string area)
|
||||
public string Html_logged_in(string mod, string area)
|
||||
{
|
||||
string layout = helpers.ReadResourceFile(Assembly.GetExecutingAssembly(), "sidemenu.layout");
|
||||
Dictionary<string, string> swaps = new Dictionary<string, string>();
|
||||
|
|
@ -387,7 +388,6 @@ namespace BetterSecondBot.HttpWebUi
|
|||
loop++;
|
||||
}
|
||||
swaps.Add("html_menu", menu);
|
||||
menu = "";
|
||||
if (mod == "none")
|
||||
{
|
||||
pagecontent = "<p>Please select a menu item on the left</p>";
|
||||
|
|
@ -428,7 +428,7 @@ namespace BetterSecondBot.HttpWebUi
|
|||
}
|
||||
return layout;
|
||||
}
|
||||
public string html_logged_out()
|
||||
public string Html_logged_out()
|
||||
{
|
||||
string layout = helpers.ReadResourceFile(Assembly.GetExecutingAssembly(), "full.layout");
|
||||
layout = layout.Replace("[[page_content]]", helpers.ReadResourceFile(Assembly.GetExecutingAssembly(), "login.block"));
|
||||
|
|
@ -438,7 +438,7 @@ namespace BetterSecondBot.HttpWebUi
|
|||
layout = layout.Replace("[[html_title]]", siteconfig.Basic_BotUserName);
|
||||
return layout;
|
||||
}
|
||||
public KeyValuePair<string, byte[]> Get_Process(HttpListenerRequest reqs, HttpListenerResponse resp, List<string> args)
|
||||
public KeyValuePair<string, byte[]> Get_Process(HttpListenerResponse resp, List<string> args)
|
||||
{
|
||||
|
||||
// get content
|
||||
|
|
@ -467,18 +467,18 @@ namespace BetterSecondBot.HttpWebUi
|
|||
}
|
||||
}
|
||||
// get display
|
||||
KeyValuePair<bool, bool> logincheck = logincookievaild(reqs, resp);
|
||||
KeyValuePair<bool, bool> logincheck = Logincookievaild(resp);
|
||||
if (logincheck.Key == true)
|
||||
{
|
||||
if (logincheck.Value == false)
|
||||
{
|
||||
logincookievaild(reqs, resp, true);
|
||||
Logincookievaild(resp, true);
|
||||
}
|
||||
}
|
||||
string reply_with = "";
|
||||
string reply_with;
|
||||
if (logincheck.Value == false)
|
||||
{
|
||||
reply_with = html_logged_out();
|
||||
reply_with = Html_logged_out();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -495,13 +495,13 @@ namespace BetterSecondBot.HttpWebUi
|
|||
|
||||
if (mod == "logout")
|
||||
{
|
||||
logincookievaild(reqs, resp, true);
|
||||
reply_with = html_logged_out();
|
||||
Logincookievaild(resp, true);
|
||||
reply_with = Html_logged_out();
|
||||
}
|
||||
else
|
||||
{
|
||||
// logged in
|
||||
reply_with = html_logged_in(mod, area);
|
||||
reply_with = Html_logged_in(mod, area);
|
||||
}
|
||||
}
|
||||
reply_with = reply_with.Replace("[[url_base]]", siteconfig.Http_PublicUrl);
|
||||
|
|
|
|||
|
|
@ -65,9 +65,9 @@ namespace BSB.Commands.Group
|
|||
{
|
||||
if (UUID.TryParse(args[0], out UUID target_group) == true)
|
||||
{
|
||||
if (UUID.TryParse(args[1], out UUID target_avatar) == true)
|
||||
if (UUID.TryParse(args[1], out UUID _) == true)
|
||||
{
|
||||
if (UUID.TryParse(args[2], out UUID target_role) == true)
|
||||
if (UUID.TryParse(args[2], out UUID _) == true)
|
||||
{
|
||||
if (bot.MyGroups.ContainsKey(target_group) == true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace BSB.Commands.Movement
|
|||
{
|
||||
if(UUID.TryParse(args[0],out UUID avatar) == true)
|
||||
{
|
||||
bot.add_uuid_to_teleport_list(avatar);
|
||||
bot.Add_uuid_to_teleport_list(avatar);
|
||||
bot.GetClient.Self.SendTeleportLureRequest(avatar, "I would like to teleport to you");
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,10 +45,8 @@ namespace BSB.bottypes
|
|||
|
||||
Rotate(logFilePath);
|
||||
|
||||
using (var sw = File.AppendText(logFilePath))
|
||||
{
|
||||
sw.WriteLine(message);
|
||||
}
|
||||
using var sw = File.AppendText(logFilePath);
|
||||
sw.WriteLine(message);
|
||||
}
|
||||
|
||||
private void Rotate(string filePath)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace BSB.bottypes
|
|||
{
|
||||
public abstract class MessageSwitcherBot : EventsBot
|
||||
{
|
||||
string[] hard_blocked_agents = new string[] { "secondlife", "second life"};
|
||||
readonly string[] hard_blocked_agents = new string[] { "secondlife", "second life"};
|
||||
protected override void ChatInputHandler(object sender, ChatEventArgs e)
|
||||
{
|
||||
bool fromme = false;
|
||||
|
|
@ -90,8 +90,10 @@ namespace BSB.bottypes
|
|||
if (bits.Count > 2)
|
||||
{
|
||||
arg_signed_with = "|||";
|
||||
List<string> newbits = new List<string>();
|
||||
newbits.Add(bits[0]);
|
||||
List<string> newbits = new List<string>
|
||||
{
|
||||
bits[0]
|
||||
};
|
||||
StringBuilder B = new StringBuilder();
|
||||
int loop = 1;
|
||||
string addon = "";
|
||||
|
|
@ -111,7 +113,7 @@ namespace BSB.bottypes
|
|||
}
|
||||
else
|
||||
{
|
||||
if (is_avatar_master(sender_name) == true)
|
||||
if (Is_avatar_master(sender_name) == true)
|
||||
{
|
||||
CoreCommandLib(sender_uuid, true, bits.ElementAt(0), bits.ElementAt(1), "", arg_signed_with);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue