diff --git a/src/main/java/wtf/beatrice/hidekobot/Configuration.java b/src/main/java/wtf/beatrice/hidekobot/Configuration.java new file mode 100644 index 0000000..a3525f6 --- /dev/null +++ b/src/main/java/wtf/beatrice/hidekobot/Configuration.java @@ -0,0 +1,15 @@ +package wtf.beatrice.hidekobot; + +public class Configuration +{ + + + private static boolean verbose = false; + + + public static boolean isVerbose() { return verbose; } + + // WARNING: verbosity spams the logs a LOT! + public static void setVerbose(boolean v) { verbose = v; } + +} diff --git a/src/main/java/wtf/beatrice/hidekobot/listeners/MessageLogger.java b/src/main/java/wtf/beatrice/hidekobot/listeners/MessageLogger.java new file mode 100644 index 0000000..80c4e11 --- /dev/null +++ b/src/main/java/wtf/beatrice/hidekobot/listeners/MessageLogger.java @@ -0,0 +1,47 @@ +package wtf.beatrice.hidekobot.listeners; + +import net.dv8tion.jda.api.entities.PrivateChannel; +import net.dv8tion.jda.api.entities.TextChannel; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; +import org.jetbrains.annotations.NotNull; +import wtf.beatrice.hidekobot.utils.Logger; + +public class MessageLogger extends ListenerAdapter +{ + // this class only gets loaded as a listener if verbosity is set to true on startup. + + + private final static String guildChannelFormat = "[%guild%] [#%channel%] %user%: %message%"; + private final static String dmFormat = "[DM] %user%: %message%"; + + private final Logger logger = new Logger(MessageLogger.class); + + @Override + public void onMessageReceived(@NotNull MessageReceivedEvent event) + { + String toLog = ""; + String userName = event.getAuthor().getName(); + String message = event.getMessage().getContentDisplay(); + + if(event.getChannel() instanceof TextChannel) + { + String guildName = ((TextChannel) event.getChannel()).getGuild().getName(); + String channelName = event.getChannel().getName(); + + toLog = guildChannelFormat + .replace("%guild%", guildName) + .replace("%channel%", channelName); + } + else if(event.getChannel() instanceof PrivateChannel) + { + toLog = dmFormat; + } + + toLog = toLog + .replace("%user%", userName) + .replace("%message%", message); + + logger.log(toLog); + } +} diff --git a/src/main/java/wtf/beatrice/hidekobot/utils/RandomUtil.java b/src/main/java/wtf/beatrice/hidekobot/utils/RandomUtil.java new file mode 100644 index 0000000..958bbfb --- /dev/null +++ b/src/main/java/wtf/beatrice/hidekobot/utils/RandomUtil.java @@ -0,0 +1,2 @@ +package wtf.beatrice.hidekobot.utils;public class RandomUtil { +}