Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve suggestion for archived thread due to inactivity #957

Merged
merged 5 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
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;
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
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;
Expand Down Expand Up @@ -104,19 +102,6 @@ public HelpSystemHelper(Config config, Database database, ChatGptService chatGpt
.collect(Collectors.toSet());
}

RestAction<Message> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +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 to make it easier to help you 👍""")
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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ private RestAction<Void> pinOriginalQuestion(ThreadChannel threadChannel) {
}

private RestAction<Message> createMessages(ThreadChannel threadChannel) {
return sendHelperHeadsUp(threadChannel)
.flatMap(any -> helper.sendExplanationMessage(threadChannel))
.flatMap(any -> createAIResponse(threadChannel));
return sendHelperHeadsUp(threadChannel).flatMap(any -> createAIResponse(threadChannel));
}

private RestAction<Message> sendHelperHeadsUp(ThreadChannel threadChannel) {
Expand Down
Loading