Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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: 4 additions & 1 deletion PP.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ In certain circumstances, you have the following data protection rights:

## Usage of Data

**TJ-Bot** may use stored data, as defined below, to offer different features and services. No usage of data outside of the aformentioned cases will happen and the data is not shared with any third-party site or service.
**TJ-Bot** may use stored data, as defined below, to offer different features and services. No usage of data outside of the aforementioned cases will happen and the data is not shared with any third-party site or service.

### Databases

Expand All @@ -55,8 +55,11 @@ For example, **TJ-Bot** may associate your `user_id` with a `message_id` and a `

**TJ-Bot** may further store data that you explicitly provided for **TJ-Bot** to offer its services. For example the reason of a moderative action when using its moderation commands.

Furthermore, upon utilization of our help service, `user_id`s and `channel_id`s are stored to track when/how many questions a user asks. The data may be stored for up to **30** days.

The stored data is not linked to any information that is personally identifiable.


No other personal information outside of the above mentioned one will be stored. In particular, **TJ-Bot** does not store the content of sent messages.

### Log Files
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,24 @@
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=Together-Java_TJ-Bot&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=Together-Java_TJ-Bot)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=Together-Java_TJ-Bot&metric=security_rating)](https://sonarcloud.io/dashboard?id=Together-Java_TJ-Bot)

TJ-Bot is a Discord Bot used on the [Together Java](https://discord.com/invite/XXFUXzK) server. It is maintained by the community, anyone can contribute.
TJ-Bot is a Discord Bot used on the [Together Java](https://discord.com/invite/XXFUXzK) server. It is maintained by the community, anyone can contribute!

![bot says hello](https://i.imgur.com/FE1MJTV.png)

The idea of this project is to provide learning experience on a real-world project. You will be provided with our guidance at every step of the way, and friendly but thorough reviews!

Feel free to join our [discord server](https://discord.com/invite/XXFUXzK) if you have any questions, or require assistance with the project. :relaxed:

# Getting started

Please read [Contributing](https://github.com/Together-Java/TJ-Bot/wiki/Contributing) if you want to propose ideas and changes or even implement some yourself.
Please read [Contributing](https://github.com/Together-Java/TJ-Bot/wiki/Contributing) guidelines if you are considering helping us out!
There you will find a detailed guide on how to contribute, and plenty of resources in case this is your first time submitting a PR to an open-source project.

Head over to the [Wiki](https://github.com/Together-Java/TJ-Bot/wiki) as general entry point to the project. It provides lots of tutorials, documentation and other information, for example
* creating a discord bot and a private server;
* setting up the project locally;
* adding your own custom commands;
* a technology overview;
* guidance about how to maintain the bot (e.g. VPS, logs, databases, restart).
* creating a discord bot and a private server
* setting up the project locally
* adding your own custom commands
* a technology overview

# Download

Expand Down
3 changes: 2 additions & 1 deletion application/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ shadowJar {
}

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

implementation project(':database')
Expand All @@ -61,7 +62,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.3.0'
implementation 'com.github.freva:ascii-table:1.4.0'

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

Expand Down
3 changes: 2 additions & 1 deletion application/config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@
"Other"
],
"categoryRoleSuffix": " - Helper"
}
},
"mediaOnlyChannelPattern": "memes"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.requests.GatewayIntent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import org.jetbrains.annotations.NotNull;
import net.dv8tion.jda.api.requests.GatewayIntent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.togetherjava.tjbot.commands.Features;
import org.togetherjava.tjbot.commands.SlashCommandAdapter;
import org.togetherjava.tjbot.commands.system.BotCore;
import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.db.Database;
import org.togetherjava.tjbot.commands.SlashCommandAdapter;

import javax.security.auth.login.LoginException;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -27,8 +24,10 @@
* New commands can be created by implementing {@link SlashCommandInteractionEvent} or extending
* {@link SlashCommandAdapter}. They can then be registered in {@link Features}.
*/
public enum Application {
;
public class Application {
private Application() {
throw new UnsupportedOperationException("Utility class, construction not supported");
}

private static final Logger logger = LoggerFactory.getLogger(Application.class);
private static final String DEFAULT_CONFIG_PATH = "config.json";
Expand Down Expand Up @@ -112,8 +111,7 @@ private static void onShutdown() {
logger.info("Bot has been stopped");
}

private static void onUncaughtException(@NotNull Thread failingThread,
@NotNull Throwable failure) {
private static void onUncaughtException(Thread failingThread, Throwable failure) {
logger.error("Unknown error in thread {}.", failingThread.getName(), failure);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
* A bootstrap launcher with minimal dependencies that sets up needed parts and workarounds for the
* main logic to take over.
*/
public enum BootstrapLauncher {
;
public class BootstrapLauncher {
private BootstrapLauncher() {
throw new UnsupportedOperationException("Utility class, construction not supported");
}

/**
* Starts the main application.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package org.togetherjava.tjbot.commands;

import net.dv8tion.jda.api.JDA;
import org.jetbrains.annotations.NotNull;
import org.togetherjava.tjbot.commands.basic.*;
import org.togetherjava.tjbot.commands.basic.PingCommand;
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.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.scam.ScamBlocker;
import org.togetherjava.tjbot.commands.moderation.scam.ScamHistoryPurgeRoutine;
Expand All @@ -28,6 +31,7 @@
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 All @@ -39,8 +43,10 @@
* To add a new slash command, extend the commands returned by
* {@link #createFeatures(JDA, Database, Config)}.
*/
public enum Features {
;
public class Features {
private Features() {
throw new UnsupportedOperationException("Utility class, construction not supported");
}

/**
* Creates all features that should be registered with this application.
Expand All @@ -53,13 +59,13 @@ public enum Features {
* @param config the configuration features should use
* @return a collection of all features
*/
public static @NotNull Collection<Feature> createFeatures(@NotNull JDA jda,
@NotNull Database database, @NotNull Config config) {
@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);
HelpSystemHelper helpSystemHelper = new HelpSystemHelper(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 @@ -73,45 +79,49 @@ public enum Features {
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
.add(new AutoPruneHelperRoutine(config, helpSystemHelper, modAuditLogWriter, database));
features.add(new HelpThreadAutoArchiver(helpSystemHelper));

// Message receivers
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));

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

// Slash commands
features.add(new LogLevelCommand());
features.add(new PingCommand());
features.add(new TeXCommand());
features.add(new TagCommand(tagSystem));
features.add(new TagManageCommand(tagSystem, config, modAuditLogWriter));
features.add(new TagManageCommand(tagSystem, modAuditLogWriter));
features.add(new TagsCommand(tagSystem));
features.add(new VcActivityCommand());
features.add(new WarnCommand(actionsStore, config));
features.add(new KickCommand(actionsStore, config));
features.add(new BanCommand(actionsStore, config));
features.add(new UnbanCommand(actionsStore, config));
features.add(new AuditCommand(actionsStore, config));
features.add(new WarnCommand(actionsStore));
features.add(new KickCommand(actionsStore));
features.add(new BanCommand(actionsStore));
features.add(new UnbanCommand(actionsStore));
features.add(new AuditCommand(actionsStore));
features.add(new MuteCommand(actionsStore, config));
features.add(new UnmuteCommand(actionsStore, config));
features.add(new TopHelpersCommand(database, config));
features.add(new TopHelpersCommand(database));
features.add(new RoleSelectCommand());
features.add(new NoteCommand(actionsStore, config));
features.add(new NoteCommand(actionsStore));
features.add(new RemindCommand(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 CloseCommand(helpSystemHelper));
features.add(new CloseCommand());
features.add(new ChangeHelpCategoryCommand(config, helpSystemHelper));
features.add(new ChangeHelpTitleCommand(helpSystemHelper));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.message.MessageUpdateEvent;
import org.jetbrains.annotations.NotNull;

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

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

/**
Expand All @@ -38,7 +38,7 @@ public interface MessageReceiver extends Feature {
* @param event the event that triggered this, containing information about the corresponding
* message that was sent and received
*/
void onMessageReceived(@NotNull MessageReceivedEvent event);
void onMessageReceived(MessageReceivedEvent event);

/**
* Triggered by the core system whenever an existing message was edited in a text channel of a
Expand All @@ -47,5 +47,5 @@ public interface MessageReceiver extends Feature {
* @param event the event that triggered this, containing information about the corresponding
* message that was edited
*/
void onMessageUpdated(@NotNull MessageUpdateEvent event);
void onMessageUpdated(MessageUpdateEvent event);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.message.MessageUpdateEvent;
import org.jetbrains.annotations.NotNull;

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

/**
Expand All @@ -24,24 +24,25 @@ public abstract class MessageReceiverAdapter implements MessageReceiver {
* @param channelNamePattern the pattern matching names of channels interested in, only messages
* from matching channels will be received
*/
protected MessageReceiverAdapter(@NotNull Pattern channelNamePattern) {
protected MessageReceiverAdapter(Pattern channelNamePattern) {
this.channelNamePattern = channelNamePattern;
}

@Override
public final @NotNull Pattern getChannelNamePattern() {
@Nonnull
public final Pattern getChannelNamePattern() {
return channelNamePattern;
}

@SuppressWarnings("NoopMethodInAbstractClass")
@Override
public void onMessageReceived(@NotNull MessageReceivedEvent event) {
public void onMessageReceived(MessageReceivedEvent event) {
// Adapter does not react by default, subclasses may change this behavior
}

@SuppressWarnings("NoopMethodInAbstractClass")
@Override
public void onMessageUpdated(@NotNull MessageUpdateEvent event) {
public void onMessageUpdated(MessageUpdateEvent event) {
// Adapter does not react by default, subclasses may change this behavior
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.togetherjava.tjbot.commands;

import net.dv8tion.jda.api.JDA;
import org.jetbrains.annotations.NotNull;

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

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

/**
* Triggered by the core system on the schedule defined by {@link #createSchedule()}.
*
* @param jda the JDA instance the bot is operating with
*/
void runRoutine(@NotNull JDA jda);
void runRoutine(JDA jda);

/**
* The schedule of routines.
Expand All @@ -46,8 +46,7 @@ public interface Routine extends Feature {
* @param unit the time unit for both, {@link #initialDuration} and {@link #duration}, e.g.
* seconds
*/
record Schedule(@NotNull ScheduleMode mode, long initialDuration, long duration,
@NotNull TimeUnit unit) {
record Schedule(ScheduleMode mode, long initialDuration, long duration, TimeUnit unit) {
}


Expand Down
Loading