From e43dbcabc8857b6e0fd4870eaa18420a0c20f78e Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Thu, 15 Aug 2024 16:53:11 +0100 Subject: [PATCH] fixs correct ResetAnimations, allow stand to call reset animations, fix start service, add a delay on startup --- SecondBotEvents/Commands/Animation.cs | 12 +++++++++--- SecondBotEvents/Commands/Avatars.cs | 1 + SecondBotEvents/Commands/Self.cs | 1 + SecondBotEvents/EventsSecondBot.cs | 2 ++ SecondBotEvents/Services/BotClientService.cs | 2 +- SecondBotEvents/Services/CommandsService.cs | 2 +- SecondBotEvents/Services/CurrentOutfitFolder.cs | 2 +- SecondBotEvents/Services/CustomCommandsService.cs | 2 +- SecondBotEvents/Services/DataStoreService.cs | 6 +++++- SecondBotEvents/Services/DialogService.cs | 6 +++++- SecondBotEvents/Services/DiscordService.cs | 6 +++++- SecondBotEvents/Services/EventsService.cs | 6 +++++- SecondBotEvents/Services/HomeboundService.cs | 8 ++++++-- SecondBotEvents/Services/HttpService.cs | 6 +++++- SecondBotEvents/Services/InteractionService.cs | 6 +++++- SecondBotEvents/Services/RLVService.cs | 6 +++++- SecondBotEvents/Services/RelayService.cs | 6 +++++- SecondBotEvents/Services/Services.cs | 9 ++++----- SecondBotEvents/Services/TriggerOnEventService.cs | 6 +++++- 19 files changed, 72 insertions(+), 23 deletions(-) diff --git a/SecondBotEvents/Commands/Animation.cs b/SecondBotEvents/Commands/Animation.cs index 433004a..54f5fcb 100644 --- a/SecondBotEvents/Commands/Animation.cs +++ b/SecondBotEvents/Commands/Animation.cs @@ -1,5 +1,7 @@ using OpenMetaverse; using SecondBotEvents.Services; +using System.Collections.Generic; +using System.Linq; namespace SecondBotEvents.Commands { @@ -44,11 +46,15 @@ namespace SecondBotEvents.Commands } [About("Resets the animation stack for the bot")] - [ReturnHints("Accepted")] + [ReturnHints("Accepted - X stopped animations")] public object ResetAnimations() { - // @todo Reset animations function from old version - return Failure("@todo"); + List animations = GetClient().Self.SignaledAnimations.Copy().Keys.ToList(); + foreach (UUID anim in animations) + { + GetClient().Self.AnimationStop(anim, true); + } + return BasicReply("Accepted - "+animations.Count.ToString()+" stopped animations"); } } diff --git a/SecondBotEvents/Commands/Avatars.cs b/SecondBotEvents/Commands/Avatars.cs index 26e8afc..6c83c93 100644 --- a/SecondBotEvents/Commands/Avatars.cs +++ b/SecondBotEvents/Commands/Avatars.cs @@ -13,6 +13,7 @@ namespace SecondBotEvents.Commands { } + [About("an improved version of near me with extra details
NearMeDetails is a object formated as follows
")] [ReturnHints("array NearMeDetails")] [ReturnHintsFailure("Error not in a sim")] diff --git a/SecondBotEvents/Commands/Self.cs b/SecondBotEvents/Commands/Self.cs index baac4e9..36bfa4b 100644 --- a/SecondBotEvents/Commands/Self.cs +++ b/SecondBotEvents/Commands/Self.cs @@ -109,6 +109,7 @@ namespace SecondBotEvents.Commands { master.HomeboundService.MarkStandup(); GetClient().Self.Stand(); + master.CommandsService.CommandInterfaceCaller("ResetAnimations", false, false, "Stand command"); return BasicReply("ok"); } diff --git a/SecondBotEvents/EventsSecondBot.cs b/SecondBotEvents/EventsSecondBot.cs index 0d72450..d567ca9 100644 --- a/SecondBotEvents/EventsSecondBot.cs +++ b/SecondBotEvents/EventsSecondBot.cs @@ -100,6 +100,8 @@ namespace SecondBotEvents { fromFolder = args[0]; } + LogFormater.Info("Giving SL a chance - waiting 4 secs"); + Thread.Sleep(4000); StartServices(); } diff --git a/SecondBotEvents/Services/BotClientService.cs b/SecondBotEvents/Services/BotClientService.cs index c8771cf..e106bbb 100644 --- a/SecondBotEvents/Services/BotClientService.cs +++ b/SecondBotEvents/Services/BotClientService.cs @@ -40,7 +40,7 @@ namespace SecondBotEvents.Services return basicCfg.IsLoaded(); } - public override void Start() + public override void Start(bool updateEnabled = false, bool setEnabledTo = false) { running = true; LogFormater.Info("Client service [Starting]"); diff --git a/SecondBotEvents/Services/CommandsService.cs b/SecondBotEvents/Services/CommandsService.cs index ad44172..8c2365c 100644 --- a/SecondBotEvents/Services/CommandsService.cs +++ b/SecondBotEvents/Services/CommandsService.cs @@ -95,7 +95,7 @@ namespace SecondBotEvents.Services } } } - public override void Start() + public override void Start(bool updateEnabled = false, bool setEnabledTo = false) { running = true; master.BotClientNoticeEvent += BotClientRestart; diff --git a/SecondBotEvents/Services/CurrentOutfitFolder.cs b/SecondBotEvents/Services/CurrentOutfitFolder.cs index f2d5879..9247468 100644 --- a/SecondBotEvents/Services/CurrentOutfitFolder.cs +++ b/SecondBotEvents/Services/CurrentOutfitFolder.cs @@ -39,7 +39,7 @@ namespace SecondBotEvents.Services return "Active"; } - public override void Start() + public override void Start(bool updateEnabled = false, bool setEnabledTo = false) { Stop(); running = true; diff --git a/SecondBotEvents/Services/CustomCommandsService.cs b/SecondBotEvents/Services/CustomCommandsService.cs index 5413edf..b256e38 100644 --- a/SecondBotEvents/Services/CustomCommandsService.cs +++ b/SecondBotEvents/Services/CustomCommandsService.cs @@ -106,7 +106,7 @@ namespace SecondBotEvents.Services botConnected = true; } - public override void Start() + public override void Start(bool updateEnabled = false, bool setEnabledTo = false) { running = true; master.BotClientNoticeEvent += BotClientRestart; diff --git a/SecondBotEvents/Services/DataStoreService.cs b/SecondBotEvents/Services/DataStoreService.cs index 1a2b8ed..02d2860 100644 --- a/SecondBotEvents/Services/DataStoreService.cs +++ b/SecondBotEvents/Services/DataStoreService.cs @@ -1093,8 +1093,12 @@ namespace SecondBotEvents.Services } } - public override void Start() + public override void Start(bool updateEnabled = false, bool setEnabledTo = false) { + if (updateEnabled) + { + myConfig.setEnabled(setEnabledTo); + } Stop(); running = true; master.BotClientNoticeEvent += BotClientRestart; diff --git a/SecondBotEvents/Services/DialogService.cs b/SecondBotEvents/Services/DialogService.cs index 2d621c8..ca8be4a 100644 --- a/SecondBotEvents/Services/DialogService.cs +++ b/SecondBotEvents/Services/DialogService.cs @@ -245,8 +245,12 @@ namespace SecondBotEvents.Services GetClient().Self.ScriptDialog += DialogWindowEvent; } - public override void Start() + public override void Start(bool updateEnabled = false, bool setEnabledTo = false) { + if (updateEnabled) + { + myConfig.setEnabled(setEnabledTo); + } Stop(); running = true; master.BotClientNoticeEvent += BotClientRestart; diff --git a/SecondBotEvents/Services/DiscordService.cs b/SecondBotEvents/Services/DiscordService.cs index aea686c..4bf3e56 100644 --- a/SecondBotEvents/Services/DiscordService.cs +++ b/SecondBotEvents/Services/DiscordService.cs @@ -524,8 +524,12 @@ namespace SecondBotEvents.Services return true; } - public override void Start() + public override void Start(bool updateEnabled = false, bool setEnabledTo = false) { + if (updateEnabled) + { + myConfig.setEnabled(setEnabledTo); + } running = true; if (myConfig.GetEnabled() == false) { diff --git a/SecondBotEvents/Services/EventsService.cs b/SecondBotEvents/Services/EventsService.cs index 66d53ac..85c71ac 100644 --- a/SecondBotEvents/Services/EventsService.cs +++ b/SecondBotEvents/Services/EventsService.cs @@ -419,8 +419,12 @@ namespace SecondBotEvents.Services - public override void Start() + public override void Start(bool updateEnabled = false, bool setEnabledTo = false) { + if (updateEnabled) + { + myConfig.setEnabled(setEnabledTo); + } if (myConfig.GetEnabled() == false) { LogFormater.Info("Events service [Disabled]"); diff --git a/SecondBotEvents/Services/HomeboundService.cs b/SecondBotEvents/Services/HomeboundService.cs index fc07c1c..b8a3e92 100644 --- a/SecondBotEvents/Services/HomeboundService.cs +++ b/SecondBotEvents/Services/HomeboundService.cs @@ -319,9 +319,13 @@ namespace SecondBotEvents.Services LogFormater.Info("Homebound Service [Active]"); } - public override void Start() + public override void Start(bool updateEnabled = false, bool setEnabledTo = false) { - if(myConfig.GetEnabled() == false) + if (updateEnabled) + { + myConfig.setEnabled(setEnabledTo); + } + if (myConfig.GetEnabled() == false) { return; } diff --git a/SecondBotEvents/Services/HttpService.cs b/SecondBotEvents/Services/HttpService.cs index 350a187..71cc7af 100644 --- a/SecondBotEvents/Services/HttpService.cs +++ b/SecondBotEvents/Services/HttpService.cs @@ -84,8 +84,12 @@ namespace SecondBotEvents.Services CreateWebServer(); } - public override void Start() + public override void Start(bool updateEnabled = false, bool setEnabledTo = false) { + if (updateEnabled) + { + myConfig.setEnabled(setEnabledTo); + } if (myConfig.GetEnabled() == false) { LogFormater.Info("HTTP service [Disabled]"); diff --git a/SecondBotEvents/Services/InteractionService.cs b/SecondBotEvents/Services/InteractionService.cs index 17445a2..6ec5110 100644 --- a/SecondBotEvents/Services/InteractionService.cs +++ b/SecondBotEvents/Services/InteractionService.cs @@ -245,8 +245,12 @@ namespace SecondBotEvents.Services LogFormater.Info("Interaction Service [Active]"); } - public override void Start() + public override void Start(bool updateEnabled = false, bool setEnabledTo = false) { + if (updateEnabled) + { + myConfig.setEnabled(setEnabledTo); + } if (myConfig.GetEnabled() == false) { LogFormater.Info("Interaction Service [- Not requested -]"); diff --git a/SecondBotEvents/Services/RLVService.cs b/SecondBotEvents/Services/RLVService.cs index e21ce86..45d7890 100644 --- a/SecondBotEvents/Services/RLVService.cs +++ b/SecondBotEvents/Services/RLVService.cs @@ -128,8 +128,12 @@ namespace SecondBotEvents.Services } - public override void Start() + public override void Start(bool updateEnabled = false, bool setEnabledTo = false) { + if(updateEnabled) + { + myConfig.setEnabled(setEnabledTo); + } if (myConfig.GetEnabled() == false) { LogFormater.Info("Events service [Disabled]"); diff --git a/SecondBotEvents/Services/RelayService.cs b/SecondBotEvents/Services/RelayService.cs index 4b4dc8b..cc4e3cf 100644 --- a/SecondBotEvents/Services/RelayService.cs +++ b/SecondBotEvents/Services/RelayService.cs @@ -245,8 +245,12 @@ namespace SecondBotEvents.Services } - public override void Start() + public override void Start(bool updateEnabled = false, bool setEnabledTo = false) { + if (updateEnabled) + { + myConfig.setEnabled(setEnabledTo); + } Stop(); running = true; master.BotClientNoticeEvent += BotClientRestart; diff --git a/SecondBotEvents/Services/Services.cs b/SecondBotEvents/Services/Services.cs index 6b6005a..3732fa0 100644 --- a/SecondBotEvents/Services/Services.cs +++ b/SecondBotEvents/Services/Services.cs @@ -18,8 +18,7 @@ namespace SecondBotEvents.Services public void enableAndStart() { - myConfig.setEnabled(true); - Restart(); + Restart(true, true); } public void changeConfig(string configKey, string configValue) @@ -46,7 +45,7 @@ namespace SecondBotEvents.Services return ""; } - public virtual void Start() + public virtual void Start(bool updateEnabled = false, bool setEnabledTo = false) { running = true; } @@ -54,13 +53,13 @@ namespace SecondBotEvents.Services { running = false; } - public void Restart() + public void Restart(bool updateEnabled=false, bool setEnabledTo=false) { if (running == true) { Stop(); } - Start(); + Start(updateEnabled, setEnabledTo); } } } diff --git a/SecondBotEvents/Services/TriggerOnEventService.cs b/SecondBotEvents/Services/TriggerOnEventService.cs index cf27a9e..8fe5ab7 100644 --- a/SecondBotEvents/Services/TriggerOnEventService.cs +++ b/SecondBotEvents/Services/TriggerOnEventService.cs @@ -786,8 +786,12 @@ namespace SecondBotEvents.Services AttachEvents(); } - public override void Start() + public override void Start(bool updateEnabled = false, bool setEnabledTo = false) { + if (updateEnabled) + { + myConfig.setEnabled(setEnabledTo); + } if (myConfig.GetEnabled() == false) { LogFormater.Info("OnEvent Service [- Not requested -]");