From 47febae03ce12178388ee130e3513ce922532f8c Mon Sep 17 00:00:00 2001 From: alphaBEE Date: Tue, 21 Nov 2023 00:23:37 +0530 Subject: [PATCH 1/5] improve suggestion for archived thread due to inactivity --- .../features/help/HelpThreadAutoArchiver.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java index a0f5121495..e3132d58a3 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java @@ -77,12 +77,14 @@ private void autoArchiveForThread(ThreadChannel threadChannel, Instant archiveAf if (shouldBeArchived(threadChannel, archiveAfterMoment)) { logger.debug("Auto archiving help thread {}", threadChannel.getId()); - MessageEmbed embed = new EmbedBuilder().setDescription(""" - Closed the thread due to inactivity. - - If your question was not resolved yet, feel free to just post a message \ - to reopen it, or create a new thread. But try to improve the quality of \ - your question to make it easier to help you 👍""") + MessageEmbed embed = new EmbedBuilder().setDescription( + """ + Closed the thread due to inactivity. + + If your question was not resolved yet, feel free to just post a message \ + to reopen it, or create a new thread. But try to **improve the quality** of \ + your question by adding more information such as relevant **code snippets**, **errors**,\ + expected **results**, if required steps to reproduce the error for more precise help 👍""") .setColor(HelpSystemHelper.AMBIENT_COLOR) .build(); From b2863f71633630e95a369c7061003580cdc223ef Mon Sep 17 00:00:00 2001 From: alphaBEE Date: Tue, 21 Nov 2023 00:31:00 +0530 Subject: [PATCH 2/5] space after errors in message --- .../tjbot/features/help/HelpThreadAutoArchiver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java index e3132d58a3..b694b84801 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java @@ -83,7 +83,7 @@ private void autoArchiveForThread(ThreadChannel threadChannel, Instant archiveAf If your question was not resolved yet, feel free to just post a message \ to reopen it, or create a new thread. But try to **improve the quality** of \ - your question by adding more information such as relevant **code snippets**, **errors**,\ + your question by adding more information such as relevant **code snippets**, **errors**, \ expected **results**, if required steps to reproduce the error for more precise help 👍""") .setColor(HelpSystemHelper.AMBIENT_COLOR) .build(); From a3b10d9f28f8e4821fc8d4a505fad5d7c0ce016a Mon Sep 17 00:00:00 2001 From: alphaBEE Date: Tue, 21 Nov 2023 13:46:20 +0530 Subject: [PATCH 3/5] refactor help-thread suggestions * remove suggestion on thread creation * improve message on thread inactivity --- .../tjbot/features/help/HelpSystemHelper.java | 15 -------- .../features/help/HelpThreadAutoArchiver.java | 36 ++++++++++++++----- .../help/HelpThreadCreatedListener.java | 4 +-- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java index b821246c8d..aa64f10dcc 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java @@ -1,6 +1,5 @@ package org.togetherjava.tjbot.features.help; -import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.entities.*; import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer; import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel; @@ -8,7 +7,6 @@ import net.dv8tion.jda.api.entities.channel.forums.ForumTag; import net.dv8tion.jda.api.entities.channel.forums.ForumTagSnowflake; import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; -import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel; import net.dv8tion.jda.api.interactions.components.buttons.Button; import net.dv8tion.jda.api.requests.RestAction; import net.dv8tion.jda.api.requests.restaction.MessageCreateAction; @@ -104,19 +102,6 @@ public HelpSystemHelper(Config config, Database database, ChatGptService chatGpt .collect(Collectors.toSet()); } - RestAction sendExplanationMessage(GuildMessageChannel threadChannel) { - MessageEmbed helpEmbed = new EmbedBuilder() - .setDescription( - """ - If nobody is calling back, that usually means that your question was **not well asked** and \ - hence nobody feels confident enough answering. Try to use your time to elaborate, \ - **provide details**, context, more code, examples and maybe some screenshots. \ - With enough info, someone knows the answer for sure.""") - .build(); - - return threadChannel.sendMessageEmbeds(helpEmbed); - } - /** * Determine between the title of the thread and the first message which to send to the AI. It * uses a simple heuristic of length to determine if enough context exists in a question. If the diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java index b694b84801..52151994ce 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java @@ -77,14 +77,34 @@ private void autoArchiveForThread(ThreadChannel threadChannel, Instant archiveAf if (shouldBeArchived(threadChannel, archiveAfterMoment)) { logger.debug("Auto archiving help thread {}", threadChannel.getId()); - MessageEmbed embed = new EmbedBuilder().setDescription( - """ - Closed the thread due to inactivity. - - If your question was not resolved yet, feel free to just post a message \ - to reopen it, or create a new thread. But try to **improve the quality** of \ - your question by adding more information such as relevant **code snippets**, **errors**, \ - expected **results**, if required steps to reproduce the error for more precise help 👍""") + String linkHowToAsk = "https://stackoverflow.com/help/how-to-ask"; + + MessageEmbed embed = new EmbedBuilder() + .setDescription( + """ + Your question has been closed due to inactivity. + + If it was not resolved yet, feel free to just post a message below + to reopen it, or create a new thread. + + Note that usually the reason for nobody calling back is that your + question may have been not well asked and hence no one felt confident + enough answering. + + When you reopen the thread, try to use your time to **improve the quality** + of the question by elaborating, providing **details**, context, all relevant code + snippets, any **errors** you are getting, concrete **examples** and perhaps also some + screenshots. Share your **attempt**, explain the **expected results** and compare + them to the current results. + + Also try to make the information **easily accessible** by sharing code + or assignment descriptions directly on Discord, not behind a link or + pdf file; provide some guidance for long code snippets and ensure + the **code is well formatted** and has syntax highlighting. Kindly read through + %s for more. + + With enough info, someone knows the answer for sure 👍""" + .formatted(linkHowToAsk)) .setColor(HelpSystemHelper.AMBIENT_COLOR) .build(); diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java index a5127d9ac2..9b528bd860 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java @@ -102,9 +102,7 @@ private RestAction pinOriginalQuestion(ThreadChannel threadChannel) { } private RestAction createMessages(ThreadChannel threadChannel) { - return sendHelperHeadsUp(threadChannel) - .flatMap(any -> helper.sendExplanationMessage(threadChannel)) - .flatMap(any -> createAIResponse(threadChannel)); + return sendHelperHeadsUp(threadChannel).flatMap(any -> createAIResponse(threadChannel)); } private RestAction sendHelperHeadsUp(ThreadChannel threadChannel) { From 613d54e57b6fac50030c3aba6ad133c77c7ca75d Mon Sep 17 00:00:00 2001 From: alphaBEE <61616007+ankitsmt211@users.noreply.github.com> Date: Tue, 21 Nov 2023 17:20:14 +0530 Subject: [PATCH 4/5] change pdf -> PDF --- .../tjbot/features/help/HelpThreadAutoArchiver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java index 52151994ce..bca2680db6 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java @@ -99,7 +99,7 @@ private void autoArchiveForThread(ThreadChannel threadChannel, Instant archiveAf Also try to make the information **easily accessible** by sharing code or assignment descriptions directly on Discord, not behind a link or - pdf file; provide some guidance for long code snippets and ensure + PDF-file; provide some guidance for long code snippets and ensure the **code is well formatted** and has syntax highlighting. Kindly read through %s for more. From 03aef1235035906ee713097eda6626c953f38305 Mon Sep 17 00:00:00 2001 From: alphaBEE <61616007+ankitsmt211@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:12:02 +0530 Subject: [PATCH 5/5] notify OP for thread inactivity --- .../tjbot/features/help/HelpThreadAutoArchiver.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java index bca2680db6..658bd6da3f 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java @@ -3,6 +3,7 @@ import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.MessageEmbed; import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel; import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel; @@ -65,15 +66,16 @@ private void autoArchiveForGuild(Guild guild) { logger.debug("Found {} active questions", activeThreads.size()); Instant archiveAfterMoment = computeArchiveAfterMoment(); - activeThreads - .forEach(activeThread -> autoArchiveForThread(activeThread, archiveAfterMoment)); + activeThreads.forEach(activeThread -> autoArchiveForThread(activeThread, archiveAfterMoment, + activeThread.getOwner())); } private Instant computeArchiveAfterMoment() { return Instant.now().minus(ARCHIVE_AFTER_INACTIVITY_OF); } - private void autoArchiveForThread(ThreadChannel threadChannel, Instant archiveAfterMoment) { + private void autoArchiveForThread(ThreadChannel threadChannel, Instant archiveAfterMoment, + Member author) { if (shouldBeArchived(threadChannel, archiveAfterMoment)) { logger.debug("Auto archiving help thread {}", threadChannel.getId()); @@ -108,7 +110,8 @@ private void autoArchiveForThread(ThreadChannel threadChannel, Instant archiveAf .setColor(HelpSystemHelper.AMBIENT_COLOR) .build(); - threadChannel.sendMessageEmbeds(embed) + threadChannel.sendMessage(author.getAsMention()) + .addEmbeds(embed) .flatMap(any -> threadChannel.getManager().setArchived(true)) .queue(); }