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
5 changes: 3 additions & 2 deletions application/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {

plugins {
id 'application'
id 'com.google.cloud.tools.jib' version '3.2.1'
id 'com.google.cloud.tools.jib' version '3.3.0'
id 'com.github.johnrengelman.shadow' version '7.1.0'
id 'database-settings'
}
Expand Down Expand Up @@ -43,6 +43,7 @@ dependencies {
implementation 'org.jetbrains:annotations:23.0.0'

implementation project(':database')
implementation project(':utils')

implementation 'net.dv8tion:JDA:5.0.0-alpha.9'

Expand All @@ -62,7 +63,7 @@ dependencies {
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'

implementation 'com.github.freva:ascii-table:1.4.0'
implementation 'com.github.freva:ascii-table:1.6.0'

implementation 'com.github.ben-manes.caffeine:caffeine:3.1.1'

Expand Down
40 changes: 39 additions & 1 deletion application/config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,43 @@
],
"categoryRoleSuffix": " - Helper"
},
"mediaOnlyChannelPattern": "memes"
"mediaOnlyChannelPattern": "memes",
"blacklistedFileExtension": [
"application",
"bat",
"cmd",
"com",
"cpl",
"exe",
"gadget",
"hta",
"inf",
"jse",
"lnk",
"msc",
"msh",
"msh1",
"msh1xml",
"msh2",
"msh2xml",
"mshxml",
"msi",
"msp",
"pif",
"ps1",
"ps1xml",
"ps2",
"ps2xml",
"psc1",
"psc2",
"scf",
"scr",
"vb",
"vbe",
"vbs",
"ws",
"wsc",
"wsf",
"wsh"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public static void main(String[] args) {
Application.main(args);
}


/**
* Sets any system-properties before anything else is touched.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.togetherjava.tjbot.commands.mathcommands.wolframalpha.WolframAlphaCommand;
import org.togetherjava.tjbot.commands.mediaonly.MediaOnlyChannelListener;
import org.togetherjava.tjbot.commands.moderation.*;
import org.togetherjava.tjbot.commands.moderation.attachment.BlacklistedAttachmentListener;
import org.togetherjava.tjbot.commands.moderation.scam.ScamBlocker;
import org.togetherjava.tjbot.commands.moderation.scam.ScamHistoryPurgeRoutine;
import org.togetherjava.tjbot.commands.moderation.scam.ScamHistoryStore;
Expand All @@ -31,7 +32,6 @@
import org.togetherjava.tjbot.moderation.ModAuditLogWriter;
import org.togetherjava.tjbot.routines.ModAuditLogRoutine;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collection;

Expand Down Expand Up @@ -59,13 +59,12 @@ private Features() {
* @param config the configuration features should use
* @return a collection of all features
*/
@Nonnull
public static Collection<Feature> createFeatures(JDA jda, Database database, Config config) {
TagSystem tagSystem = new TagSystem(database);
ModerationActionsStore actionsStore = new ModerationActionsStore(database);
ModAuditLogWriter modAuditLogWriter = new ModAuditLogWriter(config);
ScamHistoryStore scamHistoryStore = new ScamHistoryStore(database);
HelpSystemHelper helpSystemHelper = new HelpSystemHelper(config, database);
HelpSystemHelper helpSystemHelper = new HelpSystemHelper(jda, config, database);

// NOTE The system can add special system relevant commands also by itself,
// hence this list may not necessarily represent the full list of all commands actually
Expand All @@ -92,6 +91,7 @@ public static Collection<Feature> createFeatures(JDA jda, Database database, Con
features.add(new ImplicitAskListener(config, helpSystemHelper));
features.add(new MediaOnlyChannelListener(config));
features.add(new FileSharingMessageListener(config));
features.add(new BlacklistedAttachmentListener(config, modAuditLogWriter));

// Event receivers
features.add(new RejoinModerationRoleListener(actionsStore, config));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.message.MessageUpdateEvent;

import javax.annotation.Nonnull;
import java.util.regex.Pattern;

/**
Expand All @@ -28,7 +27,6 @@ public interface MessageReceiver extends Feature {
*
* @return the pattern matching the names of relevant channels
*/
@Nonnull
Pattern getChannelNamePattern();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.message.MessageUpdateEvent;

import javax.annotation.Nonnull;
import java.util.regex.Pattern;

/**
Expand All @@ -29,7 +28,6 @@ protected MessageReceiverAdapter(Pattern channelNamePattern) {
}

@Override
@Nonnull
public final Pattern getChannelNamePattern() {
return channelNamePattern;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.dv8tion.jda.api.JDA;

import javax.annotation.Nonnull;
import java.util.concurrent.TimeUnit;

/**
Expand All @@ -24,7 +23,6 @@ public interface Routine extends Feature {
*
* @return the schedule of this routine
*/
@Nonnull
Schedule createSchedule();

/**
Expand All @@ -49,7 +47,6 @@ public interface Routine extends Feature {
record Schedule(ScheduleMode mode, long initialDuration, long duration, TimeUnit unit) {
}


/**
* Whether subsequent executions of a routine are executed at a fixed rate or are delayed.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.togetherjava.tjbot.commands.componentids.ComponentIdGenerator;
import org.togetherjava.tjbot.commands.componentids.Lifespan;

import javax.annotation.Nonnull;
import java.util.List;

/**
Expand Down Expand Up @@ -49,7 +48,6 @@ public interface SlashCommand extends UserInteractor {
*
* @return the description of the command
*/
@Nonnull
String getDescription();

/**
Expand All @@ -59,7 +57,6 @@ public interface SlashCommand extends UserInteractor {
*
* @return the visibility of the command
*/
@Nonnull
SlashCommandVisibility getVisibility();

/**
Expand All @@ -77,7 +74,6 @@ public interface SlashCommand extends UserInteractor {
*
* @return the command data of this command
*/
@Nonnull
SlashCommandData getData();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.togetherjava.tjbot.commands.componentids.ComponentIdGenerator;
import org.togetherjava.tjbot.commands.componentids.Lifespan;

import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -90,25 +89,21 @@ protected SlashCommandAdapter(String name, String description,
}

@Override
@Nonnull
public final String getName() {
return name;
}

@Override
@Nonnull
public final String getDescription() {
return description;
}

@Override
@Nonnull
public final SlashCommandVisibility getVisibility() {
return visibility;
}

@Override
@Nonnull
public final SlashCommandData getData() {
return data;
}
Expand Down Expand Up @@ -145,7 +140,6 @@ public void onSelectionMenu(SelectMenuInteractionEvent event, List<String> args)
* @return the generated component ID
*/
@SuppressWarnings("OverloadedVarargsMethod")
@Nonnull
protected final String generateComponentId(String... args) {
return generateComponentId(Lifespan.REGULAR, args);
}
Expand All @@ -163,7 +157,6 @@ protected final String generateComponentId(String... args) {
* @return the generated component ID
*/
@SuppressWarnings({"OverloadedVarargsMethod", "WeakerAccess"})
@Nonnull
protected final String generateComponentId(Lifespan lifespan, String... args) {
return Objects.requireNonNull(componentIdGenerator)
.generate(new ComponentId(getName(), Arrays.asList(args)), lifespan);
Expand Down Expand Up @@ -194,7 +187,6 @@ protected final String generateComponentId(Lifespan lifespan, String... args) {
* @return the generated list of options
*/
@Unmodifiable
@Nonnull
protected static List<OptionData> generateMultipleOptions(OptionData optionData,
@Range(from = 1, to = 25) int amount) {
String baseName = optionData.getName();
Expand All @@ -216,7 +208,6 @@ protected static List<OptionData> generateMultipleOptions(OptionData optionData,
* @return all options with the given prefix
*/
@Unmodifiable
@Nonnull
protected static List<OptionMapping> getMultipleOptionsByNamePrefix(
CommandInteractionPayload event, String namePrefix) {
return event.getOptions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.dv8tion.jda.api.events.interaction.component.SelectMenuInteractionEvent;
import org.togetherjava.tjbot.commands.componentids.ComponentIdGenerator;

import javax.annotation.Nonnull;
import java.util.List;

/**
Expand All @@ -27,7 +26,6 @@ public interface UserInteractor extends Feature {
*
* @return the name of the interactor
*/
@Nonnull
String getName();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
import org.togetherjava.tjbot.commands.SlashCommandVisibility;
import org.togetherjava.tjbot.commands.componentids.Lifespan;

import javax.annotation.Nonnull;
import java.awt.Color;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;


/**
* Implements the {@code /role-select} command.
* <p>
Expand Down Expand Up @@ -57,7 +55,6 @@ public final class RoleSelectCommand extends SlashCommandAdapter {

private static final int OPTIONAL_ROLES_AMOUNT = 22;


/**
* Construct an instance.
*/
Expand Down Expand Up @@ -193,7 +190,6 @@ private void sendRoleSelectionMenu(final CommandInteraction event,
event.replyEmbeds(embed).addActionRow(menu.build()).queue();
}

@Nonnull
private static SelectOption mapToSelectOption(Role role) {
RoleIcon roleIcon = role.getIcon();

Expand Down Expand Up @@ -243,7 +239,6 @@ private static void handleRoleSelection(SelectMenuInteractionEvent event, Guild
modifyRoles(event, event.getMember(), guild, rolesToAdd, rolesToRemove);
}

@Nonnull
private static Function<SelectOption, Optional<Role>> optionToRole(Guild guild) {
return option -> {
Role role = guild.getRoleById(option.getValue());
Expand All @@ -265,7 +260,6 @@ private static void modifyRoles(IReplyCallback event, Member target, Guild guild
.queue();
}

@Nonnull
private static MessageEmbed createEmbed(String title, CharSequence description) {
return new EmbedBuilder().setTitle(title)
.setDescription(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.config.SuggestionsConfig;

import javax.annotation.Nonnull;
import java.util.Optional;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -89,7 +88,6 @@ private static void reactWith(String emoteName, String fallbackUnicodeEmote, Gui
});
}

@Nonnull
private static Optional<Emote> getEmoteByName(String name, Guild guild) {
return guild.getEmotesByName(name, false).stream().findAny();
}
Expand Down
Loading