Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
40eb817
Fix JOOQ version mismatch (#640)
Nxllpointer Oct 17, 2022
4317f57
Bump io.spring.dependency-management from 1.0.13.RELEASE to 1.1.0 (#642)
dependabot[bot] Oct 19, 2022
131a06d
Implemented modal support (#626)
Tais993 Oct 19, 2022
4a39471
Bump gradle-plugin-publishing from 9.4.0 to 9.5.0 (#644)
dependabot[bot] Oct 20, 2022
0ed3317
Bump flyway-core from 9.4.0 to 9.5.0 (#643)
dependabot[bot] Oct 20, 2022
16fd842
Adding the /modmail command (#493)
DevSerendipity Oct 20, 2022
5aaba3d
Fix Top-Helper message length exploit (#649)
Nxllpointer Oct 21, 2022
2fb7483
Bump gradle-jooq-plugin from 7.1.1 to 8.0 (#652)
dependabot[bot] Oct 24, 2022
b51020f
Fixed issue with jooq version (#657)
Zabuzard Oct 24, 2022
bb788aa
Fix and speed up top helper anticheat (#659)
Nxllpointer Oct 25, 2022
522d5c3
Added suspicious keywords to scam blocker (#658)
Zabuzard Oct 26, 2022
593b073
Bump flyway-core from 9.5.0 to 9.6.0 (#664)
dependabot[bot] Oct 27, 2022
5ee24b6
Bump gradle-plugin-publishing from 9.5.0 to 9.6.0 (#663)
dependabot[bot] Oct 27, 2022
fcbd298
Bump org.sonarqube from 3.4.0.2513 to 3.5.0.2730 (#665)
dependabot[bot] Oct 28, 2022
9767ae7
Bump flyway-core from 9.6.0 to 9.7.0 (#671)
dependabot[bot] Nov 3, 2022
89dd461
Bump gradle-plugin-publishing from 9.6.0 to 9.7.0 (#670)
dependabot[bot] Nov 3, 2022
a7b7044
Added list for reminders (#650)
Taz03 Nov 4, 2022
5ae270d
Delete scam help threads (#668)
Taz03 Nov 5, 2022
d523945
Add tests for TopHelperMessageListener (#661)
Nxllpointer Nov 5, 2022
1eb7a4c
Adding delete button to filesharing response (#669)
SquidXTV Nov 5, 2022
c897f98
Added cooldown to ask command (#651)
Taz03 Nov 6, 2022
bb5f0ff
Bump jackson-dataformat-csv from 2.13.0 to 2.14.0 (#678)
dependabot[bot] Nov 8, 2022
1330ca3
Bump jackson-databind from 2.13.0 to 2.14.0 (#677)
dependabot[bot] Nov 8, 2022
59f6823
Bump jackson-dataformat-xml from 2.13.0 to 2.14.0 (#675)
dependabot[bot] Nov 8, 2022
691d1ca
Bump jackson-datatype-jsr310 from 2.13.0 to 2.14.0 (#676)
dependabot[bot] Nov 8, 2022
cefe923
Add code format command (#622)
Zabuzard Nov 8, 2022
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
11 changes: 6 additions & 5 deletions application/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies {

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

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

Expand All @@ -52,18 +53,18 @@ dependencies {

implementation 'club.minnced:discord-webhooks:0.8.2'

implementation 'org.jooq:jooq:3.17.2'
implementation "org.jooq:jooq:$jooqVersion"

implementation 'io.mikael:urlbuilder:2.0.9'

implementation 'org.scilab.forge:jlatexmath:1.0.7'
implementation 'org.scilab.forge:jlatexmath-font-greek:1.0.7'
implementation 'org.scilab.forge:jlatexmath-font-cyrillic:1.0.7'

implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.13.0'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.0'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.14.0'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.0'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.14.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.0'

implementation 'com.github.freva:ascii-table:1.8.0'

Expand Down
6 changes: 4 additions & 2 deletions application/config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"projectWebsite": "https://github.com/Together-Java/TJ-Bot",
"discordGuildInvite": "https://discord.com/invite/XXFUXzK",
"modAuditLogChannelPattern": "mod_audit_log",
"modMailChannelPattern": "modmail",
"mutedRolePattern": "Muted",
"heavyModerationRolePattern": "Moderator",
"softModerationRolePattern": "Moderator|Staff Assistant",
"tagManageRolePattern": "Moderator|Staff Assistant|Top Helpers .+",
"softModerationRolePattern": "Moderator|Community Ambassador",
"tagManageRolePattern": "Moderator|Community Ambassador|Top Helpers .+",
"suggestions": {
"channelPattern": "tj_suggestions",
"upVoteEmoteName": "peepo_yes",
Expand All @@ -18,6 +19,7 @@
"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"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* <p>
* After registration, the system will notify a command whenever one of its corresponding command
* method, buttons ({@link #onButtonClick(ButtonInteractionEvent, List)}) or menus
* ({@link #onSelectionMenu(SelectMenuInteractionEvent, List)}) have been triggered.
* ({@link #onSelectMenuSelection(SelectMenuInteractionEvent, List)}) have been triggered.
* <p>
* Some example commands are available in {@link org.togetherjava.tjbot.commands.basic}.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.togetherjava.tjbot.commands;

import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.SelectMenuInteractionEvent;
Expand All @@ -20,8 +21,8 @@
* {@link Features}.
* <p>
* Further, {@link #onButtonClick(ButtonInteractionEvent, List)} and
* {@link #onSelectionMenu(SelectMenuInteractionEvent, List)} can be overridden if desired. The
* default implementation is empty, the adapter will not react to such events.
* {@link #onSelectMenuSelection(SelectMenuInteractionEvent, List)} can be overridden if desired.
* The default implementation is empty, the adapter will not react to such events.
* <p>
* The adapter manages some getters for you, you've to create the {@link CommandData} yourself. See
* {@link #BotCommandAdapter(CommandData, CommandVisibility)}} for more info on that. Minimal
Expand Down Expand Up @@ -100,7 +101,13 @@ public void onButtonClick(ButtonInteractionEvent event, List<String> args) {

@SuppressWarnings("NoopMethodInAbstractClass")
@Override
public void onSelectionMenu(SelectMenuInteractionEvent event, List<String> args) {
public void onSelectMenuSelection(SelectMenuInteractionEvent event, List<String> args) {
// Adapter does not react by default, subclasses may change this behavior
}

@SuppressWarnings("NoopMethodInAbstractClass")
@Override
public void onModalSubmitted(ModalInteractionEvent event, List<String> args) {
// Adapter does not react by default, subclasses may change this behavior
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
import org.togetherjava.tjbot.commands.basic.RoleSelectCommand;
import org.togetherjava.tjbot.commands.basic.SuggestionsUpDownVoter;
import org.togetherjava.tjbot.commands.basic.VcActivityCommand;
import org.togetherjava.tjbot.commands.code.CodeMessageHandler;
import org.togetherjava.tjbot.commands.filesharing.FileSharingMessageListener;
import org.togetherjava.tjbot.commands.help.*;
import org.togetherjava.tjbot.commands.mathcommands.TeXCommand;
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.modmail.ModMailCommand;
import org.togetherjava.tjbot.commands.moderation.scam.ScamBlocker;
import org.togetherjava.tjbot.commands.moderation.scam.ScamHistoryPurgeRoutine;
import org.togetherjava.tjbot.commands.moderation.scam.ScamHistoryStore;
import org.togetherjava.tjbot.commands.moderation.temp.TemporaryModerationRoutine;
import org.togetherjava.tjbot.commands.reminder.RemindCommand;
import org.togetherjava.tjbot.commands.reminder.RemindRoutine;
import org.togetherjava.tjbot.commands.reminder.ReminderCommand;
import org.togetherjava.tjbot.commands.system.BotCore;
import org.togetherjava.tjbot.commands.system.LogLevelCommand;
import org.togetherjava.tjbot.commands.tags.TagCommand;
Expand Down Expand Up @@ -93,10 +95,12 @@ public static Collection<Feature> createFeatures(JDA jda, Database database, Con
features.add(new MediaOnlyChannelListener(config));
features.add(new FileSharingMessageListener(config));
features.add(new BlacklistedAttachmentListener(config, modAuditLogWriter));
features.add(new CodeMessageHandler());

// Event receivers
features.add(new RejoinModerationRoleListener(actionsStore, config));
features.add(new OnGuildLeaveCloseThreadListener(database));
features.add(new UserBannedDeleteRecentThreadsListener(database));

// Message context commands

Expand All @@ -120,12 +124,13 @@ public static Collection<Feature> createFeatures(JDA jda, Database database, Con
features.add(new TopHelpersCommand(database));
features.add(new RoleSelectCommand());
features.add(new NoteCommand(actionsStore));
features.add(new RemindCommand(database));
features.add(new ReminderCommand(database));
features.add(new QuarantineCommand(actionsStore, config));
features.add(new UnquarantineCommand(actionsStore, config));
features.add(new WhoIsCommand());
features.add(new WolframAlphaCommand(config));
features.add(new AskCommand(config, helpSystemHelper));
features.add(new AskCommand(config, helpSystemHelper, database));
features.add(new ModMailCommand(jda, config));
features.add(new HelpThreadCommand(config, helpSystemHelper));

// Mixtures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* After registration, the system will notify a command whenever one of its corresponding message
* context-commands ({@link #onMessageContext(MessageContextInteractionEvent)}), buttons
* ({@link #onButtonClick(ButtonInteractionEvent, List)}) or menus
* ({@link #onSelectionMenu(SelectMenuInteractionEvent, List)}) have been triggered.
* ({@link #onSelectMenuSelection(SelectMenuInteractionEvent, List)}) have been triggered.
* <p>
* Some example commands are available in {@link org.togetherjava.tjbot.commands.basic}.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.togetherjava.tjbot.commands;

import net.dv8tion.jda.api.events.message.MessageDeleteEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.message.MessageUpdateEvent;

Expand Down Expand Up @@ -46,4 +47,13 @@ public interface MessageReceiver extends Feature {
* message that was edited
*/
void onMessageUpdated(MessageUpdateEvent event);

/**
* Triggered by the core system whenever an existing message was deleted in a text channel of a
* guild the bot has been added to.
*
* @param event the event that triggered this, containing information about the corresponding
* message that was deleted
*/
void onMessageDeleted(MessageDeleteEvent event);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.togetherjava.tjbot.commands;

import net.dv8tion.jda.api.events.message.MessageDeleteEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.message.MessageUpdateEvent;

Expand Down Expand Up @@ -43,4 +44,10 @@ public void onMessageReceived(MessageReceivedEvent event) {
public void onMessageUpdated(MessageUpdateEvent event) {
// Adapter does not react by default, subclasses may change this behavior
}

@SuppressWarnings("NoopMethodInAbstractClass")
@Override
public void onMessageDeleted(MessageDeleteEvent event) {
// Adapter does not react by default, subclasses may change this behavior
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* After registration, the system will notify a command whenever one of its corresponding slash
* commands ({@link #onSlashCommand(SlashCommandInteractionEvent)}), buttons
* ({@link #onButtonClick(ButtonInteractionEvent, List)}) or menus
* ({@link #onSelectionMenu(SelectMenuInteractionEvent, List)}) have been triggered.
* ({@link #onSelectMenuSelection(SelectMenuInteractionEvent, List)}) have been triggered.
* <p>
* Some example commands are available in {@link org.togetherjava.tjbot.commands.basic}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
* adding it to {@link Features}.
* <p>
* Further, {@link #onButtonClick(ButtonInteractionEvent, List)} and
* {@link #onSelectionMenu(SelectMenuInteractionEvent, List)} can be overridden if desired. The
* default implementation is empty, the adapter will not react to such events.
* {@link #onSelectMenuSelection(SelectMenuInteractionEvent, List)} can be overridden if desired.
* The default implementation is empty, the adapter will not react to such events.
* <p>
* The adapter manages all command related data itself, which can be provided during construction
* (see {@link #SlashCommandAdapter(String, String, CommandVisibility)}). In order to add options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* After registration, the system will notify a command whenever one of its corresponding user
* context-commands ({@link #onUserContext(UserContextInteractionEvent)}), buttons
* ({@link #onButtonClick(ButtonInteractionEvent, List)}) or menus
* ({@link #onSelectionMenu(SelectMenuInteractionEvent, List)}) have been triggered.
* ({@link #onSelectMenuSelection(SelectMenuInteractionEvent, List)}) have been triggered.
* <p>
* Some example commands are available in {@link org.togetherjava.tjbot.commands.basic}.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.togetherjava.tjbot.commands;

import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.SelectMenuInteractionEvent;
Expand Down Expand Up @@ -75,7 +76,26 @@ public interface UserInteractor extends Feature {
* {@link SlashCommand#onSlashCommand(SlashCommandInteractionEvent)} for details on how
* these are created
*/
void onSelectionMenu(SelectMenuInteractionEvent event, List<String> args);
void onSelectMenuSelection(SelectMenuInteractionEvent event, List<String> args);


/**
* Triggered by the core system when a modal corresponding to this implementation (based on
* {@link #getName()}) has been clicked.
* <p>
* This method may be called multithreaded. In particular, there are no guarantees that it will
* be executed on the same thread repeatedly or on the same thread that other event methods have
* been called on.
* <p>
* Details are available in the given event and the event also enables implementations to
* respond to it.
*
* @param event the event that triggered this
* @param args the arguments transported with the modal, see
* {@link SlashCommand#onSlashCommand(SlashCommandInteractionEvent)} for details on how
* these are created
*/
void onModalSubmitted(ModalInteractionEvent event, List<String> args);

/**
* Triggered by the core system during its setup phase. It will provide the command a component
Expand All @@ -90,7 +110,7 @@ public interface UserInteractor extends Feature {
* given to this method during system setup. The required {@link ComponentId} instance accepts
* optional extra arguments, which, if provided, can be picked up during the corresponding event
* (see {@link #onButtonClick(ButtonInteractionEvent, List)},
* {@link #onSelectionMenu(SelectMenuInteractionEvent, List)}).
* {@link #onSelectMenuSelection(SelectMenuInteractionEvent, List)}).
* <p>
* Alternatively, if {@link BotCommandAdapter} has been extended, it also offers a handy
* {@link BotCommandAdapter#generateComponentId(String...)} method to ease the flow.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private static SelectOption mapToSelectOption(Role role) {
}

@Override
public void onSelectionMenu(SelectMenuInteractionEvent event, List<String> args) {
public void onSelectMenuSelection(SelectMenuInteractionEvent event, List<String> args) {
Guild guild = event.getGuild();
List<Role> selectedRoles = event.getSelectedOptions()
.stream()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.togetherjava.tjbot.commands.code;

import net.dv8tion.jda.api.entities.MessageEmbed;

import org.togetherjava.tjbot.commands.utils.CodeFence;

/**
* Actions that can be executed on code, such as running it.
*/
interface CodeAction {
/**
* The name of the action, displayed to the user for applying it.
*
* @return the label of the action
*/
String getLabel();

/**
* Applies the action to the given code and returns a message.
*
* @param codeFence the code to apply the action to
* @return the message to send to the user
*/
MessageEmbed apply(CodeFence codeFence);
}
Loading