diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index f2cc23a11..a01ae4846 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -1162,9 +1162,9 @@ "Menu": "Menu", "Message": "Message", "Metadata": "Metadata", - "MetadataLoadError": "Unable to load Metadata", "MetadataKometaDeprecated": "Kometa files will no longer be created, support will be removed completely in v5", "MetadataKometaDeprecatedSetting": "Deprecated", + "MetadataLoadError": "Unable to load Metadata", "MetadataPlexSettingsEpisodeMappings": "Episode Mappings", "MetadataPlexSettingsEpisodeMappingsHelpText": "Include episode mappings for all files in .plexmatch file", "MetadataPlexSettingsSeriesPlexMatchFile": "Series Plex Match File", @@ -1437,10 +1437,10 @@ "NotificationsSettingsUpdateMapPathsTo": "Map Paths To", "NotificationsSettingsUpdateMapPathsToSeriesHelpText": "{serviceName} path, used to modify series paths when {serviceName} sees library path location differently from {appName} (Requires 'Update Library')", "NotificationsSettingsUseSslHelpText": "Connect to {serviceName} over HTTPS instead of HTTP", + "NotificationsSettingsWebhookHeaders": "Headers", "NotificationsSettingsWebhookMethod": "Method", "NotificationsSettingsWebhookMethodHelpText": "Which HTTP method to use submit to the Webservice", "NotificationsSettingsWebhookUrl": "Webhook URL", - "NotificationsSettingsWebhookHeaders": "Headers", "NotificationsSignalSettingsGroupIdPhoneNumber": "Group ID / Phone Number", "NotificationsSignalSettingsGroupIdPhoneNumberHelpText": "Group ID / Phone Number of the receiver", "NotificationsSignalSettingsPasswordHelpText": "Password used to authenticate requests toward signal-api", @@ -1466,6 +1466,8 @@ "NotificationsTelegramSettingsChatIdHelpText": "You must start a conversation with the bot or add it to your group to receive messages", "NotificationsTelegramSettingsIncludeAppName": "Include {appName} in Title", "NotificationsTelegramSettingsIncludeAppNameHelpText": "Optionally prefix message title with {appName} to differentiate notifications from different applications", + "NotificationsTelegramSettingsIncludeInstanceName": "Include Instance Name in Title", + "NotificationsTelegramSettingsIncludeInstanceNameHelpText": "Optionally include Instance name in notification", "NotificationsTelegramSettingsMetadataLinks": "Metadata Links", "NotificationsTelegramSettingsMetadataLinksHelpText": "Add a links to series metadata when sending notifications", "NotificationsTelegramSettingsSendSilently": "Send Silently", @@ -2083,14 +2085,14 @@ "UpdateFiltered": "Update Filtered", "UpdateMechanismHelpText": "Use {appName}'s built-in updater or a script", "UpdateMonitoring": "Update Monitoring", + "UpdatePath": "Update Path", "UpdateScriptPathHelpText": "Path to a custom script that takes an extracted update package and handle the remainder of the update process", "UpdateSelected": "Update Selected", + "UpdateSeriesPath": "Update Series Path", "UpdateStartupNotWritableHealthCheckMessage": "Cannot install update because startup folder '{startupFolder}' is not writable by the user '{userName}'.", "UpdateStartupTranslocationHealthCheckMessage": "Cannot install update because startup folder '{startupFolder}' is in an App Translocation folder.", "UpdateUiNotWritableHealthCheckMessage": "Cannot install update because UI folder '{uiFolder}' is not writable by the user '{userName}'.", "UpdaterLogFiles": "Updater Log Files", - "UpdatePath": "Update Path", - "UpdateSeriesPath": "Update Series Path", "Updates": "Updates", "UpgradeUntil": "Upgrade Until", "UpgradeUntilCustomFormatScore": "Upgrade Until Custom Format Score", diff --git a/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs b/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs index 91b37000b..b06328a36 100644 --- a/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs +++ b/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Configuration; using NzbDrone.Core.Tv; namespace NzbDrone.Core.Notifications.Telegram @@ -8,18 +9,23 @@ namespace NzbDrone.Core.Notifications.Telegram public class Telegram : NotificationBase { private readonly ITelegramProxy _proxy; + private readonly IConfigFileProvider _configFileProvider; - public Telegram(ITelegramProxy proxy) + public Telegram(ITelegramProxy proxy, IConfigFileProvider configFileProvider) { _proxy = proxy; + _configFileProvider = configFileProvider; } public override string Name => "Telegram"; public override string Link => "https://telegram.org/"; + private string InstanceName => _configFileProvider.InstanceName; + public override void OnGrab(GrabMessage grabMessage) { var title = Settings.IncludeAppNameInTitle ? EPISODE_GRABBED_TITLE_BRANDED : EPISODE_GRABBED_TITLE; + title = Settings.IncludeInstanceNameInTitle ? $"{title} - {InstanceName}" : title; var links = GetLinks(grabMessage.Series); _proxy.SendNotification(title, grabMessage.Message, links, Settings); @@ -28,6 +34,7 @@ namespace NzbDrone.Core.Notifications.Telegram public override void OnDownload(DownloadMessage message) { var title = Settings.IncludeAppNameInTitle ? EPISODE_DOWNLOADED_TITLE_BRANDED : EPISODE_DOWNLOADED_TITLE; + title = Settings.IncludeInstanceNameInTitle ? $"{title} - {InstanceName}" : title; var links = GetLinks(message.Series); _proxy.SendNotification(title, message.Message, links, Settings); @@ -36,6 +43,7 @@ namespace NzbDrone.Core.Notifications.Telegram public override void OnImportComplete(ImportCompleteMessage message) { var title = Settings.IncludeAppNameInTitle ? EPISODE_DOWNLOADED_TITLE_BRANDED : EPISODE_DOWNLOADED_TITLE; + title = Settings.IncludeInstanceNameInTitle ? $"{title} - {InstanceName}" : title; var links = GetLinks(message.Series); _proxy.SendNotification(title, message.Message, links, Settings); @@ -44,6 +52,7 @@ namespace NzbDrone.Core.Notifications.Telegram public override void OnEpisodeFileDelete(EpisodeDeleteMessage deleteMessage) { var title = Settings.IncludeAppNameInTitle ? EPISODE_DELETED_TITLE_BRANDED : EPISODE_DELETED_TITLE; + title = Settings.IncludeInstanceNameInTitle ? $"{title} - {InstanceName}" : title; var links = GetLinks(deleteMessage.Series); _proxy.SendNotification(title, deleteMessage.Message, links, Settings); @@ -52,6 +61,7 @@ namespace NzbDrone.Core.Notifications.Telegram public override void OnSeriesAdd(SeriesAddMessage message) { var title = Settings.IncludeAppNameInTitle ? SERIES_ADDED_TITLE_BRANDED : SERIES_ADDED_TITLE; + title = Settings.IncludeInstanceNameInTitle ? $"{title} - {InstanceName}" : title; var links = GetLinks(message.Series); _proxy.SendNotification(title, message.Message, links, Settings); @@ -60,6 +70,7 @@ namespace NzbDrone.Core.Notifications.Telegram public override void OnSeriesDelete(SeriesDeleteMessage deleteMessage) { var title = Settings.IncludeAppNameInTitle ? SERIES_DELETED_TITLE_BRANDED : SERIES_DELETED_TITLE; + title = Settings.IncludeInstanceNameInTitle ? $"{title} - {InstanceName}" : title; var links = GetLinks(deleteMessage.Series); _proxy.SendNotification(title, deleteMessage.Message, links, Settings); @@ -68,6 +79,7 @@ namespace NzbDrone.Core.Notifications.Telegram public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck) { var title = Settings.IncludeAppNameInTitle ? HEALTH_ISSUE_TITLE_BRANDED : HEALTH_ISSUE_TITLE; + title = Settings.IncludeInstanceNameInTitle ? $"{title} - {InstanceName}" : title; _proxy.SendNotification(title, healthCheck.Message, new List(), Settings); } @@ -75,6 +87,7 @@ namespace NzbDrone.Core.Notifications.Telegram public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck) { var title = Settings.IncludeAppNameInTitle ? HEALTH_RESTORED_TITLE_BRANDED : HEALTH_RESTORED_TITLE; + title = Settings.IncludeInstanceNameInTitle ? $"{title} - {InstanceName}" : title; _proxy.SendNotification(title, $"The following issue is now resolved: {previousCheck.Message}", new List(), Settings); } @@ -82,6 +95,7 @@ namespace NzbDrone.Core.Notifications.Telegram public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) { var title = Settings.IncludeAppNameInTitle ? APPLICATION_UPDATE_TITLE_BRANDED : APPLICATION_UPDATE_TITLE; + title = Settings.IncludeInstanceNameInTitle ? $"{title} - {InstanceName}" : title; _proxy.SendNotification(title, updateMessage.Message, new List(), Settings); } @@ -89,6 +103,7 @@ namespace NzbDrone.Core.Notifications.Telegram public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message) { var title = Settings.IncludeAppNameInTitle ? MANUAL_INTERACTION_REQUIRED_TITLE_BRANDED : MANUAL_INTERACTION_REQUIRED_TITLE; + title = Settings.IncludeInstanceNameInTitle ? $"{title} - {InstanceName}" : title; var links = GetLinks(message.Series); _proxy.SendNotification(title, message.Message, links, Settings); diff --git a/src/NzbDrone.Core/Notifications/Telegram/TelegramProxy.cs b/src/NzbDrone.Core/Notifications/Telegram/TelegramProxy.cs index 48f70761e..bd657e331 100644 --- a/src/NzbDrone.Core/Notifications/Telegram/TelegramProxy.cs +++ b/src/NzbDrone.Core/Notifications/Telegram/TelegramProxy.cs @@ -8,6 +8,7 @@ using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Common.Serializer; +using NzbDrone.Core.Configuration; using NzbDrone.Core.Localization; namespace NzbDrone.Core.Notifications.Telegram @@ -23,12 +24,14 @@ namespace NzbDrone.Core.Notifications.Telegram private const string URL = "https://api.telegram.org"; private readonly IHttpClient _httpClient; + private readonly IConfigFileProvider _configFileProvider; private readonly ILocalizationService _localizationService; private readonly Logger _logger; - public TelegramProxy(IHttpClient httpClient, ILocalizationService localizationService, Logger logger) + public TelegramProxy(IHttpClient httpClient, IConfigFileProvider configFileProvider, ILocalizationService localizationService, Logger logger) { _httpClient = httpClient; + _configFileProvider = configFileProvider; _localizationService = localizationService; _logger = logger; } @@ -70,7 +73,10 @@ namespace NzbDrone.Core.Notifications.Telegram new TelegramLink("Sonarr.tv", "https://sonarr.tv") }; - SendNotification(settings.IncludeAppNameInTitle ? brandedTitle : title, body, links, settings); + var testMessageTitle = settings.IncludeAppNameInTitle ? brandedTitle : title; + testMessageTitle = settings.IncludeInstanceNameInTitle ? $"{testMessageTitle} - {_configFileProvider.InstanceName}" : testMessageTitle; + + SendNotification(testMessageTitle, body, links, settings); } catch (Exception ex) { diff --git a/src/NzbDrone.Core/Notifications/Telegram/TelegramSettings.cs b/src/NzbDrone.Core/Notifications/Telegram/TelegramSettings.cs index ac39a1b45..91bf68cfc 100644 --- a/src/NzbDrone.Core/Notifications/Telegram/TelegramSettings.cs +++ b/src/NzbDrone.Core/Notifications/Telegram/TelegramSettings.cs @@ -51,7 +51,10 @@ namespace NzbDrone.Core.Notifications.Telegram [FieldDefinition(4, Label = "NotificationsTelegramSettingsIncludeAppName", Type = FieldType.Checkbox, HelpText = "NotificationsTelegramSettingsIncludeAppNameHelpText")] public bool IncludeAppNameInTitle { get; set; } - [FieldDefinition(5, Label = "NotificationsTelegramSettingsMetadataLinks", Type = FieldType.Select, SelectOptions = typeof(MetadataLinkType), HelpText = "NotificationsTelegramSettingsMetadataLinksHelpText")] + [FieldDefinition(5, Label = "NotificationsTelegramSettingsIncludeInstanceName", Type = FieldType.Checkbox, HelpText = "NotificationsTelegramSettingsIncludeInstanceNameHelpText", Advanced = true)] + public bool IncludeInstanceNameInTitle { get; set; } + + [FieldDefinition(6, Label = "NotificationsTelegramSettingsMetadataLinks", Type = FieldType.Select, SelectOptions = typeof(MetadataLinkType), HelpText = "NotificationsTelegramSettingsMetadataLinksHelpText")] public IEnumerable MetadataLinks { get; set; } public override NzbDroneValidationResult Validate()