Skip to content
Merged
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
1 change: 0 additions & 1 deletion application/config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"heavyModerationRolePattern": "Moderator",
"softModerationRolePattern": "Moderator|Staff Assistant",
"tagManageRolePattern": "Moderator|Staff Assistant|Top Helpers .+",
"helpChannelPattern": "([a-zA-Z_]+_)?help(_\\d+)?",
"suggestions": {
"channelPattern": "tj_suggestions",
"upVoteEmoteName": "peepo_yes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private boolean handleIsValidTitle(@NotNull CharSequence title, @NotNull IReplyC
}

event.reply(
"Sorry, but the titel length (after removal of special characters) has to be between %d and %d."
"Sorry, but the title length (after removal of special characters) has to be between %d and %d."
.formatted(TITLE_COMPACT_LENGTH_MIN, TITLE_COMPACT_LENGTH_MAX))
.setEphemeral(true)
.queue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,14 @@ private static boolean shouldMessageBeCleanedUp(@NotNull Message message) {

private static @NotNull RestAction<Void> cleanupBotMessages(
@NotNull GuildMessageChannel channel, @NotNull Collection<? extends Message> messages) {
logger.debug("Cleaning up old bot messages in the staging channel");
List<String> messageIdsToDelete = messages.stream()
.filter(BotMessageCleanup::shouldMessageBeCleanedUp)
.map(Message::getId)
.toList();

logger.debug("Found {} messages to delete", messageIdsToDelete.size());

if (messageIdsToDelete.isEmpty()) {
return new CompletedRestAction<>(channel.getJDA(), null, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ RestAction<Message> sendExplanationMessage(@NotNull MessageChannel threadChannel
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 ."""));
With enough info, someone knows the answer for sure."""));

MessageAction action = threadChannel.sendMessage(message);
if (useCodeSyntaxExampleImage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public final class HelpThreadOverviewUpdater extends MessageReceiverAdapter impl
private static final Logger logger = LoggerFactory.getLogger(HelpThreadOverviewUpdater.class);

private static final String STATUS_TITLE = "Active questions";
private static final int OVERVIEW_QUESTION_LIMIT = 150;

private final HelpSystemHelper helper;
private final List<String> allCategories;
Expand Down Expand Up @@ -121,17 +122,22 @@ private void updateOverviewForGuild(@NotNull Guild guild) {

private void updateOverview(@NotNull IThreadContainer stagingChannel,
@NotNull MessageChannel overviewChannel) {
logger.debug("Updating overview of active questions");

List<ThreadChannel> activeThreads = stagingChannel.getThreadChannels()
.stream()
.filter(Predicate.not(ThreadChannel::isArchived))
.toList();

logger.debug("Found {} active questions", activeThreads.size());

MessageEmbed embed = new EmbedBuilder().setTitle(STATUS_TITLE)
.setDescription(createDescription(activeThreads))
.setColor(HelpSystemHelper.AMBIENT_COLOR)
.build();

getStatusMessage(overviewChannel).flatMap(maybeStatusMessage -> {
logger.debug("Sending the updated question overview");
if (maybeStatusMessage.isEmpty()) {
return overviewChannel.sendMessageEmbeds(embed);
}
Expand All @@ -148,6 +154,7 @@ private void updateOverview(@NotNull IThreadContainer stagingChannel,

return activeThreads.stream()
.sorted(Comparator.comparing(ThreadChannel::getTimeCreated).reversed())
.limit(OVERVIEW_QUESTION_LIMIT)
.collect(Collectors
.groupingBy(thread -> helper.getCategoryOfChannel(thread).orElse("Uncategorized")))
.entrySet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,19 @@ public BotCore(@NotNull JDA jda, @NotNull Database database, @NotNull Config con
.filter(Routine.class::isInstance)
.map(Routine.class::cast)
.forEach(routine -> {
Runnable command = () -> {
String routineName = routine.getClass().getSimpleName();
logger.debug("Running routine %s...".formatted(routineName));
routine.runRoutine(jda);
logger.debug("Finished routine %s.".formatted(routineName));
};

Routine.Schedule schedule = routine.createSchedule();
switch (schedule.mode()) {
case FIXED_RATE -> ROUTINE_SERVICE.scheduleAtFixedRate(
() -> routine.runRoutine(jda), schedule.initialDuration(),
schedule.duration(), schedule.unit());
case FIXED_DELAY -> ROUTINE_SERVICE.scheduleWithFixedDelay(
() -> routine.runRoutine(jda), schedule.initialDuration(),
schedule.duration(), schedule.unit());
case FIXED_RATE -> ROUTINE_SERVICE.scheduleAtFixedRate(command,
schedule.initialDuration(), schedule.duration(), schedule.unit());
case FIXED_DELAY -> ROUTINE_SERVICE.scheduleWithFixedDelay(command,
schedule.initialDuration(), schedule.duration(), schedule.unit());
default -> throw new AssertionError("Unsupported schedule mode");
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public final class Config {
private final String heavyModerationRolePattern;
private final String softModerationRolePattern;
private final String tagManageRolePattern;
private final String helpChannelPattern;
private final SuggestionsConfig suggestions;
private final String quarantinedRolePattern;
private final ScamBlockerConfig scamBlocker;
Expand All @@ -40,7 +39,6 @@ private Config(@JsonProperty("token") String token,
@JsonProperty("heavyModerationRolePattern") String heavyModerationRolePattern,
@JsonProperty("softModerationRolePattern") String softModerationRolePattern,
@JsonProperty("tagManageRolePattern") String tagManageRolePattern,
@JsonProperty("helpChannelPattern") String helpChannelPattern,
@JsonProperty("suggestions") SuggestionsConfig suggestions,
@JsonProperty("quarantinedRolePattern") String quarantinedRolePattern,
@JsonProperty("scamBlocker") ScamBlockerConfig scamBlocker,
Expand All @@ -55,7 +53,6 @@ private Config(@JsonProperty("token") String token,
this.heavyModerationRolePattern = heavyModerationRolePattern;
this.softModerationRolePattern = softModerationRolePattern;
this.tagManageRolePattern = tagManageRolePattern;
this.helpChannelPattern = helpChannelPattern;
this.suggestions = suggestions;
this.quarantinedRolePattern = quarantinedRolePattern;
this.scamBlocker = scamBlocker;
Expand Down Expand Up @@ -160,16 +157,6 @@ public String getTagManageRolePattern() {
return tagManageRolePattern;
}

/**
* Gets the REGEX pattern used to identify channels that are used for helping people with their
* questions.
*
* @return the channel name pattern
*/
public @NotNull String getHelpChannelPattern() {
return helpChannelPattern;
}

/**
* Gets the config for the suggestion system.
*
Expand Down
4 changes: 3 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ rootProject.name = 'TJ-Bot'
include 'application'
include 'database'
include 'formatter'
include 'logviewer'
// NOTE The logviewer does not properly work as of today.
// But it is causing major build slowdowns, so we exclude it for the time being.
// include 'logviewer'