From c4450c8592e646de0185fd58710277a2dd0b3ebc Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 13 Oct 2024 17:53:20 -0500 Subject: move script config under integration --- config/slskd.example.yml | 22 +++++++++++----------- src/slskd/Core/Options.cs | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/config/slskd.example.yml b/config/slskd.example.yml index 6b7750d5..7dd6450b 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -213,6 +213,16 @@ # username: ~ # password: ~ # integration: +# scripts: +# my_post_download_script: +# on: +# - DownloadFileComplete +# - DownloadDirectoryComplete +# run: data/my_script.sh --json-to-process $EVENT +# my_logging_script: +# on: +# - All +# run: data/log_slskd_events.sh $EVENT # ftp: # enabled: false # address: ~ @@ -232,14 +242,4 @@ # notify_on_private_message: true # notify_on_room_mention: true # retry_attempts: 3 -# cooldown_time: 900000 -# scripts: -# my_post_download_script: -# on: -# - DownloadFileComplete -# - DownloadDirectoryComplete -# run: data/my_script.sh --json-to-process $EVENT -# my_logging_script: -# on: -# - All -# run: data/log_slskd_events.sh $EVENT \ No newline at end of file +# cooldown_time: 900000 \ No newline at end of file diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 0f86ff62..306f9b87 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -32,6 +32,7 @@ namespace slskd using NetTools; using slskd.Authentication; using slskd.Configuration; + using slskd.Events; using slskd.Relay; using slskd.Shares; using slskd.Validation; @@ -2004,6 +2005,12 @@ namespace slskd /// public class IntegrationOptions { + /// + /// Gets script configuration. + /// + [Validate] + public Dictionary Scripts { get; init; } = []; + /// /// Gets FTP options. /// @@ -2016,6 +2023,25 @@ namespace slskd [Validate] public PushbulletOptions Pushbullet { get; init; } = new PushbulletOptions(); + /// + /// Script configuration. + /// + public class ScriptOptions + { + /// + /// Gets the list of Event types that trigger the script. + /// + [Enum(typeof(EventType))] + public string[] On { get; init; } = Array.Empty(); + + /// + /// Gets the shell script to invoke. + /// + [StringLength(int.MaxValue, MinimumLength = 1)] + [NotNullOrWhiteSpace] + public string Run { get; init; } + } + /// /// FTP options. /// -- cgit v1.2.3