From 002cbf2cb71386d9de32d5cabfd24a8bb0e7b63d Mon Sep 17 00:00:00 2001 From: Jonas Date: Fri, 30 Dec 2022 16:00:38 +0100 Subject: [PATCH 1/9] Fix typos on the website (#735) --- website/src/main/resources/public/index.html | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/website/src/main/resources/public/index.html b/website/src/main/resources/public/index.html index cdb591a72c..83a2eb6aa9 100644 --- a/website/src/main/resources/public/index.html +++ b/website/src/main/resources/public/index.html @@ -126,9 +126,9 @@

We help you land a job!

Code together

-

Collaborate to our community bot and gain practice experience on a real +

Collaborate on our community bot and gain practice experience on a real project.

-

The project is big, sophisticated and most importantly beginner-friendly with +

The project is big, sophisticated, and most importantly beginner-friendly with lots of guides.

    @@ -158,7 +158,7 @@

    Our partnerships

    width="70"/>

    JetBrains

    We will frequently give away licenses to their products, - such as Intellij + such as IntelliJ IDEA Ultimate on special @@ -175,8 +175,7 @@

    Cloud Builders

    Hosting free Java conferences with expert speakers and many exciting talks.

    All profits go to Ukrainian charity funds - 💙💛 - . + 💙💛.

    @@ -196,7 +195,7 @@

    Advent of Code

    MOOC: Java Programming

    Hands down the best complete and free resource to learn Java.

    The University of Helsinki created this course, and they use it to teach - their Students programming. It comes with 14 weekly parts and exercises.

    + their students programming. It comes with 14 weekly parts and exercises.

From 674eff8168c633f934499548c1d1dc0fb62ee180 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Dec 2022 16:56:21 +0000 Subject: [PATCH 2/9] Bump mockito-core from 4.10.0 to 4.11.0 (#736) Bumps [mockito-core](https://github.com/mockito/mockito) from 4.10.0 to 4.11.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.10.0...v4.11.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- application/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/build.gradle b/application/build.gradle index 663428f86d..47b50febbc 100644 --- a/application/build.gradle +++ b/application/build.gradle @@ -74,7 +74,7 @@ dependencies { implementation 'com.github.ben-manes.caffeine:caffeine:3.1.1' - testImplementation 'org.mockito:mockito-core:4.10.0' + testImplementation 'org.mockito:mockito-core:4.11.0' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0' testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.0' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0' From 7ddbee4e1c69ae396ca63380d3fab30ea6a5fd21 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Dec 2022 16:58:19 +0000 Subject: [PATCH 3/9] Bump gradle-jooq-plugin from 8.0 to 8.1 (#738) Bumps gradle-jooq-plugin from 8.0 to 8.1. --- updated-dependencies: - dependency-name: nu.studer:gradle-jooq-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- buildSrc/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index add521571a..9cb4f30e81 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -8,5 +8,5 @@ repositories { dependencies { implementation "gradle.plugin.org.flywaydb:gradle-plugin-publishing:9.10.0" - implementation 'nu.studer:gradle-jooq-plugin:8.0' + implementation 'nu.studer:gradle-jooq-plugin:8.1' } From af20c75431e5d927ccc986b27fea6aeae0a9612b Mon Sep 17 00:00:00 2001 From: mDyingStar <70911193+mDyingStar@users.noreply.github.com> Date: Sat, 31 Dec 2022 10:46:32 +0100 Subject: [PATCH 4/9] Make code actions autodetection not trigger for top helpers+ (#733) * Adjust onMessageReceived conditions to ignore codeformatting bot responses for Top Helpers role --- application/config.json.template | 1 + .../commands/code/CodeMessageAutoDetection.java | 16 +++++++++++++--- .../org/togetherjava/tjbot/config/Config.java | 15 +++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/application/config.json.template b/application/config.json.template index 26980743ee..d85f39e581 100644 --- a/application/config.json.template +++ b/application/config.json.template @@ -10,6 +10,7 @@ "heavyModerationRolePattern": "Moderator", "softModerationRolePattern": "Moderator|Community Ambassador", "tagManageRolePattern": "Moderator|Community Ambassador|Top Helpers .+", + "excludeCodeAutoDetectionRolePattern": "Top Helpers .+|Moderator|Community Ambassador|Expert", "suggestions": { "channelPattern": "tj_suggestions", "upVoteEmoteName": "peepo_yes", diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/code/CodeMessageAutoDetection.java b/application/src/main/java/org/togetherjava/tjbot/commands/code/CodeMessageAutoDetection.java index 30d7aea1b5..1a8cd42173 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/code/CodeMessageAutoDetection.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/code/CodeMessageAutoDetection.java @@ -1,6 +1,7 @@ package org.togetherjava.tjbot.commands.code; import net.dv8tion.jda.api.entities.Message; +import net.dv8tion.jda.api.entities.Role; import net.dv8tion.jda.api.entities.channel.ChannelType; import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; @@ -10,6 +11,7 @@ import org.togetherjava.tjbot.commands.utils.MessageUtils; import org.togetherjava.tjbot.config.Config; +import java.util.List; import java.util.Optional; import java.util.function.Predicate; import java.util.regex.Pattern; @@ -22,12 +24,12 @@ public final class CodeMessageAutoDetection extends MessageReceiverAdapter { private static final long MINIMUM_LINES_OF_CODE = 3; private final CodeMessageHandler codeMessageHandler; - private final Predicate isHelpForumName; + private final Predicate isExcludedRole; /** * Creates a new instance. - * + * * @param config to figure out whether a message is from a help thread * @param codeMessageHandler to register detected code messages at for further handling */ @@ -38,11 +40,15 @@ public CodeMessageAutoDetection(Config config, CodeMessageHandler codeMessageHan isHelpForumName = Pattern.compile(config.getHelpSystem().getHelpForumPattern()).asMatchPredicate(); + + isExcludedRole = + Pattern.compile(config.getExcludeCodeAutoDetectionRolePattern()).asMatchPredicate(); } @Override public void onMessageReceived(MessageReceivedEvent event) { - if (event.isWebhookMessage() || event.getAuthor().isBot() || !isHelpThread(event)) { + if (event.isWebhookMessage() || event.getAuthor().isBot() || !isHelpThread(event) + || isSentByExcludedRole(event.getMember().getRoles())) { return; } @@ -63,6 +69,10 @@ public void onMessageReceived(MessageReceivedEvent event) { codeMessageHandler.addAndHandleCodeMessage(originalMessage, true); } + private boolean isSentByExcludedRole(List roles) { + return roles.stream().map(Role::getName).anyMatch(isExcludedRole); + } + private boolean isHelpThread(MessageReceivedEvent event) { if (event.getChannelType() != ChannelType.GUILD_PUBLIC_THREAD) { return false; diff --git a/application/src/main/java/org/togetherjava/tjbot/config/Config.java b/application/src/main/java/org/togetherjava/tjbot/config/Config.java index 7c078a97f7..830d4cadde 100644 --- a/application/src/main/java/org/togetherjava/tjbot/config/Config.java +++ b/application/src/main/java/org/togetherjava/tjbot/config/Config.java @@ -26,6 +26,7 @@ public final class Config { private final String heavyModerationRolePattern; private final String softModerationRolePattern; private final String tagManageRolePattern; + private final String excludeCodeAutoDetectionRolePattern; private final SuggestionsConfig suggestions; private final String quarantinedRolePattern; private final ScamBlockerConfig scamBlocker; @@ -54,6 +55,8 @@ private Config(@JsonProperty(value = "token", required = true) String token, required = true) String softModerationRolePattern, @JsonProperty(value = "tagManageRolePattern", required = true) String tagManageRolePattern, + @JsonProperty(value = "excludeCodeAutoDetectionRolePattern", + required = true) String excludeCodeAutoDetectionRolePattern, @JsonProperty(value = "suggestions", required = true) SuggestionsConfig suggestions, @JsonProperty(value = "quarantinedRolePattern", required = true) String quarantinedRolePattern, @@ -79,6 +82,8 @@ private Config(@JsonProperty(value = "token", required = true) String token, this.heavyModerationRolePattern = Objects.requireNonNull(heavyModerationRolePattern); this.softModerationRolePattern = Objects.requireNonNull(softModerationRolePattern); this.tagManageRolePattern = Objects.requireNonNull(tagManageRolePattern); + this.excludeCodeAutoDetectionRolePattern = + Objects.requireNonNull(excludeCodeAutoDetectionRolePattern); this.suggestions = Objects.requireNonNull(suggestions); this.quarantinedRolePattern = Objects.requireNonNull(quarantinedRolePattern); this.scamBlocker = Objects.requireNonNull(scamBlocker); @@ -209,6 +214,16 @@ public String getTagManageRolePattern() { return tagManageRolePattern; } + /** + * Gets the REGEX pattern used to identify roles that will be ignored for code actions + * auto-detection + * + * @return the REGEX pattern + */ + public String getExcludeCodeAutoDetectionRolePattern() { + return excludeCodeAutoDetectionRolePattern; + } + /** * Gets the config for the suggestion system. * From 88ce49f4fe7401f924ae78d88fc455679c29ba3c Mon Sep 17 00:00:00 2001 From: mDyingStar <70911193+mDyingStar@users.noreply.github.com> Date: Sat, 31 Dec 2022 10:47:13 +0100 Subject: [PATCH 5/9] Make code actions autodetection not trigger for top helpers+ (#733) * Adjust onMessageReceived conditions to ignore codeformatting bot responses for Top Helpers+ role From b8237ebbeea0617744d3d6312b2a6f18bc50336f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 7 Jan 2023 12:45:58 +0000 Subject: [PATCH 6/9] Bump flyway-core from 9.10.0 to 9.11.0 (#742) Bumps [flyway-core](https://github.com/flyway/flyway) from 9.10.0 to 9.11.0. - [Release notes](https://github.com/flyway/flyway/releases) - [Commits](https://github.com/flyway/flyway/compare/flyway-9.10.0...flyway-9.11.0) --- updated-dependencies: - dependency-name: org.flywaydb:flyway-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- database/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/build.gradle b/database/build.gradle index 75b1ef2393..0d74ae5cd5 100644 --- a/database/build.gradle +++ b/database/build.gradle @@ -7,7 +7,7 @@ var sqliteVersion = "3.40.0.0" dependencies { implementation 'com.google.code.findbugs:jsr305:3.0.2' implementation "org.xerial:sqlite-jdbc:${sqliteVersion}" - implementation 'org.flywaydb:flyway-core:9.10.0' + implementation 'org.flywaydb:flyway-core:9.11.0' implementation "org.jooq:jooq:$jooqVersion" implementation project(':utils') From af59cbb09443ab0fe32087a2e6200e478128694c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 7 Jan 2023 12:46:16 +0000 Subject: [PATCH 7/9] Bump gradle-plugin-publishing from 9.10.0 to 9.11.0 (#743) Bumps gradle-plugin-publishing from 9.10.0 to 9.11.0. --- updated-dependencies: - dependency-name: gradle.plugin.org.flywaydb:gradle-plugin-publishing dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- buildSrc/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 9cb4f30e81..0771553880 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -7,6 +7,6 @@ repositories { } dependencies { - implementation "gradle.plugin.org.flywaydb:gradle-plugin-publishing:9.10.0" + implementation "gradle.plugin.org.flywaydb:gradle-plugin-publishing:9.11.0" implementation 'nu.studer:gradle-jooq-plugin:8.1' } From 5b9bd08625d71527f241e4c60635c1176ca75369 Mon Sep 17 00:00:00 2001 From: Tanish <73871477+Taz03@users.noreply.github.com> Date: Sat, 7 Jan 2023 21:21:03 +0000 Subject: [PATCH 8/9] Fix modmail NPE when sent from DMs (#744) --- .../tjbot/commands/moderation/modmail/ModMailCommand.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/modmail/ModMailCommand.java b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/modmail/ModMailCommand.java index 0ab3181f7a..8f03496fd8 100644 --- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/modmail/ModMailCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/commands/moderation/modmail/ModMailCommand.java @@ -40,7 +40,6 @@ */ public final class ModMailCommand extends SlashCommandAdapter { - private static final Logger logger = LoggerFactory.getLogger(ModMailCommand.class); public static final String COMMAND_NAME = "modmail"; private static final String OPTION_MESSAGE = "message"; @@ -154,7 +153,7 @@ private MessageCreateAction createModMessage(SlashCommandInteractionEvent event, String.valueOf(userId))); } - Optional moderatorRole = event.getGuild() + Optional moderatorRole = modMailAuditLog.getGuild() .getRoles() .stream() .filter(role -> configModGroupPattern.test(role.getName())) @@ -193,5 +192,4 @@ private boolean isChannelOnCooldown(long userId) { .filter(Instant.now()::isBefore) .isPresent(); } - } From acb0b9bb311915d94565f9cb71dd5b784884be92 Mon Sep 17 00:00:00 2001 From: Tanish <73871477+Taz03@users.noreply.github.com> Date: Sun, 8 Jan 2023 08:26:11 +0000 Subject: [PATCH 9/9] fixed config template formatting (#745) --- application/config.json.template | 78 ++++++++++++++++---------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/application/config.json.template b/application/config.json.template index d85f39e581..da7081543f 100644 --- a/application/config.json.template +++ b/application/config.json.template @@ -11,42 +11,42 @@ "softModerationRolePattern": "Moderator|Community Ambassador", "tagManageRolePattern": "Moderator|Community Ambassador|Top Helpers .+", "excludeCodeAutoDetectionRolePattern": "Top Helpers .+|Moderator|Community Ambassador|Expert", - "suggestions": { - "channelPattern": "tj_suggestions", - "upVoteEmoteName": "peepo_yes", - "downVoteEmoteName": "peepo_no" - }, - "quarantinedRolePattern": "Quarantined", - "scamBlocker": { - "mode": "AUTO_DELETE_BUT_APPROVE_QUARANTINE", - "reportChannelPattern": "commands", - "suspiciousKeywords": ["nitro", "boob", "sexy", "sexi", "esex"], - "hostWhitelist": ["discord.com", "discord.gg", "discord.media", "discordapp.com", "discordapp.net", "discordstatus.com"], - "hostBlacklist": ["bit.ly"], - "suspiciousHostKeywords": ["discord", "nitro", "premium"], - "isHostSimilarToKeywordDistanceThreshold": 2 - }, - "wolframAlphaAppId": "79J52T-6239TVXHR7", - "helpSystem": { - "helpForumPattern": "questions", - "categories": [ - "Java", - "Frameworks", - "JavaFX|Swing", - "IDE", - "Build Tools", - "Database", - "Android", - "C|C++", - "Algorithms", - "Math", - "Architecture", - "Code Review", - "Together Java Bot", - "Other" - ], - "categoryRoleSuffix": " - Helper" - }, + "suggestions": { + "channelPattern": "tj_suggestions", + "upVoteEmoteName": "peepo_yes", + "downVoteEmoteName": "peepo_no" + }, + "quarantinedRolePattern": "Quarantined", + "scamBlocker": { + "mode": "AUTO_DELETE_BUT_APPROVE_QUARANTINE", + "reportChannelPattern": "commands", + "suspiciousKeywords": ["nitro", "boob", "sexy", "sexi", "esex"], + "hostWhitelist": ["discord.com", "discord.gg", "discord.media", "discordapp.com", "discordapp.net", "discordstatus.com"], + "hostBlacklist": ["bit.ly"], + "suspiciousHostKeywords": ["discord", "nitro", "premium"], + "isHostSimilarToKeywordDistanceThreshold": 2 + }, + "wolframAlphaAppId": "79J52T-6239TVXHR7", + "helpSystem": { + "helpForumPattern": "questions", + "categories": [ + "Java", + "Frameworks", + "JavaFX|Swing", + "IDE", + "Build Tools", + "Database", + "Android", + "C|C++", + "Algorithms", + "Math", + "Architecture", + "Code Review", + "Together Java Bot", + "Other" + ], + "categoryRoleSuffix": " - Helper" + }, "mediaOnlyChannelPattern": "memes", "blacklistedFileExtension": [ "application", @@ -85,7 +85,7 @@ "wsc", "wsf", "wsh" - ], - "logInfoChannelWebhook": "", - "logErrorChannelWebhook": "" + ], + "logInfoChannelWebhook": "", + "logErrorChannelWebhook": "" }