From 5111471cea28c1ce7da6e323fc549298a3625601 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 4 Jul 2021 17:14:35 -0500 Subject: add options for pushbullet --- src/slskd/Options.cs | 70 ++++++++++++++++++++++++++++++++++++++++++ src/slskd/Properties/slskd.yml | 10 +++++- 2 files changed, 79 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index f8190fc7..d2f2ddef 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -567,6 +567,12 @@ namespace slskd [Validate] public FTPOptions FTP { get; private set; } = new FTPOptions(); + /// + /// Gets Pushbullet options. + /// + [Validate] + public PushbulletOptions Pushbullet { get; private set; } = new PushbulletOptions(); + /// /// FTP options. /// @@ -676,6 +682,70 @@ namespace slskd return results; } } + + /// + /// Pushbullet options. + /// + public class PushbulletOptions + { + /// + /// Gets a value indicating whether the Pushbullet integration is enabled. + /// + [Argument(default, "pushbullet")] + [EnvironmentVariable("PUSHBULLET_ENABLED")] + [Description("enable Pushbullet integration")] + public bool Enabled { get; private set; } = false; + + /// + /// Gets the Pushbullet API access token. + /// + [Argument(default, "pushbullet-token")] + [EnvironmentVariable("PUSHBULLET_ACCESS_TOKEN")] + [Description("Pushbullet access token")] + public string AccessToken { get; private set; } + + /// + /// Gets the prefix for Pushbullet notification titles. + /// + [Argument(default, "pushbullet-prefix")] + [EnvironmentVariable("PUSHBULLET_NOTIFICATION_PREFIX")] + [Description("prefix for Pushbullet notification titles")] + public string NotificationPrefix { get; private set; } = "From slskd:"; + + /// + /// Gets a value indicating whether a Pushbullet notification should be sent when a private message is received. + /// + [Argument(default, "pushbullet-notify-on-pm")] + [EnvironmentVariable("PUSHBULLET_NOTIFY_ON_PRIVATE_MESSAGE")] + [Description("send Pushbullet notifications when private messages are received")] + public bool NotifyOnPrivateMessage { get; private set; } = true; + + /// + /// Gets a value indicating whether a Pushbullet notification should be sent when the currently logged + /// in user's username is mentioned in a room. + /// + [Argument(default, "pushbullet-notify-on-room-mention")] + [EnvironmentVariable("PUSHBULLET_NOTIFY_ON_ROOM_MENTION")] + [Description("send Pushbullet notifications when your username is mentioned in a room")] + public bool NotifyOnRoomMention { get; private set; } = true; + + /// + /// Gets the number of times failing Pushbullet notifications will be retried. + /// + [Argument(default, "pushbullet-retry-attempts")] + [EnvironmentVariable("PUSHBULLET_RETRY_ATTEMPTS")] + [Description("number of times failing Pushbullet notifications will be retried")] + [Range(0, 5)] + public int RetryAttempts { get; private set; } = 3; + + /// + /// Gets the cooldown time for Pushbullet notifications, in milliseconds. + /// + [Argument(default, "pushbullet-cooldown")] + [EnvironmentVariable("PUSHBULLET_COOLDOWN_TIME")] + [Description("cooldown time for Pushbullet notifications, in milliseconds")] + public int CooldownTime { get; private set; } = 900000; // 15 minutes + } } } } \ No newline at end of file diff --git a/src/slskd/Properties/slskd.yml b/src/slskd/Properties/slskd.yml index a0356e6f..c5e46b5d 100644 --- a/src/slskd/Properties/slskd.yml +++ b/src/slskd/Properties/slskd.yml @@ -61,4 +61,12 @@ # remote_path: / # overwrite_existing: true # connection_timeout: 5000 -# retry_attempts: 5 \ No newline at end of file +# retry_attempts: 3 +# pushbullet: +# enabled: false +# access_token: ~ +# notification_prefix: ~ +# notify_on_private_message: true +# notify_on_room_mention: true +# retry_attempts: 3 +# cooldown_time: 900000 \ No newline at end of file -- cgit v1.2.3