From 109a34bf60964eb2aab376ef5ba21fffc56e120b Mon Sep 17 00:00:00 2001 From: Madpeterz <57852827+Madpeterz@users.noreply.github.com> Date: Thu, 25 Mar 2021 10:56:10 +0000 Subject: [PATCH] corrects some breaking bugs and cleans up a bit --- BetterSecondbot/BetterAtHome/BetterAtHome.cs | 56 +++++++-------- BetterSecondbot/DataStorage/Datastorage.cs | 30 ++++---- .../DiscordSupervisor/ChannelControl.cs | 6 +- .../DiscordSupervisor/Discord-super.cs | 6 +- .../DiscordSupervisor/DiscordEvents.cs | 20 +++--- BetterSecondbot/DiscordSupervisor/Inbound.cs | 20 +++--- BetterSecondbot/DiscordSupervisor/Values.cs | 68 +++++++++---------- BetterSecondbot/DiscordSupervisor/relay.cs | 16 ++--- BetterSecondbot/Tracking/BetterTracking.cs | 40 +++++------ BetterSecondbot/WikiMake/wikimake.cs | 2 +- Core/Commands/Animation.cs | 4 +- Core/Commands/Avatars.cs | 12 ++-- Core/Commands/Chat.cs | 4 +- Core/Commands/Core.cs | 6 +- Core/Commands/Estate.cs | 10 +-- Core/Commands/Friends.cs | 4 +- Core/Commands/Funds.cs | 6 +- Core/Commands/Group.cs | 16 ++--- Core/Commands/Home.cs | 4 +- Core/Commands/Im.cs | 12 ++-- Core/Commands/Info.cs | 32 ++++----- Core/Commands/Inventory.cs | 12 ++-- Core/Commands/Movement.cs | 4 +- Core/Commands/Parcel.cs | 16 ++--- Core/Commands/Self.cs | 20 +++--- Core/HttpService/HttpAsService.cs | 14 ++++ Shared/API/API_interface.cs | 8 +-- Shared/BotTypes/BasicBot.cs | 2 +- 28 files changed, 232 insertions(+), 218 deletions(-) diff --git a/BetterSecondbot/BetterAtHome/BetterAtHome.cs b/BetterSecondbot/BetterAtHome/BetterAtHome.cs index 3de1e1d..98f4db3 100644 --- a/BetterSecondbot/BetterAtHome/BetterAtHome.cs +++ b/BetterSecondbot/BetterAtHome/BetterAtHome.cs @@ -14,14 +14,14 @@ namespace BetterSecondbot.BetterAtHome protected JsonConfig configfile; - protected bool LoginFailed = false; + protected bool LoginFailed ; protected string whyfailed = ""; protected string whyloggedout = ""; protected bool LoggingIn = true; - protected bool LoggedIn = false; - protected bool StartingLogin = false; + protected bool LoggedIn; + protected bool StartingLogin; protected long LastLoginEvent = 0; - protected bool FiredAfterLogin = false; + protected bool FiredAfterLogin; protected int homeregionIndexer = 0; protected long LastTeleportEvent = 0; protected List homeRegions = new List(); @@ -43,11 +43,11 @@ namespace BetterSecondbot.BetterAtHome protected void attach_events() { - controler.Bot.ChangeSimEvent += ChangedSim; - controler.Bot.AlertMessage += AlertMessage; - controler.Bot.StatusMessageEvent += StatusPing; - controler.Bot.LoginProgess += LoginProcess; - controler.Bot.NextHomeRegion += NextHomeRegionRequest; + controler.getBot().ChangeSimEvent += ChangedSim; + controler.getBot().AlertMessage += AlertMessage; + controler.getBot().StatusMessageEvent += StatusPing; + controler.getBot().LoginProgess += LoginProcess; + controler.getBot().NextHomeRegion += NextHomeRegionRequest; } protected void resetSwitchs() @@ -108,7 +108,7 @@ namespace BetterSecondbot.BetterAtHome whyloggedout = "No control"; return false; } - if (controler.Bot == null) + if (controler.getBot() == null) { whyloggedout = "No Bot"; return false; @@ -122,12 +122,12 @@ namespace BetterSecondbot.BetterAtHome { return false; } - if (controler.Bot.GetClient == null) + if (controler.getBot().GetClient == null) { whyloggedout = "No client"; return false; } - if (controler.Bot.GetClient.Network == null) + if (controler.getBot().GetClient.Network == null) { whyloggedout = "No network"; return false; @@ -161,7 +161,7 @@ namespace BetterSecondbot.BetterAtHome return false; } whyloggedout = ""; - return controler.Bot.GetClient.Network.Connected; + return controler.getBot().GetClient.Network.Connected; } protected string lastwarn = ""; @@ -170,8 +170,8 @@ namespace BetterSecondbot.BetterAtHome { if(hasBasicBot() == true) { - //controler.Bot.SetBetterAtHomeAction(whyloggedout+" "+message); - controler.Bot.SetBetterAtHomeAction(message); + //controler.getBot().SetBetterAtHomeAction(whyloggedout+" "+message); + controler.getBot().SetBetterAtHomeAction(message); } /* * extra debug stuff @@ -214,9 +214,9 @@ namespace BetterSecondbot.BetterAtHome protected void ChangedSim(object o, SimChangedEventArgs e) { simname = ""; - if (controler.Bot.GetClient.Network.CurrentSim != null) + if (controler.getBot().GetClient.Network.CurrentSim != null) { - simname = controler.Bot.GetClient.Network.CurrentSim.Name; + simname = controler.getBot().GetClient.Network.CurrentSim.Name; } } @@ -269,7 +269,7 @@ namespace BetterSecondbot.BetterAtHome protected void LoggedOutActions() { SetBetterAtHomeAction("Logged Out Actions"); - if (controler.Bot.KillMe == true) + if (controler.getBot().KillMe == true) { SetBetterAtHomeAction("Marked for death"); return; @@ -311,13 +311,13 @@ namespace BetterSecondbot.BetterAtHome SetBetterAtHomeAction("[DC] Attempting login"); resetSwitchs(); StartingLogin = true; - controler.Bot.Start(); + controler.getBot().Start(); } protected void LoggedInAction() { SetBetterAtHomeAction("Logged In Actions"); - if (controler.Bot.KillMe == true) + if (controler.getBot().KillMe == true) { SetBetterAtHomeAction("Marked for death"); return; @@ -334,11 +334,11 @@ namespace BetterSecondbot.BetterAtHome SetBetterAtHomeAction("Waiting for Teleport lockout"); return; } - if ((simname == "") || (controler.Bot.GetClient.Self.SimPosition.Z == 0)) + if ((simname == "") || (controler.getBot().GetClient.Self.SimPosition.Z == 0)) { ChangedSim(null, null); } - if ((simname == "") || (controler.Bot.GetClient.Self.SimPosition.Z == 0)) + if ((simname == "") || (controler.getBot().GetClient.Self.SimPosition.Z == 0)) { void_counter++; SetBetterAtHomeAction("Void counter: " + void_counter.ToString()); @@ -353,8 +353,8 @@ namespace BetterSecondbot.BetterAtHome if (FiredAfterLogin == false) { FiredAfterLogin = true; - controler.Bot.AfterBotLoginHandler(); - controler.Bot.reconnect = true; + controler.getBot().AfterBotLoginHandler(); + controler.getBot().reconnect = true; SetBetterAtHomeAction("Starting after login events"); return; } @@ -365,7 +365,7 @@ namespace BetterSecondbot.BetterAtHome gotoNextHomeRegion(true); return; } - if (controler.Bot.TeleportStatus() == true) + if (controler.getBot().TeleportStatus() == true) { SetBetterAtHomeAction("Teleported"); return; @@ -415,18 +415,18 @@ namespace BetterSecondbot.BetterAtHome SetBetterAtHomeAction("Teleporting to home region: " + homeRegions[homeregionIndexer] + ""); LastTeleportEvent = helpers.UnixTimeNow(); - controler.Bot.TeleportWithSLurl(configfile.Basic_HomeRegions[homeregionIndexer]); + controler.getBot().TeleportWithSLurl(configfile.Basic_HomeRegions[homeregionIndexer]); } protected bool IsAtHome() { if ((simname == "") || (FiredAfterLogin == false)) { - if (controler.Bot.GetClient.Network.CurrentSim == null) + if (controler.getBot().GetClient.Network.CurrentSim == null) { return true; } - simname = controler.Bot.GetClient.Network.CurrentSim.Name; + simname = controler.getBot().GetClient.Network.CurrentSim.Name; } return homeRegions.Contains(simname); } diff --git a/BetterSecondbot/DataStorage/Datastorage.cs b/BetterSecondbot/DataStorage/Datastorage.cs index 2bd37b0..55245ef 100644 --- a/BetterSecondbot/DataStorage/Datastorage.cs +++ b/BetterSecondbot/DataStorage/Datastorage.cs @@ -17,23 +17,23 @@ namespace BetterSecondbot.DataStorage protected void attach_events() { - controler.Bot.ChangeSimEvent += ChangedSim; - controler.Bot.LoginProgess += LoginProcess; - controler.Bot.StatusMessageEvent += StatusPing; + controler.getBot().ChangeSimEvent += ChangedSim; + controler.getBot().LoginProgess += LoginProcess; + controler.getBot().StatusMessageEvent += StatusPing; } protected void StatusPing(object o, StatusMessageEvent e) { if(simname != "") { - if (controler.Bot.GetClient.Network.CurrentSim != null) + if (controler.getBot().GetClient.Network.CurrentSim != null) { - if (controler.Bot.GetClient.Network.CurrentSim.IsEstateManager == true) + if (controler.getBot().GetClient.Network.CurrentSim.IsEstateManager == true) { - long dif = helpers.UnixTimeNow() - controler.Bot._lastUpdatedSimBlacklist.lastupdated; + long dif = helpers.UnixTimeNow() - controler.getBot()._lastUpdatedSimBlacklist.lastupdated; if (dif > 120) { - controler.Bot.GetClient.Estate.RequestInfo(); + controler.getBot().GetClient.Estate.RequestInfo(); } } } @@ -50,7 +50,7 @@ namespace BetterSecondbot.DataStorage if(attachedClientEvents == false) { attachedClientEvents = true; - controler.Bot.GetClient.Estate.EstateBansReply += EstateBansReply; + controler.getBot().GetClient.Estate.EstateBansReply += EstateBansReply; } } @@ -58,15 +58,15 @@ namespace BetterSecondbot.DataStorage protected void ChangedSim(object o, SimChangedEventArgs e) { simname = ""; - if (controler.Bot.GetClient.Network.CurrentSim != null) + if (controler.getBot().GetClient.Network.CurrentSim != null) { - simname = controler.Bot.GetClient.Network.CurrentSim.Name; + simname = controler.getBot().GetClient.Network.CurrentSim.Name; } if(simname != "") { - if(controler.Bot.GetClient.Network.CurrentSim.IsEstateManager == true) + if(controler.getBot().GetClient.Network.CurrentSim.IsEstateManager == true) { - controler.Bot.GetClient.Estate.RequestInfo(); + controler.getBot().GetClient.Estate.RequestInfo(); } } } @@ -77,10 +77,10 @@ namespace BetterSecondbot.DataStorage working.lastupdated = helpers.UnixTimeNow(); foreach(UUID av in e.Banned) { - working.banned.Add(av,"lookup"); // controler.Bot.FindAvatarKey2Name(av) + working.banned.Add(av,"lookup"); // controler.getBot().FindAvatarKey2Name(av) } - working.regionname = controler.Bot.GetClient.Network.CurrentSim.Name; - controler.Bot.UpdateSimBlacklist(working); + working.regionname = controler.getBot().GetClient.Network.CurrentSim.Name; + controler.getBot().UpdateSimBlacklist(working); } } diff --git a/BetterSecondbot/DiscordSupervisor/ChannelControl.cs b/BetterSecondbot/DiscordSupervisor/ChannelControl.cs index 00db1d9..8424954 100644 --- a/BetterSecondbot/DiscordSupervisor/ChannelControl.cs +++ b/BetterSecondbot/DiscordSupervisor/ChannelControl.cs @@ -195,9 +195,9 @@ namespace BetterSecondBot.DiscordSupervisor } else if (sender_id == UUID.Zero.ToString()) { - if (controler.Bot != null) + if (controler.getBot() != null) { - display_topic = "" + myconfig.Basic_BotUserName + " #" + controler.Bot.MyVersion + ""; + display_topic = "" + myconfig.Basic_BotUserName + " #" + controler.getBot().MyVersion + ""; } } else if (channeltopictype == "Group") @@ -286,7 +286,7 @@ namespace BetterSecondBot.DiscordSupervisor if (HasBot() == true) { - foreach (Group G in controler.Bot.MyGroups.Values) + foreach (Group G in controler.getBot().MyGroups.Values) { string groupname = G.Name.ToLowerInvariant(); groupname = String.Concat(groupname.Where(char.IsLetterOrDigit)); diff --git a/BetterSecondbot/DiscordSupervisor/Discord-super.cs b/BetterSecondbot/DiscordSupervisor/Discord-super.cs index fe6279d..285197e 100644 --- a/BetterSecondbot/DiscordSupervisor/Discord-super.cs +++ b/BetterSecondbot/DiscordSupervisor/Discord-super.cs @@ -37,7 +37,7 @@ namespace BetterSecondBot.DiscordSupervisor LastStatusMessage = NewStatusMessage; if (HasBasicBot() == true) { - controler.Bot.Log2File(LogFormater.Status(LastStatusMessage, false), ConsoleLogLogLevel.Status); + controler.getBot().Log2File(LogFormater.Status(LastStatusMessage, false), ConsoleLogLogLevel.Status); } else { @@ -79,11 +79,11 @@ namespace BetterSecondBot.DiscordSupervisor if (controler != null) { unattach_events(); - controler.Bot.KillMePlease(); + controler.getBot().KillMePlease(); controler = null; } controler = new Cli(myconfig, running_as_docker, self_keep_alive); - controler.Bot.setDiscordClient(DiscordClient); + controler.getBot().setDiscordClient(DiscordClient); relayService = new BetterRelay(controler, this, running_as_docker); attach_events(); } diff --git a/BetterSecondbot/DiscordSupervisor/DiscordEvents.cs b/BetterSecondbot/DiscordSupervisor/DiscordEvents.cs index b1ea515..809690c 100644 --- a/BetterSecondbot/DiscordSupervisor/DiscordEvents.cs +++ b/BetterSecondbot/DiscordSupervisor/DiscordEvents.cs @@ -10,27 +10,27 @@ namespace BetterSecondBot.DiscordSupervisor protected StatusMessageEvent LastNetworkEventArgs = null; protected void attach_events() { - controler.Bot.MessageEvent += BotChatControlerHandler; - controler.Bot.StatusMessageEvent += StatusMessageHandler; - controler.Bot.GroupsReadyEvent += GroupsReadyHandler; - controler.Bot.SendImEvent += SendImHandler; + controler.getBot().MessageEvent += BotChatControlerHandler; + controler.getBot().StatusMessageEvent += StatusMessageHandler; + controler.getBot().GroupsReadyEvent += GroupsReadyHandler; + controler.getBot().SendImEvent += SendImHandler; } protected void unattach_events() { - controler.Bot.MessageEvent -= BotChatControlerHandler; - controler.Bot.StatusMessageEvent -= StatusMessageHandler; - controler.Bot.GroupsReadyEvent -= GroupsReadyHandler; - controler.Bot.SendImEvent -= SendImHandler; + controler.getBot().MessageEvent -= BotChatControlerHandler; + controler.getBot().StatusMessageEvent -= StatusMessageHandler; + controler.getBot().GroupsReadyEvent -= GroupsReadyHandler; + controler.getBot().SendImEvent -= SendImHandler; } protected void SendImHandler(object sender, ImSendArgs e) { - if (controler.Bot.AvatarKey2Name.ContainsKey(e.avataruuid) == true) + if (controler.getBot().AvatarKey2Name.ContainsKey(e.avataruuid) == true) { if (DiscordClientConnected == true) { - _ = SendMessageToChannelAsync(controler.Bot.AvatarKey2Name[e.avataruuid], "Bot/Script: " + e.message + "", "im", e.avataruuid, "IM").ConfigureAwait(false); + _ = SendMessageToChannelAsync(controler.getBot().AvatarKey2Name[e.avataruuid], "Bot/Script: " + e.message + "", "im", e.avataruuid, "IM").ConfigureAwait(false); } } } diff --git a/BetterSecondbot/DiscordSupervisor/Inbound.cs b/BetterSecondbot/DiscordSupervisor/Inbound.cs index efbfe5d..4a30a5e 100644 --- a/BetterSecondbot/DiscordSupervisor/Inbound.cs +++ b/BetterSecondbot/DiscordSupervisor/Inbound.cs @@ -47,7 +47,7 @@ namespace BetterSecondBot.DiscordSupervisor if (HasBot() == true) { IGuildUser user = (IGuildUser)message.Author; - controler.Bot.GetClient.Self.Chat(message.Content, 0, ChatType.Normal); + controler.getBot().GetClient.Self.Chat(message.Content, 0, ChatType.Normal); return await MarkMessage(message, "✅"); } return await MarkMessage(message, "❌"); @@ -69,7 +69,7 @@ namespace BetterSecondBot.DiscordSupervisor { return await MarkMessage(message, "❌"); } - controler.Bot.KillMePlease(); + controler.getBot().KillMePlease(); controler = null; return await MarkMessage(message, "✅").ConfigureAwait(false); } @@ -77,8 +77,8 @@ namespace BetterSecondBot.DiscordSupervisor { if (HasBot() == true) { - controler.Bot.KillMePlease(); - controler.Bot.GetClient.Network.Logout(); + controler.getBot().KillMePlease(); + controler.getBot().GetClient.Network.Logout(); } exit_super = true; return await MarkMessage(message, "✅").ConfigureAwait(false); @@ -92,7 +92,7 @@ namespace BetterSecondBot.DiscordSupervisor { if (message.Content == "!commands") { - string[] commands = controler.Bot.getFullListOfCommands(); + string[] commands = controler.getBot().getFullListOfCommands(); await SendMessageToChannelAsync("interface", string.Join("\n",commands)+ " \n For more details please see the wiki \n https://wiki.magicmadpeter.xyz/", "bot", UUID.Zero, "bot"); } else @@ -116,9 +116,9 @@ namespace BetterSecondBot.DiscordSupervisor { args = bits[1]; } - if (controler.Bot.GetFullListOfCommandsWithCustoms().Contains(bits[0].ToLowerInvariant()) == true) + if (controler.getBot().GetFullListOfCommandsWithCustoms().Contains(bits[0].ToLowerInvariant()) == true) { - controler.Bot.CallAPI(bits[0], args.Split("~#~"), target); + controler.getBot().CallAPI(bits[0], args.Split("~#~"), target); await MarkMessage(message, "✅").ConfigureAwait(false); } else @@ -175,7 +175,7 @@ namespace BetterSecondBot.DiscordSupervisor { if (UUID.TryParse(bits[1], out UUID group) == true) { - if (controler.Bot.MyGroups.ContainsKey(group) == true) + if (controler.getBot().MyGroups.ContainsKey(group) == true) { if (message.Content == "!clear") { @@ -197,13 +197,13 @@ namespace BetterSecondBot.DiscordSupervisor } Noticetitle = Noticetitle.Replace("!notice ", ""); Noticetitle = Noticetitle.Trim(); - controler.Bot.CallAPI("Groupnotice", new [] { Noticetitle, Noticemessage }); + controler.getBot().CallAPI("Groupnotice", new [] { Noticetitle, Noticemessage }); await MarkMessage(message, "✅"); } else { IGuildUser user = (IGuildUser)message.Author; - controler.Bot.CallAPI("Groupchat", new [] { group.ToString(), message.Content }); + controler.getBot().CallAPI("Groupchat", new [] { group.ToString(), message.Content }); await MarkMessage(message, "✅"); } } diff --git a/BetterSecondbot/DiscordSupervisor/Values.cs b/BetterSecondbot/DiscordSupervisor/Values.cs index 090a672..4f86b7b 100644 --- a/BetterSecondbot/DiscordSupervisor/Values.cs +++ b/BetterSecondbot/DiscordSupervisor/Values.cs @@ -1,29 +1,29 @@ using BetterSecondBotShared.Json; -using Discord; -using Discord.WebSocket; -using System.Collections.Generic; - -namespace BetterSecondBot.DiscordSupervisor -{ - public abstract class DiscordValues - { - protected JsonConfig myconfig; - protected bool exit_super = false; - protected Cli controler; - protected bool running_as_docker = false; - - protected bool discord_group_relay; - protected DiscordSocketClient DiscordClient; - protected bool DiscordClientConnected; - - protected IGuild DiscordServer; - protected string LastSendDiscordStatus = ""; - protected long DiscordUnixTimeOnine; - protected bool DiscordLock; - protected string LastStatusMessage = ""; - - protected Dictionary catmap = new Dictionary(); - +using Discord; +using Discord.WebSocket; +using System.Collections.Generic; + +namespace BetterSecondBot.DiscordSupervisor +{ + public abstract class DiscordValues + { + protected JsonConfig myconfig; + protected bool exit_super = false; + protected Cli controler; + protected bool running_as_docker = false; + + protected bool discord_group_relay; + protected DiscordSocketClient DiscordClient; + protected bool DiscordClientConnected; + + protected IGuild DiscordServer; + protected string LastSendDiscordStatus = ""; + protected long DiscordUnixTimeOnine; + protected bool DiscordLock; + protected string LastStatusMessage = ""; + + protected Dictionary catmap = new Dictionary(); + protected virtual void login_bot(bool self_keepalive) { @@ -38,20 +38,20 @@ namespace BetterSecondBot.DiscordSupervisor { if (HasBasicBot() == true) { - return controler.Bot.GetClient.Network.Connected; + return controler.getBot().GetClient.Network.Connected; } return false; - } - + } + protected bool HasBasicBot() { if (controler != null) { - if (controler.Bot != null) + if (controler.getBot() != null) { - if (controler.Bot.GetClient != null) + if (controler.getBot().GetClient != null) { - if (controler.Bot.GetClient.Network != null) + if (controler.getBot().GetClient.Network != null) { return true; } @@ -59,6 +59,6 @@ namespace BetterSecondBot.DiscordSupervisor } } return false; - } - } -} + } + } +} diff --git a/BetterSecondbot/DiscordSupervisor/relay.cs b/BetterSecondbot/DiscordSupervisor/relay.cs index e7a78e0..0b66039 100644 --- a/BetterSecondbot/DiscordSupervisor/relay.cs +++ b/BetterSecondbot/DiscordSupervisor/relay.cs @@ -11,7 +11,7 @@ namespace BetterSecondBot.DiscordSupervisor { if (HasBot() == true) { - controler.Bot.SendIM(avatar, message); + controler.getBot().SendIM(avatar, message); } } protected async Task DiscordGroupMessage(UUID group_uuid, string sender_name, string message) @@ -20,9 +20,9 @@ namespace BetterSecondBot.DiscordSupervisor { if ((helpers.notempty(sender_name) == true) && (helpers.notempty(message) == true)) { - if (controler.Bot.MyGroups.ContainsKey(group_uuid) == true) + if (controler.getBot().MyGroups.ContainsKey(group_uuid) == true) { - await SendMessageToChannelAsync(controler.Bot.MyGroups[group_uuid].Name, "" + sender_name + ": " + message + "", "group", group_uuid, "Group").ConfigureAwait(false); + await SendMessageToChannelAsync(controler.getBot().MyGroups[group_uuid].Name, "" + sender_name + ": " + message + "", "group", group_uuid, "Group").ConfigureAwait(false); } } } @@ -44,7 +44,7 @@ namespace BetterSecondBot.DiscordSupervisor { if (HasBot() == true) { - string output = controler.Bot.CommandHistoryAdd(command, arg, status, WhyFailed); + string output = controler.getBot().CommandHistoryAdd(command, arg, status, WhyFailed); if (output != "") { _ = SendMessageToChannelAsync("interface", output, "bot", UUID.Zero, "bot"); @@ -68,24 +68,24 @@ namespace BetterSecondBot.DiscordSupervisor { if (group == true) { - controler.Bot.Debug("DiscordBotChatControler - GroupChat:(" + group_uuid.ToString() + " -> " + sender_name + ":" + message); + controler.getBot().Debug("DiscordBotChatControler - GroupChat:(" + group_uuid.ToString() + " -> " + sender_name + ":" + message); await DiscordGroupMessage(group_uuid, sender_name, message).ConfigureAwait(false); } else { - controler.Bot.Debug("DiscordBotChatControler - IM:" + sender_name + ":" + message); + controler.getBot().Debug("DiscordBotChatControler - IM:" + sender_name + ":" + message); await DiscordIMMessage(sender_uuid, sender_name, message).ConfigureAwait(false); } } else { - controler.Bot.Debug("DiscordBotChatControler - Localchat:" + sender_name + ":" + message); + controler.getBot().Debug("DiscordBotChatControler - Localchat:" + sender_name + ":" + message); await SendMessageToChannelAsync("localchat", "" + sender_name + ": " + message, "bot", UUID.Zero, "bot").ConfigureAwait(false); } } else { - controler.Bot.Debug("DiscordBotChatControler - Not from an avatar"); + controler.getBot().Debug("DiscordBotChatControler - Not from an avatar"); } } } diff --git a/BetterSecondbot/Tracking/BetterTracking.cs b/BetterSecondbot/Tracking/BetterTracking.cs index cdec02d..cbdae79 100644 --- a/BetterSecondbot/Tracking/BetterTracking.cs +++ b/BetterSecondbot/Tracking/BetterTracking.cs @@ -28,17 +28,17 @@ namespace BetterSecondbot.Tracking public BetterTracking(Cli setcontroler) { controler = setcontroler; - if(controler.Bot.getMyConfig.Setting_Tracker.ToLowerInvariant() == "false") + if(controler.getBot().getMyConfig.Setting_Tracker.ToLowerInvariant() == "false") { LogFormater.Info("Tracker - Disabled because set to false"); return; } - if(int.TryParse(controler.Bot.getMyConfig.Setting_Tracker,out output_channel) == true) + if(int.TryParse(controler.getBot().getMyConfig.Setting_Tracker,out output_channel) == true) { output_to_channel = true; attachEvents(); } - else if (controler.Bot.getMyConfig.Setting_Tracker.StartsWith("http") == true) + else if (controler.getBot().getMyConfig.Setting_Tracker.StartsWith("http") == true) { output_to_url = true; attachEvents(); @@ -51,7 +51,7 @@ namespace BetterSecondbot.Tracking protected void attachEvents() { LogFormater.Info("Tracker - Connected to login process event"); - controler.Bot.LoginProgess += LoginProcess; + controler.getBot().LoginProgess += LoginProcess; } protected void LoginProcess(object o, LoginProgressEventArgs e) @@ -59,7 +59,7 @@ namespace BetterSecondbot.Tracking if(e.Status == LoginStatus.ConnectingToSim) { LogFormater.Info("Tracker - disconnected from login process event"); - controler.Bot.LoginProgess -= LoginProcess; + controler.getBot().LoginProgess -= LoginProcess; if (AfterLogin == false) { AfterLogin = true; @@ -69,10 +69,10 @@ namespace BetterSecondbot.Tracking } if (output_to_url == true) { - LogFormater.Info("Tracker - Enabled HTTP: " + controler.Bot.getMyConfig.Setting_Tracker); + LogFormater.Info("Tracker - Enabled HTTP: " + controler.getBot().getMyConfig.Setting_Tracker); } - controler.Bot.StatusMessageEvent += StatusPing; - //controler.Bot.GetClient.Grid.CoarseLocationUpdate += LocationUpdate; + controler.getBot().StatusMessageEvent += StatusPing; + //controler.getBot().GetClient.Grid.CoarseLocationUpdate += LocationUpdate; } } } @@ -83,28 +83,28 @@ namespace BetterSecondbot.Tracking { return false; } - if (controler.Bot == null) + if (controler.getBot() == null) { return false; } - if (controler.Bot.GetClient == null) + if (controler.getBot().GetClient == null) { return false; } - if (controler.Bot.GetClient.Network == null) + if (controler.getBot().GetClient.Network == null) { return false; } - return controler.Bot.GetClient.Network.Connected; + return controler.getBot().GetClient.Network.Connected; } protected void StatusPing(object o, StatusMessageEvent e) { if(hasBot() == true) { - if(controler.Bot.GetClient.Network.CurrentSim != null) + if(controler.getBot().GetClient.Network.CurrentSim != null) { - Dictionary entrys = controler.Bot.GetClient.Network.CurrentSim.AvatarPositions.Copy(); + Dictionary entrys = controler.getBot().GetClient.Network.CurrentSim.AvatarPositions.Copy(); List avs = entrys.Keys.ToList(); List seenavs = new List(); foreach (UUID A in avs) @@ -139,7 +139,7 @@ namespace BetterSecondbot.Tracking string output = av.ToString() + "|||" + mode; if (output_to_channel == true) { - controler.Bot.GetClient.Self.Chat(output, output_channel, ChatType.Normal); + controler.getBot().GetClient.Self.Chat(output, output_channel, ChatType.Normal); } if(output_to_url == true) { @@ -159,7 +159,7 @@ namespace BetterSecondbot.Tracking var content = new FormUrlEncodedContent(values); try { - HTTPclient.PostAsync(controler.Bot.getMyConfig.Setting_Tracker, content); + HTTPclient.PostAsync(controler.getBot().getMyConfig.Setting_Tracker, content); } catch (Exception e) { @@ -174,12 +174,12 @@ namespace BetterSecondbot.Tracking if (AvatarSeen.ContainsKey(avuuid) == false) { addToSeen(avuuid); - string name = controler.Bot.FindAvatarKey2Name(avuuid); + string name = controler.getBot().FindAvatarKey2Name(avuuid); int loop = 0; while ((loop < 32) && (name == "lookup")) { Thread.Sleep(500); - name = controler.Bot.FindAvatarKey2Name(avuuid); + name = controler.getBot().FindAvatarKey2Name(avuuid); loop++; } output(avuuid, "entry###" + name); @@ -217,12 +217,12 @@ namespace BetterSecondbot.Tracking { if (AvatarSeen.ContainsKey(avuuid) == true) { - string name = controler.Bot.FindAvatarKey2Name(avuuid); + string name = controler.getBot().FindAvatarKey2Name(avuuid); int loop = 0; while ((loop < 32) && (name == "lookup")) { Thread.Sleep(500); - name = controler.Bot.FindAvatarKey2Name(avuuid); + name = controler.getBot().FindAvatarKey2Name(avuuid); loop++; } if (AvatarSeen.ContainsKey(avuuid) == true) diff --git a/BetterSecondbot/WikiMake/wikimake.cs b/BetterSecondbot/WikiMake/wikimake.cs index 47b50c4..7e4383c 100644 --- a/BetterSecondbot/WikiMake/wikimake.cs +++ b/BetterSecondbot/WikiMake/wikimake.cs @@ -628,7 +628,7 @@ namespace BetterSecondBot.WikiMake } } } - return new [] { }; + return new string[] { }; } diff --git a/Core/Commands/Animation.cs b/Core/Commands/Animation.cs index 9faedd3..2dba806 100644 --- a/Core/Commands/Animation.cs +++ b/Core/Commands/Animation.cs @@ -69,10 +69,10 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "animation", "resetanimations", handleGetClientIP()) == false) { - return BasicReply("Token not accepted", "resetanimations", new [] { }); + return BasicReply("Token not accepted", "resetanimations"); } bot.ResetAnimations(); - return BasicReply("Accepted", "resetanimations", new [] { }); + return BasicReply("Accepted", "resetanimations"); } } diff --git a/Core/Commands/Avatars.cs b/Core/Commands/Avatars.cs index 3b79668..7837d68 100644 --- a/Core/Commands/Avatars.cs +++ b/Core/Commands/Avatars.cs @@ -24,11 +24,11 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "avatars", "nearmewithdetails", handleGetClientIP()) == false) { - return BasicReply("Token not accepted", "nearmewithdetails", new [] { }); + return BasicReply("Token not accepted", "nearmewithdetails"); } if (bot.GetClient.Network.CurrentSim == null) { - return BasicReply("Error not in a sim", "nearmewithdetails", new [] { }); + return BasicReply("Error not in a sim", "nearmewithdetails"); } List BetterNearMe = new List(); Dictionary avcopy = bot.GetClient.Network.CurrentSim.ObjectsAvatars.Copy(); @@ -46,7 +46,7 @@ namespace BetterSecondBot.HttpService BetterNearMe.Add(details); } } - return BasicReply(JsonConvert.SerializeObject(BetterNearMe), "nearmewithdetails", new [] { }); + return BasicReply(JsonConvert.SerializeObject(BetterNearMe), "nearmewithdetails"); } [About("returns a list of all known avatars nearby")] @@ -57,11 +57,11 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "avatars", "nearme", handleGetClientIP()) == false) { - return BasicReply("Token not accepted", "nearme", new [] { }); + return BasicReply("Token not accepted", "nearme"); } if (bot.GetClient.Network.CurrentSim == null) { - return BasicReply("Error not in a sim", "nearme", new [] { }); + return BasicReply("Error not in a sim", "nearme"); } Dictionary NearMe = new Dictionary(); Dictionary avcopy = bot.GetClient.Network.CurrentSim.ObjectsAvatars.Copy(); @@ -72,7 +72,7 @@ namespace BetterSecondBot.HttpService NearMe.Add(av.ID, av.Name); } } - return BasicReply(JsonConvert.SerializeObject(NearMe), "nearme", new [] { }); + return BasicReply(JsonConvert.SerializeObject(NearMe), "nearme"); } } } diff --git a/Core/Commands/Chat.cs b/Core/Commands/Chat.cs index 8b05bb9..afe5116 100644 --- a/Core/Commands/Chat.cs +++ b/Core/Commands/Chat.cs @@ -23,9 +23,9 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "chat", "LocalChatHistory", handleGetClientIP()) == false) { - return Failure("Token not accepted", "LocalChatHistory", new [] { }); + return Failure("Token not accepted", "LocalChatHistory"); } - return BasicReply(JsonConvert.SerializeObject(bot.getLocalChatHistory()), "LocalChatHistory", new [] { }); + return BasicReply(JsonConvert.SerializeObject(bot.getLocalChatHistory()), "LocalChatHistory"); } [About("sends a message to localchat")] diff --git a/Core/Commands/Core.cs b/Core/Commands/Core.cs index ac97f9b..9762345 100644 --- a/Core/Commands/Core.cs +++ b/Core/Commands/Core.cs @@ -51,7 +51,7 @@ namespace BetterSecondBot.HttpService [Route(HttpVerbs.Get, "/Hello")] public object Hello() { - return BasicReply("world", "Hello", new [] { }); + return BasicReply("world", "Hello"); } [About("Delays a thead by X ms
Mostly pointless but good if your doing custom commands")] @@ -80,9 +80,9 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "core", "LogoutUI", handleGetClientIP()) == false) { - return Failure("Token not accepted", "LogoutUI", new [] { }); + return Failure("Token not accepted", "LogoutUI"); } - SuccessNoReturn("LogoutUI", new [] { }); + SuccessNoReturn("LogoutUI"); return tokens.Expire(token); } } diff --git a/Core/Commands/Estate.cs b/Core/Commands/Estate.cs index 5f5af8d..cf241df 100644 --- a/Core/Commands/Estate.cs +++ b/Core/Commands/Estate.cs @@ -102,15 +102,15 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "estate", "EstateParcelReclaim", handleGetClientIP()) == false) { - return Failure("Token not accepted", "EstateParcelReclaim", new [] { }); + return Failure("Token not accepted", "EstateParcelReclaim"); } if (bot.GetClient.Network.CurrentSim.IsEstateManager == false) { - return Failure("Not an estate manager here", "EstateParcelReclaim", new [] { }); + return Failure("Not an estate manager here", "EstateParcelReclaim"); } int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition); bot.GetClient.Parcels.Reclaim(bot.GetClient.Network.CurrentSim, localid); - return BasicReply("ok", "EstateParcelReclaim", new [] { }); + return BasicReply("ok", "EstateParcelReclaim"); } [About("Reclaims ownership of the current parcel")] @@ -142,9 +142,9 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "estate", "banlist", handleGetClientIP()) == false) { - return Failure("Token not accepted", "banlist", new [] { }); + return Failure("Token not accepted", "banlist"); } - return BasicReply(JsonConvert.SerializeObject(bot._lastUpdatedSimBlacklist), "banlist", new [] { }); + return BasicReply(JsonConvert.SerializeObject(bot._lastUpdatedSimBlacklist), "banlist"); } [About("Attempts to add/remove the avatar to/from the Estate banlist")] diff --git a/Core/Commands/Friends.cs b/Core/Commands/Friends.cs index 9d5853d..da531c1 100644 --- a/Core/Commands/Friends.cs +++ b/Core/Commands/Friends.cs @@ -23,9 +23,9 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "friends", "Friendslist", handleGetClientIP()) == false) { - return Failure("Token not accepted", "Friendslist", new [] { }); + return Failure("Token not accepted", "Friendslist"); } - return BasicReply(bot.getJsonFriendlist(), "Friendslist", new [] { }); + return BasicReply(bot.getJsonFriendlist(), "Friendslist"); } [About("Updates the friend perms for avatar avatar to State \n if true grants (Online/Map/Modify) perms")] diff --git a/Core/Commands/Funds.cs b/Core/Commands/Funds.cs index d1a2271..d997353 100644 --- a/Core/Commands/Funds.cs +++ b/Core/Commands/Funds.cs @@ -24,14 +24,14 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "funds", "Balance", handleGetClientIP()) == false) { - return Failure("Token not accepted", "Balance", new [] { }); + return Failure("Token not accepted", "Balance"); } if (bot.GetAllowFunds == false) { - return Failure("Funds commands are disabled", "Balance", new [] { }); + return Failure("Funds commands are disabled", "Balance"); } bot.GetClient.Self.RequestBalance(); - return BasicReply(bot.GetClient.Self.Balance.ToString(), "Balance", new [] { }); + return BasicReply(bot.GetClient.Self.Balance.ToString(), "Balance"); } [About("Makes the bot pay a avatar")] diff --git a/Core/Commands/Group.cs b/Core/Commands/Group.cs index 46d766c..ba34e57 100644 --- a/Core/Commands/Group.cs +++ b/Core/Commands/Group.cs @@ -453,14 +453,14 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "groups", "GetGroupList", handleGetClientIP()) == false) { - return Failure("Token not accepted", "GetGroupList", new [] {}); + return Failure("Token not accepted", "GetGroupList"); } Dictionary grouppackage = new Dictionary(); foreach (KeyValuePair entry in bot.MyGroups) { grouppackage.Add(entry.Value.ID.ToString(), entry.Value.Name); } - return BasicReply(JsonConvert.SerializeObject(grouppackage), "GetGroupList", new [] { }); + return BasicReply(JsonConvert.SerializeObject(grouppackage), "GetGroupList"); } [About("Requests the roles for the selected group
Replys with GroupRoleDetails object formated as follows
  • UpdateUnderway (Bool)
  • RoleDataAge (Int) [default -1]
  • Roles (KeyPair array of UUID=Name)

")] @@ -523,9 +523,9 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "groups", "GroupchatListAllUnreadGroups", handleGetClientIP()) == false) { - return Failure("Token not accepted", "GroupchatListAllUnreadGroups", new [] { }); + return Failure("Token not accepted", "GroupchatListAllUnreadGroups"); } - return BasicReply(JsonConvert.SerializeObject(bot.UnreadGroupchatGroups()), "GroupchatListAllUnreadGroups", new [] { }); + return BasicReply(JsonConvert.SerializeObject(bot.UnreadGroupchatGroups()), "GroupchatListAllUnreadGroups"); } [About("fetchs a list of all groups with unread messages")] @@ -561,9 +561,9 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "groups", "GroupchatAnyUnread", handleGetClientIP()) == false) { - return Failure("Token not accepted", "GroupchatAnyUnread", new [] { }); + return Failure("Token not accepted", "GroupchatAnyUnread"); } - return BasicReply(bot.HasUnreadGroupchats().ToString(), "GroupchatAnyUnread", new [] { }); + return BasicReply(bot.HasUnreadGroupchats().ToString(), "GroupchatAnyUnread"); } [About("Clears all group chat buffers at once")] @@ -573,10 +573,10 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "groups", "GroupchatClearAll", handleGetClientIP()) == false) { - return Failure("Token not accepted", "GroupchatClearAll", new [] { }); + return Failure("Token not accepted", "GroupchatClearAll"); } bot.ClearAllGroupchat(); - return BasicReply("ok", "GroupchatClearAll", new [] { }); + return BasicReply("ok", "GroupchatClearAll"); } [About("fetchs the groupchat history")] diff --git a/Core/Commands/Home.cs b/Core/Commands/Home.cs index 5c10014..57cc97d 100644 --- a/Core/Commands/Home.cs +++ b/Core/Commands/Home.cs @@ -23,10 +23,10 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "home", "GoHome", handleGetClientIP()) == false) { - return Failure("Token not accepted", "GoHome", new [] { }); + return Failure("Token not accepted", "GoHome"); } bot.GotoNextHomeRegion(); - return BasicReply("ok", "GoHome", new [] { }); + return BasicReply("ok", "GoHome"); } } diff --git a/Core/Commands/Im.cs b/Core/Commands/Im.cs index 38cb5ef..ca85c70 100644 --- a/Core/Commands/Im.cs +++ b/Core/Commands/Im.cs @@ -22,9 +22,9 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "im", "chatwindows", handleGetClientIP()) == false) { - return BasicReply("Token not accepted", "chatwindows", new [] { }); + return BasicReply("Token not accepted", "chatwindows"); } - return BasicReply(JsonConvert.SerializeObject(bot.GetIMChatWindowKeyNames()), "chatwindows", new [] { }); + return BasicReply(JsonConvert.SerializeObject(bot.GetIMChatWindowKeyNames()), "chatwindows"); } [About("gets a list of chat windows with unread messages")] @@ -34,7 +34,7 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "im", "listwithunread", handleGetClientIP()) == false) { - return BasicReply("Token not accepted", "listwithunread", new [] { }); + return BasicReply("Token not accepted", "listwithunread"); } List unreadimwindows = new List(); foreach (UUID window in bot.IMChatWindows()) @@ -44,7 +44,7 @@ namespace BetterSecondBot.HttpService unreadimwindows.Add(window); } } - return BasicReply(JsonConvert.SerializeObject(unreadimwindows), "listwithunread", new [] { }); + return BasicReply(JsonConvert.SerializeObject(unreadimwindows), "listwithunread"); } [About("gets if there are any unread im messages at all")] @@ -54,7 +54,7 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "im", "haveunreadims", handleGetClientIP()) == false) { - return BasicReply("Token not accepted", "haveunreadims", new [] { }); + return BasicReply("Token not accepted", "haveunreadims"); } bool reply = false; foreach (UUID window in bot.IMChatWindows()) @@ -65,7 +65,7 @@ namespace BetterSecondBot.HttpService break; } } - return BasicReply(reply.ToString(), "haveunreadims", new [] { }); + return BasicReply(reply.ToString(), "haveunreadims"); } [About("gets the chat from the selected window")] diff --git a/Core/Commands/Info.cs b/Core/Commands/Info.cs index 2628577..95a207d 100644 --- a/Core/Commands/Info.cs +++ b/Core/Commands/Info.cs @@ -23,9 +23,9 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "info", "Version", handleGetClientIP()) == false) { - return Failure("Token not accepted", "Version", new [] { }); + return Failure("Token not accepted", "Version"); } - return BasicReply(bot.MyVersion, "Version", new [] { }); + return BasicReply(bot.MyVersion, "Version"); } @@ -36,9 +36,9 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "info", "Name", handleGetClientIP()) == false) { - return Failure("Token not accepted", "Name", new [] { }); + return Failure("Token not accepted", "Name"); } - return BasicReply(bot.GetClient.Self.FirstName + " " + bot.GetClient.Self.LastName, "Name", new [] { }); + return BasicReply(bot.GetClient.Self.FirstName + " " + bot.GetClient.Self.LastName, "Name"); } [About("Fetchs the current parcels name")] @@ -50,18 +50,18 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "info", "ParcelName", handleGetClientIP()) == false) { - return Failure("Token not accepted", "ParcelName", new [] { }); + return Failure("Token not accepted", "ParcelName"); } if (bot.GetClient.Network.CurrentSim == null) { - return Failure("Error not in a sim", "ParcelName", new [] { }); + return Failure("Error not in a sim", "ParcelName"); } int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition); if (bot.GetClient.Network.CurrentSim.Parcels.ContainsKey(localid) == false) { - return Failure("Error parcel not found", "ParcelName", new [] { }); + return Failure("Error parcel not found", "ParcelName"); } - return BasicReply(bot.GetClient.Network.CurrentSim.Parcels[localid].Name, "ParcelName", new [] { }); + return BasicReply(bot.GetClient.Network.CurrentSim.Parcels[localid].Name, "ParcelName"); } [About("Requests the current unixtime at the bot")] @@ -71,9 +71,9 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "info", "UnixTimeNow", handleGetClientIP()) == false) { - return Failure("Token not accepted", "UnixTimeNow", new [] { }); + return Failure("Token not accepted", "UnixTimeNow"); } - return BasicReply(helpers.UnixTimeNow().ToString(), "UnixTimeNow", new [] { }); + return BasicReply(helpers.UnixTimeNow().ToString(), "UnixTimeNow"); } [About("Fetchs the current region name")] @@ -84,13 +84,13 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "info", "SimName", handleGetClientIP()) == false) { - return Failure("Token not accepted", "SimName", new [] { }); + return Failure("Token not accepted", "SimName"); } if (bot.GetClient.Network.CurrentSim == null) { - return Failure("Error not in a sim", "SimName", new [] { }); + return Failure("Error not in a sim", "SimName"); } - return BasicReply(bot.GetClient.Network.CurrentSim.Name, "SimName", new [] { }); + return BasicReply(bot.GetClient.Network.CurrentSim.Name, "SimName"); } [About("Fetchs the current location of the bot")] @@ -101,17 +101,17 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "info", "GetPosition", handleGetClientIP()) == false) { - return Failure("Token not accepted", "GetPosition", new [] { }); + return Failure("Token not accepted", "GetPosition"); } if (bot.GetClient.Network.CurrentSim == null) { - return Failure("Error not in a sim", "GetPosition", new [] { }); + return Failure("Error not in a sim", "GetPosition"); } Dictionary pos = new Dictionary(); pos.Add("x", (int)Math.Round(bot.GetClient.Self.SimPosition.X)); pos.Add("y", (int)Math.Round(bot.GetClient.Self.SimPosition.Y)); pos.Add("z", (int)Math.Round(bot.GetClient.Self.SimPosition.Z)); - return BasicReply(JsonConvert.SerializeObject(pos), "GetPosition", new [] { }); + return BasicReply(JsonConvert.SerializeObject(pos), "GetPosition"); } } } diff --git a/Core/Commands/Inventory.cs b/Core/Commands/Inventory.cs index e0494e0..43a5494 100644 --- a/Core/Commands/Inventory.cs +++ b/Core/Commands/Inventory.cs @@ -228,7 +228,7 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "inventory", "InventoryPurgeNotecards", handleGetClientIP()) == false) { - return Failure("Token not accepted", "InventoryPurgeNotecards", new [] { }); + return Failure("Token not accepted", "InventoryPurgeNotecards"); } List T = bot.GetClient.Inventory.Store.GetContents(bot.GetClient.Inventory.Store.RootFolder); InventoryBase NotecardFolder = null; @@ -242,7 +242,7 @@ namespace BetterSecondBot.HttpService } if (NotecardFolder != null) { - return Failure("Unable to find notecard folder", "InventoryPurgeNotecards", new [] { }); + return Failure("Unable to find notecard folder", "InventoryPurgeNotecards"); } List purge_notecards = new List(); List contents = bot.GetClient.Inventory.FolderContents(NotecardFolder.UUID, bot.GetClient.Self.AgentID, true, true, InventorySortOrder.ByDate, 40 * 1000); @@ -262,7 +262,7 @@ namespace BetterSecondBot.HttpService { bot.GetClient.Inventory.Remove(purge_notecards, new List()); } - return BasicReply("Ok", "InventoryPurgeNotecards", new [] { }); + return BasicReply("Ok", "InventoryPurgeNotecards"); } [About("converts a inventory uuid to a realworld uuid
Needed for texture preview")] @@ -425,11 +425,11 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "inventory", "InventoryFolders", handleGetClientIP()) == false) { - return Failure("Token not accepted", "InventoryFolders", new [] { }); + return Failure("Token not accepted", "InventoryFolders"); } string reply = HelperInventory.MapFolderJson(bot); - if (reply != null) return BasicReply(reply, "InventoryFolders", new [] { }); - return Failure("Error", "InventoryFolders", new [] { }); + if (reply != null) return BasicReply(reply, "InventoryFolders"); + return Failure("Error", "InventoryFolders"); } [About("Requests the contents of a folder as an array of InventoryMapItem
Formated as follows
InventoryMapItem
  • id: UUID
  • name: String
  • typename: String
")] diff --git a/Core/Commands/Movement.cs b/Core/Commands/Movement.cs index 08435fd..40f6248 100644 --- a/Core/Commands/Movement.cs +++ b/Core/Commands/Movement.cs @@ -65,10 +65,10 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "movement", "AutoPilotStop", handleGetClientIP()) == false) { - return Failure("Token not accepted", "AutoPilotStop", new [] { }); + return Failure("Token not accepted", "AutoPilotStop"); } bot.GetClient.Self.AutoPilotCancel(); - return BasicReply("ok", "AutoPilotStop", new [] { }); + return BasicReply("ok", "AutoPilotStop"); } [About("Make the bot request the target avatar teleport to the bot")] diff --git a/Core/Commands/Parcel.cs b/Core/Commands/Parcel.cs index 532fc79..fa9205f 100644 --- a/Core/Commands/Parcel.cs +++ b/Core/Commands/Parcel.cs @@ -137,9 +137,9 @@ namespace BetterSecondBot.HttpService KeyValuePair tests = SetupCurrentParcel(token, "parcel", "GetParcelDesc"); if (tests.Key == false) { - return Failure(tests.Value, "GetParcelDesc", new [] { }); + return Failure(tests.Value, "GetParcelDesc"); } - return BasicReply(targetparcel.Desc, "GetParcelDesc", new [] { }); + return BasicReply(targetparcel.Desc, "GetParcelDesc"); } [About("gets the flags for the parcel")] @@ -152,7 +152,7 @@ namespace BetterSecondBot.HttpService KeyValuePair tests = SetupCurrentParcel(token, "parcel", "GetParcelFlags"); if (tests.Key == false) { - return Failure(tests.Value, "GetParcelFlags", new [] { }); + return Failure(tests.Value, "GetParcelFlags"); } Dictionary flags = parcel_static.get_flags_list(); Dictionary collection = new Dictionary(); @@ -160,7 +160,7 @@ namespace BetterSecondBot.HttpService { collection.Add(cfg.ToString(), targetparcel.Flags.HasFlag(cfg).ToString()); } - SuccessNoReturn("GetParcelFlags", new [] { }); + SuccessNoReturn("GetParcelFlags"); return collection; } @@ -192,10 +192,10 @@ namespace BetterSecondBot.HttpService KeyValuePair tests = SetupCurrentParcel(token, "parcel", "AbandonLand"); if (tests.Key == false) { - return Failure(tests.Value, "AbandonLand", new [] { }); + return Failure(tests.Value, "AbandonLand"); } bot.GetClient.Parcels.ReleaseParcel(bot.GetClient.Network.CurrentSim, targetparcel.LocalID); - return BasicReply("ok", "AbandonLand", new [] { }); + return BasicReply("ok", "AbandonLand"); } @@ -493,7 +493,7 @@ namespace BetterSecondBot.HttpService KeyValuePair tests = SetupCurrentParcel(token, "parcel", "GetParcelBanlist"); if (tests.Key == false) { - return Failure(tests.Value, "GetParcelBanlist", new [] { }); + return Failure(tests.Value, "GetParcelBanlist"); } GetParcelBanlistObject reply = new GetParcelBanlistObject(); int delays = 0; @@ -526,7 +526,7 @@ namespace BetterSecondBot.HttpService reply.delay = delays * 1000; reply.parcelName = targetparcel.Name; reply.regionName = bot.GetClient.Network.CurrentSim.Name; - return BasicReply(JsonConvert.SerializeObject(reply), "GetParcelBanlist", new [] { }); + return BasicReply(JsonConvert.SerializeObject(reply), "GetParcelBanlist"); } [About("Returns a rezzed object")] diff --git a/Core/Commands/Self.cs b/Core/Commands/Self.cs index daeab5d..8a5c1d7 100644 --- a/Core/Commands/Self.cs +++ b/Core/Commands/Self.cs @@ -73,11 +73,11 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "self", "Stand", handleGetClientIP()) == false) { - return Failure("Token not accepted", "Stand", new [] { }); + return Failure("Token not accepted", "Stand"); } bot.GetClient.Self.Stand(); bot.ResetAnimations(); - return BasicReply("ok", "Stand", new [] { }); + return BasicReply("ok", "Stand"); } [About("Makes the bot sit on the ground or on a object if it can see it")] @@ -117,14 +117,14 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "self", "Logoff", handleGetClientIP()) == false) { - return Failure("Token not accepted", "Logoff", new [] { }); + return Failure("Token not accepted", "Logoff"); } if (bot.KillMe == false) { bot.GetClient.Self.Chat("Laters im out", 0, ChatType.Normal); bot.KillMePlease(); } - return BasicReply("ok", "Logoff", new [] { }); + return BasicReply("ok", "Logoff"); } [About("Makes the bot kill itself you monster")] @@ -134,14 +134,14 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "self", "Logout", handleGetClientIP()) == false) { - return Failure("Token not accepted", "Logout", new [] { }); + return Failure("Token not accepted", "Logout"); } if (bot.KillMe == false) { bot.GetClient.Self.Chat("Laters im out", 0, ChatType.Normal); bot.KillMePlease(); } - return BasicReply("ok", "Logout", new [] { }); + return BasicReply("ok", "Logout"); } [About("Makes the bot kill itself you monster - without making a sound")] @@ -151,13 +151,13 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "self", "Bye", handleGetClientIP()) == false) { - return Failure("Token not accepted", "Bye", new [] { }); + return Failure("Token not accepted", "Bye"); } if (bot.KillMe == false) { bot.KillMePlease(); } - return BasicReply("ok", "Bye", new [] { }); + return BasicReply("ok", "Bye"); } [About("Gets the last 5 commands issued to the bot")] @@ -167,9 +167,9 @@ namespace BetterSecondBot.HttpService { if (tokens.Allow(token, "self", "GetLastCommands", handleGetClientIP()) == false) { - return Failure("Token not accepted", "GetLastCommands", new [] { }); + return Failure("Token not accepted", "GetLastCommands"); } - SuccessNoReturn("GetLastCommands", new [] { }); + SuccessNoReturn("GetLastCommands"); return bot.GetLastCommands(5); } diff --git a/Core/HttpService/HttpAsService.cs b/Core/HttpService/HttpAsService.cs index b771cad..561480b 100644 --- a/Core/HttpService/HttpAsService.cs +++ b/Core/HttpService/HttpAsService.cs @@ -460,11 +460,20 @@ namespace BetterSecondBot.HttpService UUID.TryParse(avatar, out avataruuid); } + protected void SuccessNoReturn(string command) + { + SuccessNoReturn(command); + } protected void SuccessNoReturn(string command, string[] args) { bot.CommandHistoryAdd(command, String.Join("~#~", args), true, ""); } + protected Object BasicReply(string input, string command) + { + return BasicReply(input, command); + } + protected Object BasicReply(string input,string command, string[] args) { bot.CommandHistoryAdd(command, String.Join("~#~", args), true, ""); @@ -477,6 +486,11 @@ namespace BetterSecondBot.HttpService return new { reply = input, status = false }; } + protected Object Failure(string input, string command) + { + return Failure(input, command); + } + public WebApiControllerWithTokens(SecondBot mainbot, TokenStorage setuptokens) { diff --git a/Shared/API/API_interface.cs b/Shared/API/API_interface.cs index b67c082..7b208a2 100644 --- a/Shared/API/API_interface.cs +++ b/Shared/API/API_interface.cs @@ -13,8 +13,8 @@ namespace BetterSecondBotShared.API public string CommandName { get { return GetType().Name.ToLowerInvariant(); ; } } public virtual int Min_Required_args { get { return 0; } } public virtual string Helpfile { get { return "No help given"; } } - public virtual string[] ArgTypes { get { return new [] { }; } } - public virtual string[] ArgHints { get { return new [] { }; } } + public virtual string[] ArgTypes { get { return new string[] { }; } } + public virtual string[] ArgHints { get { return new string[] { }; } } protected string InfoBlob = ""; public string GetInfoBlob { get { return InfoBlob; } } @@ -162,7 +162,7 @@ namespace BetterSecondBotShared.API { return CmdGet.ArgTypes; } - return new [] { }; + return new string[] { }; } public virtual string[] GetCommandArgHints(string cmd) { @@ -171,7 +171,7 @@ namespace BetterSecondBotShared.API { return CmdGet.ArgHints; } - return new [] { }; + return new string[] { }; } public virtual List GetAllWorkspaces() diff --git a/Shared/BotTypes/BasicBot.cs b/Shared/BotTypes/BasicBot.cs index 647feaa..b0491fb 100644 --- a/Shared/BotTypes/BasicBot.cs +++ b/Shared/BotTypes/BasicBot.cs @@ -202,7 +202,7 @@ namespace BetterSecondBotShared.bottypes } protected virtual string[] getNextHomeArgs() { - return new [] { }; + return new string[] { }; } public virtual void Start() {