aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Integrations/Scripts/ScriptService.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2024-10-13 17:55:28 -0500
committerJP Dillingham <jp@dillingham.me>2024-10-13 17:55:28 -0500
commit4511741facda6c232b4748940ea0f111fa081abe (patch)
tree32c9eb099fd89b3edd3440ef77196c624d8a31a4 /src/slskd/Integrations/Scripts/ScriptService.cs
parent602002b881ab89145975db10dedfabc69850114d (diff)
downloadslskd-4511741facda6c232b4748940ea0f111fa081abe.tar.gz
All -> Any
Diffstat (limited to 'src/slskd/Integrations/Scripts/ScriptService.cs')
-rw-r--r--src/slskd/Integrations/Scripts/ScriptService.cs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/slskd/Integrations/Scripts/ScriptService.cs b/src/slskd/Integrations/Scripts/ScriptService.cs
index a427480b..9a2a0a0c 100644
--- a/src/slskd/Integrations/Scripts/ScriptService.cs
+++ b/src/slskd/Integrations/Scripts/ScriptService.cs
@@ -20,6 +20,7 @@ using Microsoft.Extensions.Options;
namespace slskd.Integrations.Scripts;
using System;
+using System.Linq;
using System.Threading.Tasks;
using Serilog;
using slskd.Events;
@@ -45,6 +46,18 @@ public class ScriptService
private async Task HandleEvent(Event data)
{
- Console.WriteLine($"--------------------{nameof(HandleEvent)}");
+ Log.Debug("Handling event {Event}", data);
+
+ bool EqualsThisEvent(string type) => type.Equals(data.Type.ToString(), StringComparison.OrdinalIgnoreCase);
+ bool EqualsLiterallyAnyEvent(string type) => type.Equals(EventType.Any.ToString(), StringComparison.OrdinalIgnoreCase);
+
+ var options = OptionsMonitor.CurrentValue;
+ var scriptsTriggeredByThisEventType = options.Integration.Scripts
+ .Where(kvp => kvp.Value.On.Any(EqualsThisEvent) || kvp.Value.On.Any(EqualsLiterallyAnyEvent));
+
+ foreach (var script in scriptsTriggeredByThisEventType)
+ {
+ Console.WriteLine($"--------------------{script.Key}");
+ }
}
} \ No newline at end of file