mirror of
https://github.com/Sheldan/Sissi.git
synced 2026-01-01 23:35:21 +00:00
[SIS-xxx] adding weekly text feature specific to miepscord server
This commit is contained in:
@@ -166,6 +166,13 @@
|
|||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.sheldan.sissi.application.module</groupId>
|
||||||
|
<artifactId>miepscord</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.sheldan.sissi.application.module</groupId>
|
<groupId>dev.sheldan.sissi.application.module</groupId>
|
||||||
<artifactId>rss-news</artifactId>
|
<artifactId>rss-news</artifactId>
|
||||||
|
|||||||
45
application/sissi-modules/miepscord/pom.xml
Normal file
45
application/sissi-modules/miepscord/pom.xml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>sissi-modules</artifactId>
|
||||||
|
<groupId>dev.sheldan.sissi.application</groupId>
|
||||||
|
<version>1.4.61-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>dev.sheldan.sissi.application.module</groupId>
|
||||||
|
<artifactId>miepscord</artifactId>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<descriptors>
|
||||||
|
<descriptor>src/main/assembly/liquibase.xml</descriptor>
|
||||||
|
</descriptors>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>make-assembly</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>single</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.sheldan.abstracto.scheduling</groupId>
|
||||||
|
<artifactId>scheduling-int</artifactId>
|
||||||
|
<version>${abstracto.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
|
||||||
|
<id>liquibase</id>
|
||||||
|
<formats>
|
||||||
|
<format>zip</format>
|
||||||
|
</formats>
|
||||||
|
<includeBaseDirectory>false</includeBaseDirectory>
|
||||||
|
<fileSets>
|
||||||
|
<fileSet>
|
||||||
|
<outputDirectory>.</outputDirectory>
|
||||||
|
<directory>${project.basedir}/src/main/resources/migrations</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/*</include>
|
||||||
|
</includes>
|
||||||
|
</fileSet>
|
||||||
|
</fileSets>
|
||||||
|
</assembly>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum MiepscordFeatureDefinition implements FeatureDefinition {
|
||||||
|
WEEKLY_TEXT("weeklyText");
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
MiepscordFeatureDefinition(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@PropertySource("classpath:miepscord.properties")
|
||||||
|
public class MiepscordProperties {
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord;
|
||||||
|
|
||||||
|
public class MiepscordSlashCommandNames {
|
||||||
|
public static final String MIEPSCORD_ROOT_NAME = "miepscord";
|
||||||
|
public static final String MIEPSCORD_ROOT_NAME_CONFIG = "miepscordManage";
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord.weeklytext.commands;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.command.UtilityModuleDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||||
|
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.MiepscordFeatureDefinition;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.MiepscordSlashCommandNames;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.weeklytext.service.TextItemServiceBean;
|
||||||
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class AddTextItem extends AbstractConditionableCommand {
|
||||||
|
|
||||||
|
private static final String ADD_WEEKLY_TEXT_TEXT_PARAMETER = "text";
|
||||||
|
private static final String ADD_WEEKLY_TEXT_COMMAND_NAME = "addWeeklyText";
|
||||||
|
private static final String ADD_WEEKLY_TEXT_RESPONSE = "addWeeklyText_response";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SlashCommandParameterService slashCommandParameterService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TextItemServiceBean textItemServiceBean;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InteractionService interactionService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||||
|
String weeklyText = slashCommandParameterService.getCommandOption(ADD_WEEKLY_TEXT_TEXT_PARAMETER, event, String.class);
|
||||||
|
textItemServiceBean.createTextItem(weeklyText, event.getMember());
|
||||||
|
return interactionService.replyEmbed(ADD_WEEKLY_TEXT_RESPONSE, event)
|
||||||
|
.thenApply(interactionHook -> CommandResult.fromSuccess());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandConfiguration getConfiguration() {
|
||||||
|
Parameter textitemTextParameter = Parameter
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.name(ADD_WEEKLY_TEXT_TEXT_PARAMETER)
|
||||||
|
.type(String.class)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
List<Parameter> parameters = Arrays.asList(textitemTextParameter);
|
||||||
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
SlashCommandConfig slashCommandConfig = SlashCommandConfig
|
||||||
|
.builder()
|
||||||
|
.enabled(true)
|
||||||
|
.rootCommandName(MiepscordSlashCommandNames.MIEPSCORD_ROOT_NAME_CONFIG)
|
||||||
|
.groupName("weeklytexts")
|
||||||
|
.commandName("add")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return CommandConfiguration.builder()
|
||||||
|
.name(ADD_WEEKLY_TEXT_COMMAND_NAME)
|
||||||
|
.module(UtilityModuleDefinition.UTILITY)
|
||||||
|
.templated(true)
|
||||||
|
.slashCommandOnly(true)
|
||||||
|
.slashCommandConfig(slashCommandConfig)
|
||||||
|
.async(true)
|
||||||
|
.supportsEmbedException(true)
|
||||||
|
.causesReaction(true)
|
||||||
|
.parameters(parameters)
|
||||||
|
.help(helpInfo)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeatureDefinition getFeature() {
|
||||||
|
return MiepscordFeatureDefinition.WEEKLY_TEXT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord.weeklytext.commands;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.command.UtilityModuleDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||||
|
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.MiepscordFeatureDefinition;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.MiepscordSlashCommandNames;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.weeklytext.service.TextItemServiceBean;
|
||||||
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class RemoveTextItem extends AbstractConditionableCommand {
|
||||||
|
|
||||||
|
private static final String REMOVE_WEEKLY_TEXT_ID_PARAMETER = "id";
|
||||||
|
private static final String REMOVE_WEEKLY_TEXT_COMMAND_NAME = "removeWeeklyText";
|
||||||
|
|
||||||
|
private static final String REMOVE_WEEKLY_TEXT_RESPONSE = "removeWeeklyText_response";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SlashCommandParameterService slashCommandParameterService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TextItemServiceBean textItemServiceBean;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InteractionService interactionService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||||
|
Long itemId = slashCommandParameterService.getCommandOption(REMOVE_WEEKLY_TEXT_ID_PARAMETER, event, Integer.class).longValue();
|
||||||
|
textItemServiceBean.removeTextItem(itemId);
|
||||||
|
return interactionService.replyEmbed(REMOVE_WEEKLY_TEXT_RESPONSE, event)
|
||||||
|
.thenApply(interactionHook -> CommandResult.fromSuccess());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandConfiguration getConfiguration() {
|
||||||
|
Parameter textItemId = Parameter
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.name(REMOVE_WEEKLY_TEXT_ID_PARAMETER)
|
||||||
|
.type(Long.class)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
List<Parameter> parameters = Arrays.asList(textItemId);
|
||||||
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
SlashCommandConfig slashCommandConfig = SlashCommandConfig
|
||||||
|
.builder()
|
||||||
|
.enabled(true)
|
||||||
|
.rootCommandName(MiepscordSlashCommandNames.MIEPSCORD_ROOT_NAME_CONFIG)
|
||||||
|
.groupName("weeklytexts")
|
||||||
|
.commandName("remove")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return CommandConfiguration.builder()
|
||||||
|
.name(REMOVE_WEEKLY_TEXT_COMMAND_NAME)
|
||||||
|
.module(UtilityModuleDefinition.UTILITY)
|
||||||
|
.templated(true)
|
||||||
|
.slashCommandOnly(true)
|
||||||
|
.slashCommandConfig(slashCommandConfig)
|
||||||
|
.async(true)
|
||||||
|
.supportsEmbedException(true)
|
||||||
|
.causesReaction(true)
|
||||||
|
.parameters(parameters)
|
||||||
|
.help(helpInfo)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeatureDefinition getFeature() {
|
||||||
|
return MiepscordFeatureDefinition.WEEKLY_TEXT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord.weeklytext.commands;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.command.UtilityModuleDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||||
|
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
|
||||||
|
import dev.sheldan.abstracto.core.service.PaginatorService;
|
||||||
|
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||||
|
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.MiepscordFeatureDefinition;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.MiepscordSlashCommandNames;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.weeklytext.model.database.TextItem;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.weeklytext.model.template.ShowTextItemModel;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.weeklytext.model.template.ShowTextItemsModel;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.weeklytext.service.management.TextItemServiceManagementBean;
|
||||||
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ShowTextItems extends AbstractConditionableCommand {
|
||||||
|
|
||||||
|
private static final String SHOW_WEEKLY_TEXTS_COMMAND_NAME = "showWeeklyTexts";
|
||||||
|
private static final String SHOW_WEEKLY_TEXTS_RESPONSE_TEMPLATE = "showWeeklyTexts";
|
||||||
|
public static final String NO_ITEMS_TEMPLATE_KEY = "showWeeklyTexts_no_items_found";
|
||||||
|
|
||||||
|
private static final String SHOW_WEEKLY_TEXT_SHOW_ALL_PARAMETER = "showAll";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TextItemServiceManagementBean textItemServiceManagementBean;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PaginatorService paginatorService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TemplateService templateService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InteractionService interactionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SlashCommandParameterService slashCommandParameterService;
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||||
|
boolean showAll = false;
|
||||||
|
if(slashCommandParameterService.hasCommandOption(SHOW_WEEKLY_TEXT_SHOW_ALL_PARAMETER, event)) {
|
||||||
|
showAll = slashCommandParameterService.getCommandOption(SHOW_WEEKLY_TEXT_SHOW_ALL_PARAMETER, event, Boolean.class);
|
||||||
|
}
|
||||||
|
List<TextItem> textItems;
|
||||||
|
if(showAll) {
|
||||||
|
textItems = textItemServiceManagementBean.getAllTextItems();
|
||||||
|
} else {
|
||||||
|
textItems = textItemServiceManagementBean.getAllTextItemsWithDoneFlag(false);
|
||||||
|
}
|
||||||
|
textItems.sort(Comparator.comparing(TextItem::getCreated));
|
||||||
|
if(textItems.isEmpty()) {
|
||||||
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(NO_ITEMS_TEMPLATE_KEY, new Object(), event.getGuild().getIdLong());
|
||||||
|
return interactionService.replyMessageToSend(messageToSend, event)
|
||||||
|
.thenApply(interactionHook -> CommandResult.fromSuccess());
|
||||||
|
|
||||||
|
}
|
||||||
|
List<ShowTextItemModel> convertedTextItems = textItems.stream().map(this::convertTextItem).toList();
|
||||||
|
ShowTextItemsModel items = ShowTextItemsModel
|
||||||
|
.builder()
|
||||||
|
.items(convertedTextItems)
|
||||||
|
.build();
|
||||||
|
return paginatorService.createPaginatorFromTemplate(SHOW_WEEKLY_TEXTS_RESPONSE_TEMPLATE, items, event)
|
||||||
|
.thenApply(unused -> CommandResult.fromIgnored());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ShowTextItemModel convertTextItem(TextItem textItem) {
|
||||||
|
return ShowTextItemModel
|
||||||
|
.builder()
|
||||||
|
.text(textItem.getText())
|
||||||
|
.id(textItem.getId())
|
||||||
|
.done(textItem.getDone())
|
||||||
|
.created(textItem.getCreated())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandConfiguration getConfiguration() {
|
||||||
|
|
||||||
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Parameter showAllItems = Parameter
|
||||||
|
.builder()
|
||||||
|
.name(SHOW_WEEKLY_TEXT_SHOW_ALL_PARAMETER)
|
||||||
|
.type(Boolean.class)
|
||||||
|
.optional(true)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
List<Parameter> parameters = Arrays.asList(showAllItems);
|
||||||
|
|
||||||
|
SlashCommandConfig slashCommandConfig = SlashCommandConfig
|
||||||
|
.builder()
|
||||||
|
.enabled(true)
|
||||||
|
.rootCommandName(MiepscordSlashCommandNames.MIEPSCORD_ROOT_NAME)
|
||||||
|
.groupName("weeklytexts")
|
||||||
|
.commandName("show")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return CommandConfiguration.builder()
|
||||||
|
.name(SHOW_WEEKLY_TEXTS_COMMAND_NAME)
|
||||||
|
.module(UtilityModuleDefinition.UTILITY)
|
||||||
|
.templated(true)
|
||||||
|
.slashCommandOnly(true)
|
||||||
|
.slashCommandConfig(slashCommandConfig)
|
||||||
|
.async(true)
|
||||||
|
.parameters(parameters)
|
||||||
|
.supportsEmbedException(true)
|
||||||
|
.causesReaction(true)
|
||||||
|
.help(helpInfo)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeatureDefinition getFeature() {
|
||||||
|
return MiepscordFeatureDefinition.WEEKLY_TEXT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord.weeklytext.config;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureConfig;
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.config.PostTargetEnum;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.MiepscordFeatureDefinition;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class WeeklyTextFeatureConfig implements FeatureConfig {
|
||||||
|
|
||||||
|
public static final String WEEKLY_TEXT_SERVER_ID = "WEEKLY_TEXT_SERVER_ID";
|
||||||
|
@Override
|
||||||
|
public FeatureDefinition getFeature() {
|
||||||
|
return MiepscordFeatureDefinition.WEEKLY_TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PostTargetEnum> getRequiredPostTargets() {
|
||||||
|
return Arrays.asList(WeeklyTextPostTarget.TEXT_ITEM_TARGET);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord.weeklytext.config;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.config.PostTargetEnum;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum WeeklyTextPostTarget implements PostTargetEnum {
|
||||||
|
TEXT_ITEM_TARGET("textItemTarget");
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
WeeklyTextPostTarget(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord.weeklytext.job;
|
||||||
|
|
||||||
|
import dev.sheldan.sissi.module.miepscord.weeklytext.service.TextItemServiceBean;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.quartz.DisallowConcurrentExecution;
|
||||||
|
import org.quartz.JobExecutionContext;
|
||||||
|
import org.quartz.JobExecutionException;
|
||||||
|
import org.quartz.PersistJobDataAfterExecution;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@DisallowConcurrentExecution
|
||||||
|
@Component
|
||||||
|
@PersistJobDataAfterExecution
|
||||||
|
public class WeeklyTextJob extends QuartzJobBean {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TextItemServiceBean textItemServiceBean;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
||||||
|
try {
|
||||||
|
log.info("Executing text item job.");
|
||||||
|
textItemServiceBean.sendTexItem();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Text item job failed.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord.weeklytext.model.database;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Entity
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Table(name = "text_item")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class TextItem {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "id", nullable = false)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(name = "text")
|
||||||
|
private String text;
|
||||||
|
|
||||||
|
@Column(name = "done")
|
||||||
|
private Boolean done;
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "creator_id", nullable = false)
|
||||||
|
private AUserInAServer creator;
|
||||||
|
|
||||||
|
@Column(name = "created")
|
||||||
|
private Instant created;
|
||||||
|
|
||||||
|
@Column(name = "updated")
|
||||||
|
private Instant updated;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord.weeklytext.model.template;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Getter
|
||||||
|
public class ShowTextItemModel {
|
||||||
|
private String text;
|
||||||
|
private Boolean done;
|
||||||
|
private Instant created;
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord.weeklytext.model.template;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Getter
|
||||||
|
public class ShowTextItemsModel {
|
||||||
|
private List<ShowTextItemModel> items;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord.weeklytext.model.template;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Getter
|
||||||
|
public class TextItemPostModel {
|
||||||
|
private String text;
|
||||||
|
private Long id;
|
||||||
|
private Instant created;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord.weeklytext.repository;
|
||||||
|
|
||||||
|
import dev.sheldan.sissi.module.miepscord.weeklytext.model.database.TextItem;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface TextItemRepository extends JpaRepository<TextItem, Long> {
|
||||||
|
List<TextItem> findByDoneFalseOrderByCreated();
|
||||||
|
List<TextItem> findByDone(Boolean done);
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord.weeklytext.service;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||||
|
import dev.sheldan.abstracto.core.service.PostTargetService;
|
||||||
|
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
|
||||||
|
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||||
|
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||||
|
import dev.sheldan.abstracto.core.utils.CompletableFutureList;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.weeklytext.config.WeeklyTextPostTarget;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.weeklytext.model.database.TextItem;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.weeklytext.model.template.TextItemPostModel;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.weeklytext.service.management.TextItemServiceManagementBean;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import static dev.sheldan.sissi.module.miepscord.weeklytext.config.WeeklyTextFeatureConfig.WEEKLY_TEXT_SERVER_ID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class TextItemServiceBean {
|
||||||
|
|
||||||
|
public static final String WEEKLY_TEXT_ITEM_POST_TEMPLATE = "weekly_text_item_post";
|
||||||
|
@Autowired
|
||||||
|
private TextItemServiceManagementBean textItemServiceManagementBean;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserInServerManagementService userInServerManagementService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PostTargetService postTargetService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TemplateService templateService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TextItemServiceBean self;
|
||||||
|
|
||||||
|
public TextItem createTextItem(String text, Member creator) {
|
||||||
|
log.info("Creating new text item in server {} from user {}.", creator.getGuild().getIdLong(), creator.getIdLong());
|
||||||
|
AUserInAServer creatorUser = userInServerManagementService.loadOrCreateUser(creator);
|
||||||
|
return textItemServiceManagementBean.createTextItem(text, creatorUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompletableFuture<Void> sendTexItem() {
|
||||||
|
Long serverId = Long.parseLong(System.getenv(WEEKLY_TEXT_SERVER_ID));
|
||||||
|
Optional<TextItem> nextTextItemOptional = textItemServiceManagementBean.getNextTextItem();
|
||||||
|
if(nextTextItemOptional.isEmpty()) {
|
||||||
|
log.info("No next text item found.");
|
||||||
|
return CompletableFuture.completedFuture(null);
|
||||||
|
}
|
||||||
|
TextItem textItem = nextTextItemOptional.get();
|
||||||
|
log.info("Sending text item {}.", textItem.getId());
|
||||||
|
Long textItemId = textItem.getId();
|
||||||
|
TextItemPostModel model = TextItemPostModel
|
||||||
|
.builder()
|
||||||
|
.id(textItemId)
|
||||||
|
.created(textItem.getCreated())
|
||||||
|
.text(textItem.getText())
|
||||||
|
.build();
|
||||||
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(WEEKLY_TEXT_ITEM_POST_TEMPLATE, model, serverId);
|
||||||
|
List<CompletableFuture<Message>> futures = postTargetService.sendEmbedInPostTarget(messageToSend, WeeklyTextPostTarget.TEXT_ITEM_TARGET, serverId);
|
||||||
|
CompletableFutureList<Message> futureList = new CompletableFutureList<>(futures);
|
||||||
|
return futureList.getMainFuture().thenAccept(unused -> {
|
||||||
|
self.setTexItemToDone(textItemId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void setTexItemToDone(Long id) {
|
||||||
|
Optional<TextItem> textItemOptional = textItemServiceManagementBean.findTextItemById(id);
|
||||||
|
textItemOptional.ifPresentOrElse(textItem -> {
|
||||||
|
log.info("Setting textItem with ID {} to done.", id);
|
||||||
|
textItem.setDone(true);
|
||||||
|
}, () -> log.info("TextItem {} not found.", id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeTextItem(Long id) {
|
||||||
|
log.info("Deleting text item with ID {}.", id);
|
||||||
|
textItemServiceManagementBean.deleteById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package dev.sheldan.sissi.module.miepscord.weeklytext.service.management;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.weeklytext.model.database.TextItem;
|
||||||
|
import dev.sheldan.sissi.module.miepscord.weeklytext.repository.TextItemRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class TextItemServiceManagementBean {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TextItemRepository textItemRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SecureRandom secureRandom;
|
||||||
|
|
||||||
|
public TextItem createTextItem(String text, AUserInAServer aUserInAServer) {
|
||||||
|
TextItem textItem = TextItem
|
||||||
|
.builder()
|
||||||
|
.text(text)
|
||||||
|
.creator(aUserInAServer)
|
||||||
|
.done(false)
|
||||||
|
.build();
|
||||||
|
return textItemRepository.save(textItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<TextItem> getNextTextItem() {
|
||||||
|
List<TextItem> allItems = textItemRepository.findByDoneFalseOrderByCreated();
|
||||||
|
if(allItems.isEmpty()) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
return Optional.of(allItems.get(secureRandom.nextInt(allItems.size())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<TextItem> findTextItemById(Long id) {
|
||||||
|
return textItemRepository.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteById(Long id) {
|
||||||
|
textItemRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TextItem> getAllTextItems() {
|
||||||
|
return textItemRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TextItem> getAllTextItemsWithDoneFlag(boolean done) {
|
||||||
|
return textItemRepository.findByDone(done);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
abstracto.featureFlags.weeklyText.featureName=weeklyText
|
||||||
|
abstracto.featureFlags.weeklyText.enabled=false
|
||||||
|
|
||||||
|
abstracto.postTargets.textItemTarget.name=textItemTarget
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
|
||||||
|
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<property name="utilityModule" value="(SELECT id FROM module WHERE name = 'utility')"/>
|
||||||
|
<property name="weeklyTextFeature" value="(SELECT id FROM feature WHERE key = 'weeklyText')"/>
|
||||||
|
<changeSet author="Sheldan" id="weeklyText-commands" >
|
||||||
|
<insert tableName="command">
|
||||||
|
<column name="name" value="addWeeklyText"/>
|
||||||
|
<column name="module_id" valueComputed="${utilityModule}"/>
|
||||||
|
<column name="feature_id" valueComputed="${weeklyTextFeature}"/>
|
||||||
|
</insert>
|
||||||
|
<insert tableName="command">
|
||||||
|
<column name="name" value="removeWeeklyText"/>
|
||||||
|
<column name="module_id" valueComputed="${utilityModule}"/>
|
||||||
|
<column name="feature_id" valueComputed="${weeklyTextFeature}"/>
|
||||||
|
</insert>
|
||||||
|
<insert tableName="command">
|
||||||
|
<column name="name" value="showWeeklyTexts"/>
|
||||||
|
<column name="module_id" valueComputed="${utilityModule}"/>
|
||||||
|
<column name="feature_id" valueComputed="${weeklyTextFeature}"/>
|
||||||
|
</insert>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<include file="feature.xml" relativeToChangelogFile="true"/>
|
||||||
|
<include file="command.xml" relativeToChangelogFile="true"/>
|
||||||
|
<include file="weekly_text_job.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<changeSet author="Sheldan" id="weeklyText_feature-insertion">
|
||||||
|
<insert tableName="feature">
|
||||||
|
<column name="key" value="weeklyText"/>
|
||||||
|
</insert>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<changeSet author="Sheldan" id="weekly_text_job-insert">
|
||||||
|
<insert tableName="scheduler_job">
|
||||||
|
<column name="name" value="weeklyTextJob"/>
|
||||||
|
<column name="group_name" value="miepscord"/>
|
||||||
|
<column name="clazz" value="dev.sheldan.sissi.module.miepscord.weeklytext.job.WeeklyTextJob"/>
|
||||||
|
<column name="active" value="true"/>
|
||||||
|
<column name="cron_expression" value="0 0 14 ? * FRI *"/>
|
||||||
|
<column name="recovery" value="false"/>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<include file="text_item.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
|
||||||
|
<changeSet author="Sheldan" id="text_item-table">
|
||||||
|
<createTable tableName="text_item">
|
||||||
|
<column name="id" autoIncrement="true" type="BIGINT">
|
||||||
|
<constraints nullable="false" primaryKey="true" primaryKeyName="pk_text_item"/>
|
||||||
|
</column>
|
||||||
|
<column name="text" type="VARCHAR">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="done" type="BOOLEAN">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="creator_id" type="BIGINT">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="created" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="updated" type="TIMESTAMP WITHOUT TIME ZONE"/>
|
||||||
|
</createTable>
|
||||||
|
<addForeignKeyConstraint baseColumnNames="creator_id" baseTableName="text_item" constraintName="fk_text_item_creator"
|
||||||
|
deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION"
|
||||||
|
referencedColumnNames="user_in_server_id" referencedTableName="user_in_server" validate="true"/>
|
||||||
|
<sql>
|
||||||
|
DROP TRIGGER IF EXISTS text_item_update_trigger ON text_item;
|
||||||
|
CREATE TRIGGER repost_check_channel_group_update_trigger BEFORE UPDATE ON text_item FOR EACH ROW EXECUTE PROCEDURE update_trigger_procedure();
|
||||||
|
</sql>
|
||||||
|
<sql>
|
||||||
|
DROP TRIGGER IF EXISTS text_item_insert_trigger ON text_item;
|
||||||
|
CREATE TRIGGER repost_check_channel_group_insert_trigger BEFORE INSERT ON text_item FOR EACH ROW EXECUTE PROCEDURE insert_trigger_procedure();
|
||||||
|
</sql>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<include file="1.4.61/collection.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -61,6 +61,8 @@ spec:
|
|||||||
value: {{ .Values.dbCredentials.schema }}
|
value: {{ .Values.dbCredentials.schema }}
|
||||||
- name: DEBRA_DONATION_NOTIFICATION_SERVER_ID
|
- name: DEBRA_DONATION_NOTIFICATION_SERVER_ID
|
||||||
value: "297910194841583616"
|
value: "297910194841583616"
|
||||||
|
- name: WEEKLY_TEXT_SERVER_ID
|
||||||
|
value: "{{ .Values.bot.config.weeklyTextServerId }}"
|
||||||
- name: TOKEN
|
- name: TOKEN
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ bot:
|
|||||||
propertyConfig:
|
propertyConfig:
|
||||||
hikariPoolSize: 10
|
hikariPoolSize: 10
|
||||||
host: null
|
host: null
|
||||||
|
config:
|
||||||
|
weeklyTextServerId: null
|
||||||
restApi:
|
restApi:
|
||||||
enabled: true
|
enabled: true
|
||||||
repository: harbor.sheldan.dev/sissi
|
repository: harbor.sheldan.dev/sissi
|
||||||
|
|||||||
@@ -263,6 +263,17 @@
|
|||||||
<destFileName>meetup.zip</destFileName>
|
<destFileName>meetup.zip</destFileName>
|
||||||
</artifactItem>
|
</artifactItem>
|
||||||
|
|
||||||
|
|
||||||
|
<artifactItem>
|
||||||
|
<groupId>dev.sheldan.sissi.templates</groupId>
|
||||||
|
<artifactId>miepscord-templates</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>zip</type>
|
||||||
|
<overWrite>true</overWrite>
|
||||||
|
<outputDirectory>${file.basedir}/template-data/template-artifacts/</outputDirectory>
|
||||||
|
<destFileName>miepscord.zip</destFileName>
|
||||||
|
</artifactItem>
|
||||||
|
|
||||||
<artifactItem>
|
<artifactItem>
|
||||||
<groupId>dev.sheldan.sissi.templates</groupId>
|
<groupId>dev.sheldan.sissi.templates</groupId>
|
||||||
<artifactId>debra-templates</artifactId>
|
<artifactId>debra-templates</artifactId>
|
||||||
@@ -519,6 +530,16 @@
|
|||||||
<destFileName>meetup.zip</destFileName>
|
<destFileName>meetup.zip</destFileName>
|
||||||
</artifactItem>
|
</artifactItem>
|
||||||
|
|
||||||
|
<artifactItem>
|
||||||
|
<groupId>dev.sheldan.sissi.templates.translations</groupId>
|
||||||
|
<artifactId>miepscord-translations</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>zip</type>
|
||||||
|
<overWrite>true</overWrite>
|
||||||
|
<outputDirectory>${file.basedir}/template-data/translation-artifacts/</outputDirectory>
|
||||||
|
<destFileName>miepscord.zip</destFileName>
|
||||||
|
</artifactItem>
|
||||||
|
|
||||||
<artifactItem>
|
<artifactItem>
|
||||||
<groupId>dev.sheldan.sissi.templates.translations</groupId>
|
<groupId>dev.sheldan.sissi.templates.translations</groupId>
|
||||||
<artifactId>debra-translations</artifactId>
|
<artifactId>debra-translations</artifactId>
|
||||||
@@ -754,6 +775,17 @@
|
|||||||
<destFileName>meetup.zip</destFileName>
|
<destFileName>meetup.zip</destFileName>
|
||||||
</artifactItem>
|
</artifactItem>
|
||||||
|
|
||||||
|
<artifactItem>
|
||||||
|
<groupId>dev.sheldan.sissi.application.module</groupId>
|
||||||
|
<artifactId>miepscord</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<classifier>liquibase</classifier>
|
||||||
|
<type>zip</type>
|
||||||
|
<overWrite>true</overWrite>
|
||||||
|
<outputDirectory>${file.basedir}/db-data/liquibase-artifacts/</outputDirectory>
|
||||||
|
<destFileName>miepscord.zip</destFileName>
|
||||||
|
</artifactItem>
|
||||||
|
|
||||||
<artifactItem>
|
<artifactItem>
|
||||||
<groupId>dev.sheldan.sissi.application.module</groupId>
|
<groupId>dev.sheldan.sissi.application.module</groupId>
|
||||||
<artifactId>rss-news</artifactId>
|
<artifactId>rss-news</artifactId>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
{ "zip": "meetup", "file": "meetup-changeLog.xml"},
|
{ "zip": "meetup", "file": "meetup-changeLog.xml"},
|
||||||
{ "zip": "rss-news", "file": "rssNews-changeLog.xml"},
|
{ "zip": "rss-news", "file": "rssNews-changeLog.xml"},
|
||||||
{ "zip": "debra", "file": "debra-changeLog.xml"},
|
{ "zip": "debra", "file": "debra-changeLog.xml"},
|
||||||
|
{ "zip": "miepscord", "file": "miepscord-changeLog.xml"},
|
||||||
{ "zip": "moderation", "file": "moderation-changeLog.xml"},
|
{ "zip": "moderation", "file": "moderation-changeLog.xml"},
|
||||||
{ "zip": "entertainment", "file": "entertainment-changeLog.xml"},
|
{ "zip": "entertainment", "file": "entertainment-changeLog.xml"},
|
||||||
{ "zip": "custom-command", "file": "custom-command-changeLog.xml"},
|
{ "zip": "custom-command", "file": "custom-command-changeLog.xml"},
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"core","starboard", "link-embed", "moderation", "entertainment", "custom-command", "utility", "webservices", "remind",
|
"core","starboard", "link-embed", "moderation", "entertainment", "custom-command", "utility", "webservices", "remind",
|
||||||
"suggestion", "modmail", "assignable-roles", "experience-tracking", "logging", "statistic", "twitch", "giveaway", "sticky-roles",
|
"suggestion", "modmail", "assignable-roles", "experience-tracking", "logging", "statistic", "twitch", "giveaway", "sticky-roles",
|
||||||
"image-generation",
|
"image-generation",
|
||||||
"quotes", "meetup", "debra", "rss-news",
|
"quotes", "meetup", "debra", "rss-news", "miepscord",
|
||||||
"moderation-custom", "image-generation-custom",
|
"moderation-custom", "image-generation-custom",
|
||||||
"moderation-template-overrides", "experience-template-overrides", "logging-template-overrides"
|
"moderation-template-overrides", "experience-template-overrides", "logging-template-overrides"
|
||||||
],
|
],
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
"starboard", "link-embed", "moderation", "entertainment", "custom-command", "utility", "webservices",
|
"starboard", "link-embed", "moderation", "entertainment", "custom-command", "utility", "webservices",
|
||||||
"suggestion", "remind", "modmail", "assignable-roles", "experience-tracking", "logging", "statistic", "twitch", "giveaway", "sticky-roles",
|
"suggestion", "remind", "modmail", "assignable-roles", "experience-tracking", "logging", "statistic", "twitch", "giveaway", "sticky-roles",
|
||||||
"image-generation",
|
"image-generation",
|
||||||
"quotes", "meetup", "debra", "rss-news",
|
"quotes", "meetup", "debra", "rss-news", "miepscord",
|
||||||
"moderation-custom",
|
"moderation-custom",
|
||||||
"moderation-translation-overrides", "experience-translation-overrides", "logging-translation-overrides"
|
"moderation-translation-overrides", "experience-translation-overrides", "logging-translation-overrides"
|
||||||
]
|
]
|
||||||
|
|||||||
1
pom.xml
1
pom.xml
@@ -28,6 +28,7 @@
|
|||||||
<module>application</module>
|
<module>application</module>
|
||||||
<module>templates</module>
|
<module>templates</module>
|
||||||
<module>deployment</module>
|
<module>deployment</module>
|
||||||
|
<module>application/sissi-modules/miepscord</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>sissi-templates</module>
|
<module>sissi-templates</module>
|
||||||
<module>sissi-translations</module>
|
<module>sissi-translations</module>
|
||||||
|
<module>sissi-templates/module-templates/miepscord-templates</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>dev.sheldan.sissi.templates</groupId>
|
||||||
|
<artifactId>module-templates</artifactId>
|
||||||
|
<version>1.4.61-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>miepscord-templates</artifactId>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>single</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<finalName>miepscord-templates-${project.version}</finalName>
|
||||||
|
<appendAssemblyId>false</appendAssemblyId>
|
||||||
|
<descriptors>
|
||||||
|
<descriptor>src/main/assembly/assembly.xml</descriptor>
|
||||||
|
</descriptors>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
|
||||||
|
<id>zip</id>
|
||||||
|
<includeBaseDirectory>false</includeBaseDirectory>
|
||||||
|
<formats>
|
||||||
|
<format>zip</format>
|
||||||
|
</formats>
|
||||||
|
<fileSets>
|
||||||
|
<fileSet>
|
||||||
|
<outputDirectory>.</outputDirectory>
|
||||||
|
<directory>${project.basedir}/src/main/resources</directory>
|
||||||
|
</fileSet>
|
||||||
|
</fileSets>
|
||||||
|
</assembly>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"additionalMessage": "<@safe_include "addWeeklyText_response_text"/>",
|
||||||
|
"messageConfig": {
|
||||||
|
"ephemeral": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"additionalMessage": "<@safe_include "removeWeeklyText_response_text"/>",
|
||||||
|
"messageConfig": {
|
||||||
|
"ephemeral": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<#include "format_instant">
|
||||||
|
<#assign done=item.done>
|
||||||
|
<#assign text=item.text>
|
||||||
|
<#assign id=item.id>
|
||||||
|
<#assign created><@format_instant_long_date_time instant=item.created/></#assign>
|
||||||
|
<@safe_include "showWeeklyTexts_response_text"/>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"embeds": [
|
||||||
|
{
|
||||||
|
"description": "<@safe_include "showWeeklyTexts_no_items_found_text"/>"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
<#assign exitOnly=innerModel.items?size lt 11/>
|
||||||
|
"embedConfigs": [
|
||||||
|
<#assign chunks=innerModel.items?chunk(10)>
|
||||||
|
<#list chunks as row><#assign counter=row?index><#assign row=row><#include "showWeeklyTexts_response_item_entry"><#sep>,</#list>
|
||||||
|
],
|
||||||
|
"timeoutSeconds": 120,
|
||||||
|
"restrictUser": true
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"embeds": [
|
||||||
|
{
|
||||||
|
"description": "<#list row as item><#assign item=item><@safe_include "showWeeklyTexts_item_entry"/>\n</#list>"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"buttons": [
|
||||||
|
<#include "paginator_buttons">
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
<#assign rolePing="<@&1300195018933534843>">
|
||||||
|
<#assign text=text>
|
||||||
|
"additionalMessage": "<@safe_include "weekly_text_item_post_text"/>",
|
||||||
|
"messageConfig": {
|
||||||
|
"allowsRoleMention": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>dev.sheldan.sissi.templates.translations</groupId>
|
||||||
|
<artifactId>module-translations</artifactId>
|
||||||
|
<version>1.4.61-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>miepscord-translations</artifactId>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>single</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<finalName>miepscord-translations-${project.version}</finalName>
|
||||||
|
<appendAssemblyId>false</appendAssemblyId>
|
||||||
|
<descriptors>
|
||||||
|
<descriptor>src/main/assembly/assembly.xml</descriptor>
|
||||||
|
</descriptors>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
|
||||||
|
<id>zip</id>
|
||||||
|
<includeBaseDirectory>false</includeBaseDirectory>
|
||||||
|
<formats>
|
||||||
|
<format>zip</format>
|
||||||
|
</formats>
|
||||||
|
<fileSets>
|
||||||
|
<fileSet>
|
||||||
|
<outputDirectory>.</outputDirectory>
|
||||||
|
<directory>${project.basedir}/src/main/resources</directory>
|
||||||
|
</fileSet>
|
||||||
|
</fileSets>
|
||||||
|
</assembly>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Weekly text was added.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Adds a weekly text
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Adds a new text to the list of weekly texts to be evaluated at some point.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
The text to show
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Deletes one individual weekly text
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Deletes one individual weekly text. If no text with the ID is found, nothing happens.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
The ID of the text to remove
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
If a weekly text exited, it has been removed.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Shows the current weekly texts, and whether they have been handled
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Shows the weekly texts
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Whether to show all entries (default false)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
No items found.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
(${id}) `${text}` ${done?string('✅', '❌')} Created on: ${created}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Weekly Texts
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
${rolePing} ${text}
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
<module>meetup-translations</module>
|
<module>meetup-translations</module>
|
||||||
<module>debra-translations</module>
|
<module>debra-translations</module>
|
||||||
<module>rss-news-translations</module>
|
<module>rss-news-translations</module>
|
||||||
|
<module>miepscord-translations</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user