diff --git a/Dockerfile b/Dockerfile index f15c5d7..e8af814 100644 --- a/Dockerfile +++ b/Dockerfile @@ -116,7 +116,10 @@ ENV basic_Username='' \ chatgpt_UseModel='gpt3' \ chatgpt_ChatHistoryMessages='5' \ chatgpt_ChatPrompt='respond as if you are a horse that knows its going to the glue factory and you are upset about this fact' \ - chatgpt_Provider='openai' + chatgpt_Provider='openai' \ + onevent_Enabled='false' \ + onevent_Count=0 \ + onevent_HideStatusOutput='false' EXPOSE 80 diff --git a/SecondBotEvents/Config/OnEventConfig.cs b/SecondBotEvents/Config/OnEventConfig.cs index 775a6dd..5102b2d 100644 --- a/SecondBotEvents/Config/OnEventConfig.cs +++ b/SecondBotEvents/Config/OnEventConfig.cs @@ -15,6 +15,7 @@ namespace SecondBotEvents.Config settings.Add("Enabled"); settings.Add("Count"); settings.Add("HideStatusOutput"); + settings.Add("DebugMe"); } public void unloadEvents() @@ -54,6 +55,10 @@ namespace SecondBotEvents.Config settings.Remove(name); } + public bool GetDebugMe() + { + return ReadSettingAsBool("DebugMe", false); + } public bool GetEnabled() { return ReadSettingAsBool("Enabled", false); diff --git a/SecondBotEvents/Services/TriggerOnEventService.cs b/SecondBotEvents/Services/TriggerOnEventService.cs index 61bd051..1c43f3c 100644 --- a/SecondBotEvents/Services/TriggerOnEventService.cs +++ b/SecondBotEvents/Services/TriggerOnEventService.cs @@ -1,4 +1,5 @@ -using OpenMetaverse; +using Microsoft.Extensions.Logging; +using OpenMetaverse; using OpenMetaverse.Rendering; using SecondBotEvents.Config; using Swan.Logging; @@ -7,6 +8,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection.Metadata.Ecma335; +using System.Text; namespace SecondBotEvents.Services { @@ -200,6 +202,10 @@ namespace SecondBotEvents.Services protected void RemoveEvents() { + if (myConfig.GetDebugMe() == true) + { + LogFormater.Info("OnEvent Service (DebugMe) RemoveEvents"); + } if (master.BotClient != null) { if (GetClient() != null) @@ -216,6 +222,10 @@ namespace SecondBotEvents.Services protected void AttachEvents() { + if(myConfig.GetDebugMe() == true) + { + LogFormater.Info("OnEvent Service (DebugMe) AttachEvents"); + } GetClient().Self.IM += BotImMessage; GetClient().Groups.GroupMembersReply += BotGroupMembers; GetClient().Groups.CurrentGroups += BotGroupsCurrent; @@ -458,8 +468,26 @@ namespace SecondBotEvents.Services } protected void TriggerEvent(string eventName, Dictionary args) { + if (myConfig.GetDebugMe() == true) + { + StringBuilder A = new StringBuilder(); + string addon = ""; + foreach(KeyValuePair Ar in args) + { + A.Append(Ar.Key); + A.Append("="); + A.Append(Ar.Value); + A.Append(addon); + addon = ","; + } + LogFormater.Info("OnEvent Service (DebugMe) TriggerEvent "+eventName+" args: "+A.ToString()); + } if (MyCustomEvents.ContainsKey(eventName) == false) { + if (myConfig.GetDebugMe() == true) + { + LogFormater.Info("OnEvent Service (DebugMe) Not a tracked event"); + } return; } string avataruuid = inArgsOrDefault("avataruuid", args, null); @@ -493,14 +521,23 @@ namespace SecondBotEvents.Services { "clockmin", DateTime.Now.ToString("mm") }, { "dayofweek", ((int)DateTime.Now.DayOfWeek).ToString() } }; - + if (myConfig.GetDebugMe() == true) + { + LogFormater.Info("OnEvent Service (DebugMe) There are "+ MyCustomEvents[eventName].Count.ToString()+" events to trigger"); + } + int eventid = -1; foreach (CustomOnEvent E in MyCustomEvents[eventName]) { + eventid++; bool canFireEvent = true; if ((E.Source == "GroupMemberJoin") || (E.Source == "GroupMemberLeave")) { if (E.MonitorFlags[0] != values["groupuuid"]) { + if (myConfig.GetDebugMe() == true) + { + LogFormater.Info("OnEvent Service (DebugMe) Failed checks on " + eventName + " id " + (eventid + 1).ToString() + " failed Group checks"); + } continue; } } @@ -512,6 +549,10 @@ namespace SecondBotEvents.Services (E.MonitorFlags[1] != values["avatarparcel"]) ) { + if (myConfig.GetDebugMe() == true) + { + LogFormater.Info("OnEvent Service (DebugMe) Failed checks on " + eventName + " id " + (eventid + 1).ToString() + " failed Guest checks"); + } continue; } } @@ -564,6 +605,10 @@ namespace SecondBotEvents.Services else if ((center == "DIVISIBLE") && (leftIsDivs == false)) { canFireEvent = false; } if (canFireEvent == false) { + if (myConfig.GetDebugMe() == true) + { + LogFormater.Info("OnEvent Service (DebugMe) Failed checks on " + eventName + " id " + (eventid + 1).ToString()+" rule id "+(loop+1).ToString()+" #"+center); + } break; } loop++; @@ -572,7 +617,12 @@ namespace SecondBotEvents.Services { continue; } - foreach(string action in E.Actions) + if (myConfig.GetDebugMe() == true) + { + LogFormater.Info("OnEvent Service (DebugMe) Triggering "+E.Actions.Count().ToString()+ " actions for event id "+(eventid+1).ToString()); + } + int loop2 = 1; + foreach (string action in E.Actions) { string useaction = swapvalues(action, values); string[] bits = useaction.Split('='); @@ -591,6 +641,11 @@ namespace SecondBotEvents.Services continue; } } + if (myConfig.GetDebugMe() == true) + { + LogFormater.Info("OnEvent Service (DebugMe) Triggering " + useaction + " actions for event id " + (loop2).ToString()); + } + loop2++; master.CommandsService.CommandInterfaceCaller(useaction, false, false, "OnEvents"); } }