Skip to content

Commit 96de17f

Browse files
authored
Migrated help system to forums (#705)
* Migrated help system to forums * fixed issues with multiple tags and tag limit
1 parent bc6574f commit 96de17f

18 files changed

+268
-1222
lines changed

application/config.json.template

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
},
2828
"wolframAlphaAppId": "79J52T-6239TVXHR7",
2929
"helpSystem": {
30-
"stagingChannelPattern": "ask_here",
31-
"overviewChannelPattern": "active_questions",
30+
"helpForumPattern": "questions",
3231
"categories": [
3332
"Java",
3433
"Frameworks",

application/src/main/java/org/togetherjava/tjbot/commands/Features.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public static Collection<Feature> createFeatures(JDA jda, Database database, Con
8686
features.add(new TopHelpersPurgeMessagesRoutine(database));
8787
features.add(new RemindRoutine(database));
8888
features.add(new ScamHistoryPurgeRoutine(scamHistoryStore));
89-
features.add(new BotMessageCleanup(config));
9089
features.add(new HelpThreadMetadataPurger(database));
9190
features.add(new HelpThreadActivityUpdater(helpSystemHelper));
9291
features
@@ -98,7 +97,6 @@ public static Collection<Feature> createFeatures(JDA jda, Database database, Con
9897
features.add(new TopHelpersMessageListener(database, config));
9998
features.add(new SuggestionsUpDownVoter(config));
10099
features.add(new ScamBlocker(actionsStore, scamHistoryStore, config));
101-
features.add(new ImplicitAskListener(config, helpSystemHelper));
102100
features.add(new MediaOnlyChannelListener(config));
103101
features.add(new FileSharingMessageListener(config));
104102
features.add(new BlacklistedAttachmentListener(config, modAuditLogWriter));
@@ -111,6 +109,7 @@ public static Collection<Feature> createFeatures(JDA jda, Database database, Con
111109
features.add(new OnGuildLeaveCloseThreadListener(database));
112110
features.add(new UserBannedDeleteRecentThreadsListener(database));
113111
features.add(new LeftoverBookmarksListener(bookmarksSystem));
112+
features.add(new HelpThreadCreatedListener(helpSystemHelper));
114113

115114
// Message context commands
116115

@@ -139,14 +138,12 @@ public static Collection<Feature> createFeatures(JDA jda, Database database, Con
139138
features.add(new UnquarantineCommand(actionsStore, config));
140139
features.add(new WhoIsCommand());
141140
features.add(new WolframAlphaCommand(config));
142-
features.add(new AskCommand(config, helpSystemHelper, database));
143141
features.add(new ModMailCommand(jda, config));
144142
features.add(new HelpThreadCommand(config, helpSystemHelper));
145143
features.add(new ReportCommand(config));
146144
features.add(new BookmarksCommand(bookmarksSystem));
147145

148146
// Mixtures
149-
features.add(new HelpThreadOverviewUpdater(config, helpSystemHelper));
150147

151148
return features;
152149
}

application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/BookmarksSystem.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public final class BookmarksSystem {
3939
static final Color COLOR_FAILURE = new Color(238, 153, 160);
4040

4141
private final Database database;
42-
private final Predicate<String> isOverviewChannelName;
42+
private final Predicate<String> isHelpForumName;
4343

4444
/**
4545
* Creates a new instance of the bookmarks system.
@@ -50,8 +50,8 @@ public final class BookmarksSystem {
5050
public BookmarksSystem(Config config, Database database) {
5151
this.database = database;
5252

53-
isOverviewChannelName = Pattern.compile(config.getHelpSystem().getOverviewChannelPattern())
54-
.asMatchPredicate();
53+
isHelpForumName =
54+
Pattern.compile(config.getHelpSystem().getHelpForumPattern()).asMatchPredicate();
5555
}
5656

5757
boolean isHelpThread(MessageChannelUnion channel) {
@@ -60,9 +60,9 @@ boolean isHelpThread(MessageChannelUnion channel) {
6060
}
6161

6262
ThreadChannel threadChannel = channel.asThreadChannel();
63-
String parentChannelName = threadChannel.getParentMessageChannel().getName();
63+
String parentChannelName = threadChannel.getParentChannel().getName();
6464

65-
return isOverviewChannelName.test(parentChannelName);
65+
return isHelpForumName.test(parentChannelName);
6666
}
6767

6868
boolean didUserBookmarkChannel(long userID, long channelID) {

application/src/main/java/org/togetherjava/tjbot/commands/code/CodeMessageAutoDetection.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ public final class CodeMessageAutoDetection extends MessageReceiverAdapter {
2323

2424
private final CodeMessageHandler codeMessageHandler;
2525

26-
private final Predicate<String> isStagingChannelName;
27-
private final Predicate<String> isOverviewChannelName;
26+
private final Predicate<String> isHelpForumName;
2827

2928
/**
3029
* Creates a new instance.
@@ -37,10 +36,8 @@ public CodeMessageAutoDetection(Config config, CodeMessageHandler codeMessageHan
3736

3837
this.codeMessageHandler = codeMessageHandler;
3938

40-
isStagingChannelName = Pattern.compile(config.getHelpSystem().getStagingChannelPattern())
41-
.asMatchPredicate();
42-
isOverviewChannelName = Pattern.compile(config.getHelpSystem().getOverviewChannelPattern())
43-
.asMatchPredicate();
39+
isHelpForumName =
40+
Pattern.compile(config.getHelpSystem().getHelpForumPattern()).asMatchPredicate();
4441
}
4542

4643
@Override
@@ -73,7 +70,6 @@ private boolean isHelpThread(MessageReceivedEvent event) {
7370

7471
ThreadChannel thread = event.getChannel().asThreadChannel();
7572
String rootChannelName = thread.getParentChannel().getName();
76-
return isStagingChannelName.test(rootChannelName)
77-
|| isOverviewChannelName.test(rootChannelName);
73+
return isHelpForumName.test(rootChannelName);
7874
}
7975
}

application/src/main/java/org/togetherjava/tjbot/commands/filesharing/FileSharingMessageListener.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ public class FileSharingMessageListener extends MessageReceiverAdapter implement
6363
private final Set<String> extensionFilter = Set.of("txt", "java", "gradle", "xml", "kt", "json",
6464
"fxml", "css", "c", "h", "cpp", "py", "yml");
6565

66-
private final Predicate<String> isStagingChannelName;
67-
private final Predicate<String> isOverviewChannelName;
66+
private final Predicate<String> isHelpForumName;
6867
private final Predicate<String> isSoftModRole;
6968

7069
/**
@@ -77,10 +76,8 @@ public FileSharingMessageListener(Config config) {
7776
super(Pattern.compile(".*"));
7877

7978
gistApiKey = config.getGistApiKey();
80-
isStagingChannelName = Pattern.compile(config.getHelpSystem().getStagingChannelPattern())
81-
.asMatchPredicate();
82-
isOverviewChannelName = Pattern.compile(config.getHelpSystem().getOverviewChannelPattern())
83-
.asMatchPredicate();
79+
isHelpForumName =
80+
Pattern.compile(config.getHelpSystem().getHelpForumPattern()).asMatchPredicate();
8481
isSoftModRole = Pattern.compile(config.getSoftModerationRolePattern()).asMatchPredicate();
8582
}
8683

@@ -245,8 +242,7 @@ private boolean isHelpThread(MessageReceivedEvent event) {
245242

246243
ThreadChannel thread = event.getChannel().asThreadChannel();
247244
String rootChannelName = thread.getParentChannel().getName();
248-
return isStagingChannelName.test(rootChannelName)
249-
|| isOverviewChannelName.test(rootChannelName);
245+
return isHelpForumName.test(rootChannelName);
250246
}
251247

252248
private void deleteGist(String gistId) {

0 commit comments

Comments
 (0)