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
12 changes: 7 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@
"extensions": [
"vscjava.vscode-java-pack",
"vscjava.vscode-gradle",
"alexcvzz.vscode-sqlite",
"richardwillis.vscode-spotless-gradle"
"alexcvzz.vscode-sqlite"
],
"settings": {
"[java]": {
"spotlessGradle.format.enable": true,
"editor.defaultFormatter": "richardwillis.vscode-spotless-gradle"
"java.compile.nullAnalysis.mode": "disabled",
"java.format.settings.url": "meta/formatting/google-style-eclipse.xml",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"java.format.enabled": true
}
}
}
},
"postCreateCommand": {
"config": "cp application/config.json.template application/config.json"
}
}
}
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,15 @@ logviewer/pnpm-lock.yaml
logviewer/webpack.config.js
logviewer/webpack.generated.js
.DS_Store

# VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"vscjava.vscode-gradle",
"github.vscode-pull-request-github",
"vscjava.vscode-java-pack",
"alexcvzz.vscode-sqlite"
]
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
//Configure the JDK to Java 18 in settings
"java.compile.nullAnalysis.mode": "disabled",
"java.format.settings.url": "meta/formatting/google-style-eclipse.xml",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"java.format.enabled": true,
}
2 changes: 1 addition & 1 deletion application/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ shadowJar {

dependencies {
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'org.jetbrains:annotations:23.0.0'
implementation 'org.jetbrains:annotations:23.1.0'

implementation project(':database')
implementation project(':utils')
Expand Down
3 changes: 1 addition & 2 deletions application/config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
},
"wolframAlphaAppId": "79J52T-6239TVXHR7",
"helpSystem": {
"stagingChannelPattern": "ask_here",
"overviewChannelPattern": "active_questions",
"helpForumPattern": "questions",
"categories": [
"Java",
"Frameworks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public static Collection<Feature> createFeatures(JDA jda, Database database, Con
features.add(new TopHelpersPurgeMessagesRoutine(database));
features.add(new RemindRoutine(database));
features.add(new ScamHistoryPurgeRoutine(scamHistoryStore));
features.add(new BotMessageCleanup(config));
features.add(new HelpThreadMetadataPurger(database));
features.add(new HelpThreadActivityUpdater(helpSystemHelper));
features
Expand All @@ -98,7 +97,6 @@ public static Collection<Feature> createFeatures(JDA jda, Database database, Con
features.add(new TopHelpersMessageListener(database, config));
features.add(new SuggestionsUpDownVoter(config));
features.add(new ScamBlocker(actionsStore, scamHistoryStore, config));
features.add(new ImplicitAskListener(config, helpSystemHelper));
features.add(new MediaOnlyChannelListener(config));
features.add(new FileSharingMessageListener(config));
features.add(new BlacklistedAttachmentListener(config, modAuditLogWriter));
Expand All @@ -111,6 +109,7 @@ public static Collection<Feature> createFeatures(JDA jda, Database database, Con
features.add(new OnGuildLeaveCloseThreadListener(database));
features.add(new UserBannedDeleteRecentThreadsListener(database));
features.add(new LeftoverBookmarksListener(bookmarksSystem));
features.add(new HelpThreadCreatedListener(helpSystemHelper));

// Message context commands

Expand Down Expand Up @@ -139,14 +138,12 @@ public static Collection<Feature> createFeatures(JDA jda, Database database, Con
features.add(new UnquarantineCommand(actionsStore, config));
features.add(new WhoIsCommand());
features.add(new WolframAlphaCommand(config));
features.add(new AskCommand(config, helpSystemHelper, database));
features.add(new ModMailCommand(jda, config));
features.add(new HelpThreadCommand(config, helpSystemHelper));
features.add(new ReportCommand(config));
features.add(new BookmarksCommand(bookmarksSystem));

// Mixtures
features.add(new HelpThreadOverviewUpdater(config, helpSystemHelper));

return features;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class BookmarksSystem {
static final Color COLOR_FAILURE = new Color(238, 153, 160);

private final Database database;
private final Predicate<String> isOverviewChannelName;
private final Predicate<String> isHelpForumName;

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

isOverviewChannelName = Pattern.compile(config.getHelpSystem().getOverviewChannelPattern())
.asMatchPredicate();
isHelpForumName =
Pattern.compile(config.getHelpSystem().getHelpForumPattern()).asMatchPredicate();
}

boolean isHelpThread(MessageChannelUnion channel) {
Expand All @@ -60,9 +60,9 @@ boolean isHelpThread(MessageChannelUnion channel) {
}

ThreadChannel threadChannel = channel.asThreadChannel();
String parentChannelName = threadChannel.getParentMessageChannel().getName();
String parentChannelName = threadChannel.getParentChannel().getName();

return isOverviewChannelName.test(parentChannelName);
return isHelpForumName.test(parentChannelName);
}

boolean didUserBookmarkChannel(long userID, long channelID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public final class CodeMessageAutoDetection extends MessageReceiverAdapter {

private final CodeMessageHandler codeMessageHandler;

private final Predicate<String> isStagingChannelName;
private final Predicate<String> isOverviewChannelName;
private final Predicate<String> isHelpForumName;

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

this.codeMessageHandler = codeMessageHandler;

isStagingChannelName = Pattern.compile(config.getHelpSystem().getStagingChannelPattern())
.asMatchPredicate();
isOverviewChannelName = Pattern.compile(config.getHelpSystem().getOverviewChannelPattern())
.asMatchPredicate();
isHelpForumName =
Pattern.compile(config.getHelpSystem().getHelpForumPattern()).asMatchPredicate();
}

@Override
Expand Down Expand Up @@ -73,7 +70,6 @@ private boolean isHelpThread(MessageReceivedEvent event) {

ThreadChannel thread = event.getChannel().asThreadChannel();
String rootChannelName = thread.getParentChannel().getName();
return isStagingChannelName.test(rootChannelName)
|| isOverviewChannelName.test(rootChannelName);
return isHelpForumName.test(rootChannelName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ public class FileSharingMessageListener extends MessageReceiverAdapter implement
private final Set<String> extensionFilter = Set.of("txt", "java", "gradle", "xml", "kt", "json",
"fxml", "css", "c", "h", "cpp", "py", "yml");

private final Predicate<String> isStagingChannelName;
private final Predicate<String> isOverviewChannelName;
private final Predicate<String> isHelpForumName;
private final Predicate<String> isSoftModRole;

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

gistApiKey = config.getGistApiKey();
isStagingChannelName = Pattern.compile(config.getHelpSystem().getStagingChannelPattern())
.asMatchPredicate();
isOverviewChannelName = Pattern.compile(config.getHelpSystem().getOverviewChannelPattern())
.asMatchPredicate();
isHelpForumName =
Pattern.compile(config.getHelpSystem().getHelpForumPattern()).asMatchPredicate();
isSoftModRole = Pattern.compile(config.getSoftModerationRolePattern()).asMatchPredicate();
}

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

ThreadChannel thread = event.getChannel().asThreadChannel();
String rootChannelName = thread.getParentChannel().getName();
return isStagingChannelName.test(rootChannelName)
|| isOverviewChannelName.test(rootChannelName);
return isHelpForumName.test(rootChannelName);
}

private void deleteGist(String gistId) {
Expand Down
Loading