Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -130,7 +130,7 @@ public static Collection<Feature> createFeatures(JDA jda, Database database, Con
HelpThreadLifecycleListener helpThreadLifecycleListener =
new HelpThreadLifecycleListener(helpSystemHelper, database);
HelpThreadCreatedListener helpThreadCreatedListener =
new HelpThreadCreatedListener(helpSystemHelper, metrics);
new HelpThreadCreatedListener(blacklistConfig.special(), helpSystemHelper, metrics);
TopHelpersService topHelpersService = new TopHelpersService(database);
TopHelpersAssignmentRoutine topHelpersAssignmentRoutine =
new TopHelpersAssignmentRoutine(config, topHelpersService, metrics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.togetherjava.tjbot.config.FeatureBlacklist;
import org.togetherjava.tjbot.features.EventReceiver;
import org.togetherjava.tjbot.features.UserInteractionType;
import org.togetherjava.tjbot.features.UserInteractor;
Expand Down Expand Up @@ -47,6 +48,7 @@
public final class HelpThreadCreatedListener extends ListenerAdapter
implements EventReceiver, UserInteractor {
private static final Logger log = LoggerFactory.getLogger(HelpThreadCreatedListener.class);
private final FeatureBlacklist<String> specialBlacklist;
private final HelpSystemHelper helper;
private final Metrics metrics;

Expand All @@ -60,10 +62,13 @@ public final class HelpThreadCreatedListener extends ListenerAdapter
/**
* Creates a new instance.
*
* @param specialBlacklist the special blacklist
* @param helper to work with the help threads
* @param metrics to track events
*/
public HelpThreadCreatedListener(HelpSystemHelper helper, Metrics metrics) {
public HelpThreadCreatedListener(FeatureBlacklist<String> specialBlacklist,
HelpSystemHelper helper, Metrics metrics) {
this.specialBlacklist = specialBlacklist;
this.helper = helper;
this.metrics = metrics;
}
Expand Down Expand Up @@ -96,10 +101,13 @@ private void handleHelpThreadCreated(ThreadChannel threadChannel) {
metrics.count("help-question_posted");
threadChannel.retrieveStartMessage().flatMap(message -> {
registerThreadDataInDB(message, threadChannel);
return sendHelperHeadsUp(threadChannel)
.flatMap(_ -> HelpThreadCreatedListener.isContextSufficient(message),
_ -> createAIResponse(threadChannel, message))
.flatMap(_ -> pinOriginalQuestion(message));
RestAction<Message> messageRestAction = sendHelperHeadsUp(threadChannel);
if (specialBlacklist.isEnabled("AutoAIResponse")) {
messageRestAction = messageRestAction.flatMap(
_ -> HelpThreadCreatedListener.isContextSufficient(message),
_ -> createAIResponse(threadChannel, message));
}
return messageRestAction.flatMap(_ -> pinOriginalQuestion(message));
}).queue();
}

Expand Down
Loading