diff --git a/app/common/src/main/java/stirling/software/common/model/ApplicationProperties.java b/app/common/src/main/java/stirling/software/common/model/ApplicationProperties.java index 29e468020..f051bf622 100644 --- a/app/common/src/main/java/stirling/software/common/model/ApplicationProperties.java +++ b/app/common/src/main/java/stirling/software/common/model/ApplicationProperties.java @@ -336,8 +336,8 @@ public class ApplicationProperties { throw new UnsupportedProviderException( "Logout from the provider " + registrationId - + " is not supported. " - + "Report it at https://github.com/Stirling-Tools/Stirling-PDF/issues"); + + " is not supported. Report it at" + + " https://github.com/Stirling-Tools/Stirling-PDF/issues"); }; } } @@ -537,10 +537,10 @@ public class ApplicationProperties { @Override public String toString() { return """ - Driver { - driverName='%s' - } - """ + Driver { + driverName='%s' + } + """ .formatted(driverName); } } @@ -646,6 +646,44 @@ public class ApplicationProperties { private List allowChannelIDs = new ArrayList<>(); private long processingTimeoutSeconds = 180; private long pollingIntervalMillis = 2000; + private Feedback feedback = new Feedback(); + + @Data + public static class Feedback { + private General general = new General(); + private Channel channel = new Channel(); + private User user = new User(); + + @Data + public static class General { + private Boolean enabled = true; // set to 'true' to enable feedback messages + } + + @Data + public static class Channel { + private Boolean noValidDocument = + false; // set to 'true' to deny feedback messages in channels (to avoid + // spam) + private Boolean processingError = + false; // set to 'true' to deny feedback messages in channels (to avoid + // spam) + private Boolean errorMessage = + false; // set to 'true' to deny error feedback messages in channels (to + // avoid spam) + } + + @Data + public static class User { + private Boolean noValidDocument = + false; // set to 'true' to deny feedback messages to users (to avoid + // spam) + private Boolean processingError = + false; // set to 'true' to deny feedback messages to users (to avoid + // spam) + private Boolean errorMessage = + false; // set to 'true' to deny error feedback messages to users (to avoid + } + } } @Data diff --git a/app/core/src/main/java/stirling/software/SPDF/service/telegram/TelegramPipelineBot.java b/app/core/src/main/java/stirling/software/SPDF/service/telegram/TelegramPipelineBot.java index cb93226bf..f2ea1ea21 100644 --- a/app/core/src/main/java/stirling/software/SPDF/service/telegram/TelegramPipelineBot.java +++ b/app/core/src/main/java/stirling/software/SPDF/service/telegram/TelegramPipelineBot.java @@ -107,13 +107,17 @@ public class TelegramPipelineBot extends TelegramLongPollingBot { if (update.hasMessage() && update.getMessage().hasText()) { String message_text = update.getMessage().getText(); long chat_id = update.getMessage().getChatId(); - if (message_text.equals("/start")) { + if ("/start".equals(message_text)) { sendMessage( chat_id, - "Welcome to the SPDF Telegram Bot!\n\n" - + "To get started, please send me a PDF document that you would like to process." - + " Make sure the document is in PDF format.\n\n" - + "Once I receive your document, I'll begin processing it through the pipeline."); + """ + Welcome to the SPDF Telegram Bot! + + To get started, please send me a PDF document that you would like to process. + Make sure the document is in PDF format. + + Once I receive your document, I'll begin processing it through the pipeline. + """); return; } } @@ -122,10 +126,11 @@ public class TelegramPipelineBot extends TelegramLongPollingBot { handleIncomingFile(message); return; } - - sendMessage( - chat.getId(), - "No valid file found in the message. Please send a document to process."); + if (telegramProperties.getFeedback().getGeneral().getEnabled()) { + sendMessage( + chat.getId(), + "No valid file found in the message. Please send a document to process."); + } } // --------------------------- @@ -237,7 +242,8 @@ public class TelegramPipelineBot extends TelegramLongPollingBot { if (!hasJsonConfig(chatId)) { sendMessage( chatId, - "No JSON configuration file found in the pipeline inbox folder. Please contact the administrator."); + "No JSON configuration file found in the pipeline inbox folder. Please contact" + + " the administrator."); return; } diff --git a/app/core/src/main/resources/settings.yml.template b/app/core/src/main/resources/settings.yml.template index c7928c91a..f7c798241 100644 --- a/app/core/src/main/resources/settings.yml.template +++ b/app/core/src/main/resources/settings.yml.template @@ -124,6 +124,17 @@ telegram: allowChannelIDs: [] # List of allowed Telegram channel IDs (e.g. [-1001234567890, -1009876543210]). Leave empty to allow all channels. processingTimeoutSeconds: 180 # Maximum time in seconds to wait for processing a Telegram request pollingIntervalMillis: 2000 # Interval in milliseconds between polling for new messages + feedback: + general: + enabled: true # set to 'true' to enable feedback messages + channel: + noValidDocument: false # set to 'true' to deny feedback messages in channels (to avoid spam) + processingError: false # set to 'true' to deny feedback messages in channels (to avoid spam) + errorMessage: false # set to 'true' to deny error messages in channels (to avoid spam) + user: + noValidDocument: false # set to 'true' to deny feedback messages to users (to avoid spam) + processingError: false # set to 'true' to deny feedback messages to users (to avoid spam) + errorMessage: false # set to 'true' to deny error messages to users (to avoid spam) legal: termsAndConditions: https://www.stirling.com/legal/terms-of-service # URL to the terms and conditions of your application (e.g. https://example.com/terms). Empty string to disable or filename to load from local file in static folder