mirror of
https://github.com/Sheldan/Sissi.git
synced 2026-01-26 19:21:43 +00:00
[SIS-11] adding debra donation notification support
This commit is contained in:
4
README
Normal file
4
README
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
|
Attributions:
|
||||||
|
Code for debra module has been inspired with approval of zinnsoldat91 by: https://github.com/zinnsoldat91/spendenbot. The code has been adapted to fit into the structure.
|
||||||
@@ -134,6 +134,12 @@
|
|||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.sheldan.sissi.application.module</groupId>
|
||||||
|
<artifactId>debra</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- sissi customizations -->
|
<!-- sissi customizations -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
37
application/sissi-modules/debra/pom.xml
Normal file
37
application/sissi-modules/debra/pom.xml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?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>
|
||||||
|
<groupId>dev.sheldan.sissi.application</groupId>
|
||||||
|
<artifactId>sissi-modules</artifactId>
|
||||||
|
<version>1.3.6-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>dev.sheldan.sissi.application.module</groupId>
|
||||||
|
<artifactId>debra</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>
|
||||||
|
|
||||||
|
</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.debra;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
|
||||||
|
|
||||||
|
public class DonationAmountNotFoundException extends AbstractoTemplatableException {
|
||||||
|
@Override
|
||||||
|
public String getTemplateName() {
|
||||||
|
return "donation_amount_not_found_exception";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getTemplateModel() {
|
||||||
|
return new Object();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package dev.sheldan.sissi.module.debra.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.execution.CommandContext;
|
||||||
|
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.service.ChannelService;
|
||||||
|
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||||
|
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||||
|
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||||
|
import dev.sheldan.sissi.module.debra.config.DebraFeatureDefinition;
|
||||||
|
import dev.sheldan.sissi.module.debra.config.DebraSlashCommandNames;
|
||||||
|
import dev.sheldan.sissi.module.debra.model.commands.DonationsModel;
|
||||||
|
import dev.sheldan.sissi.module.debra.service.DonationService;
|
||||||
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class Donations extends AbstractConditionableCommand {
|
||||||
|
|
||||||
|
private static final String DONATIONS_COMMAND_NAME = "donations";
|
||||||
|
private static final String DONATIONS_RESPONSE_TEMPLATE_KEY = "donations_response";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ChannelService channelService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InteractionService interactionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DonationService donationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TemplateService templateService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||||
|
MessageToSend messageToSend = getDonationMessageToSend();
|
||||||
|
return FutureUtils.toSingleFutureGeneric(channelService.sendMessageToSendToChannel(messageToSend, commandContext.getChannel()))
|
||||||
|
.thenApply(unused -> CommandResult.fromSuccess());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||||
|
MessageToSend messageToSend = getDonationMessageToSend();
|
||||||
|
return interactionService.replyMessageToSend(messageToSend, event)
|
||||||
|
.thenApply(interactionHook -> CommandResult.fromSuccess());
|
||||||
|
}
|
||||||
|
|
||||||
|
private MessageToSend getDonationMessageToSend() {
|
||||||
|
BigDecimal currentDonationAmount = donationService.fetchCurrentDonationAmount();
|
||||||
|
DonationsModel donationModel = DonationsModel
|
||||||
|
.builder()
|
||||||
|
.donationAmount(currentDonationAmount)
|
||||||
|
.build();
|
||||||
|
return templateService.renderEmbedTemplate(DONATIONS_RESPONSE_TEMPLATE_KEY, donationModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandConfiguration getConfiguration() {
|
||||||
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
SlashCommandConfig slashCommandConfig = SlashCommandConfig
|
||||||
|
.builder()
|
||||||
|
.enabled(true)
|
||||||
|
.rootCommandName(DebraSlashCommandNames.DEBRA)
|
||||||
|
.commandName("donations")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return CommandConfiguration.builder()
|
||||||
|
.name(DONATIONS_COMMAND_NAME)
|
||||||
|
.module(UtilityModuleDefinition.UTILITY)
|
||||||
|
.templated(true)
|
||||||
|
.slashCommandConfig(slashCommandConfig)
|
||||||
|
.async(true)
|
||||||
|
.supportsEmbedException(true)
|
||||||
|
.causesReaction(false)
|
||||||
|
.help(helpInfo)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeatureDefinition getFeature() {
|
||||||
|
return DebraFeatureDefinition.DEBRA;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package dev.sheldan.sissi.module.debra.config;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureConfig;
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.config.PostTargetEnum;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class DebraFeatureConfig implements FeatureConfig {
|
||||||
|
@Override
|
||||||
|
public FeatureDefinition getFeature() {
|
||||||
|
return DebraFeatureDefinition.DEBRA;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PostTargetEnum> getRequiredPostTargets() {
|
||||||
|
return Arrays.asList(DebraPostTarget.DEBRA_DONATION_NOTIFICATION);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package dev.sheldan.sissi.module.debra.config;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum DebraFeatureDefinition implements FeatureDefinition {
|
||||||
|
DEBRA("debra");
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
DebraFeatureDefinition(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package dev.sheldan.sissi.module.debra.config;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.config.PostTargetEnum;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum DebraPostTarget implements PostTargetEnum {
|
||||||
|
DEBRA_DONATION_NOTIFICATION("debraDonationNotification");
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
DebraPostTarget(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package dev.sheldan.sissi.module.debra.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@PropertySource("classpath:debra.properties")
|
||||||
|
public class DebraPropertieSource {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package dev.sheldan.sissi.module.debra.config;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ConfigurationProperties(prefix = "sissi.debra")
|
||||||
|
public class DebraProperties {
|
||||||
|
private String websocketURL;
|
||||||
|
private String donationsPageURL;
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package dev.sheldan.sissi.module.debra.config;
|
||||||
|
|
||||||
|
public class DebraSlashCommandNames {
|
||||||
|
public static final String DEBRA = "debra";
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package dev.sheldan.sissi.module.debra.listener;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.listener.AsyncStartupListener;
|
||||||
|
import dev.sheldan.sissi.module.debra.config.DebraProperties;
|
||||||
|
import dev.sheldan.sissi.module.debra.model.Donation;
|
||||||
|
import dev.sheldan.sissi.module.debra.service.DonationService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import okhttp3.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class WebsocketListener extends WebSocketListener implements AsyncStartupListener {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DonationService donationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DebraProperties debraProperties;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onOpen(WebSocket webSocket, Response response) {
|
||||||
|
log.info("Connected to donation websocket.");
|
||||||
|
super.onOpen(webSocket, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessage(WebSocket webSocket, String text) {
|
||||||
|
log.info("Handling received message on websocket.");
|
||||||
|
try {
|
||||||
|
Donation donation = donationService.parseDonationFromMessage(text);
|
||||||
|
donationService.sendDonationNotification(donation).thenAccept(unused -> {
|
||||||
|
log.info("Successfully notified about donation.");
|
||||||
|
}).exceptionally(throwable -> {
|
||||||
|
log.error("Failed to notify about donation.", throwable);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
} catch (Exception exception) {
|
||||||
|
log.error("Failed to handle websocket message.", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
OkHttpClient client = new OkHttpClient.Builder()
|
||||||
|
.readTimeout(0, TimeUnit.MILLISECONDS)
|
||||||
|
.retryOnConnectionFailure(true)
|
||||||
|
.build();
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(debraProperties.getWebsocketURL())
|
||||||
|
.build();
|
||||||
|
client.newWebSocket(request, this);
|
||||||
|
client.dispatcher().executorService().shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package dev.sheldan.sissi.module.debra.model;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
@ToString
|
||||||
|
public class Donation {
|
||||||
|
private String donatorName;
|
||||||
|
private BigDecimal amount;
|
||||||
|
private String message;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package dev.sheldan.sissi.module.debra.model.commands;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
public class DonationsModel {
|
||||||
|
private BigDecimal donationAmount;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package dev.sheldan.sissi.module.debra.model.listener;
|
||||||
|
|
||||||
|
import dev.sheldan.sissi.module.debra.model.Donation;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
public class DonationNotificationModel {
|
||||||
|
private Donation donation;
|
||||||
|
private BigDecimal totalDonationAmount;
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package dev.sheldan.sissi.module.debra.service;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.service.PostTargetService;
|
||||||
|
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||||
|
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||||
|
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||||
|
import dev.sheldan.sissi.module.debra.DonationAmountNotFoundException;
|
||||||
|
import dev.sheldan.sissi.module.debra.config.DebraPostTarget;
|
||||||
|
import dev.sheldan.sissi.module.debra.config.DebraProperties;
|
||||||
|
import dev.sheldan.sissi.module.debra.model.Donation;
|
||||||
|
import dev.sheldan.sissi.module.debra.model.listener.DonationNotificationModel;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class DonationService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PostTargetService postTargetService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DebraProperties debraProperties;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TemplateService templateService;
|
||||||
|
|
||||||
|
private static final String DONATION_NOTIFICATION_TEMPLATE_KEY = "debra_donation_notification";
|
||||||
|
|
||||||
|
private static final Pattern MESSAGE_PATTERN = Pattern.compile("(.*) hat (\\d{1,9},\\d{2}) Euro gespendet!<br \\/>Vielen Dank!<br \\/>Nachricht:<br \\/>(.*)");
|
||||||
|
private static final Pattern DONATION_PAGE_AMOUNT_PARTNER = Pattern.compile("\"metric4\",\\s*\"(.*)\"");
|
||||||
|
|
||||||
|
public Donation parseDonationFromMessage(String message) {
|
||||||
|
Matcher matcher = MESSAGE_PATTERN.matcher(message);
|
||||||
|
if (matcher.find()) {
|
||||||
|
String donatorName = matcher.group(1);
|
||||||
|
String amountString = matcher.group(2);
|
||||||
|
BigDecimal amount = new BigDecimal(amountString.replace(',', '.'));
|
||||||
|
String donationMessage = Optional.ofNullable(matcher.group(3)).map(msg -> msg.replaceAll("(<br>)+", " ")).map(String::trim).orElse("");
|
||||||
|
return Donation
|
||||||
|
.builder()
|
||||||
|
.message(donationMessage)
|
||||||
|
.donatorName(donatorName)
|
||||||
|
.amount(amount)
|
||||||
|
.build();
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("String in wrong format");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal fetchCurrentDonationAmount() {
|
||||||
|
try (InputStream is = new URL(debraProperties.getDonationsPageURL()).openStream()) {
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
||||||
|
String line;
|
||||||
|
while ((line = br.readLine()) != null) {
|
||||||
|
Matcher matcher = DONATION_PAGE_AMOUNT_PARTNER.matcher(line);
|
||||||
|
if (matcher.find()) {
|
||||||
|
return new BigDecimal(matcher.group(1).replace(',', '.'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.warn("Did not find the donation amount in the configured URL {}", debraProperties.getDonationsPageURL());
|
||||||
|
throw new DonationAmountNotFoundException();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
log.warn("Failed to load page for parsing donation amount {}.", debraProperties.getDonationsPageURL(), ex);
|
||||||
|
throw new DonationAmountNotFoundException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompletableFuture<Void> sendDonationNotification(Donation donation) {
|
||||||
|
DonationNotificationModel model = DonationNotificationModel
|
||||||
|
.builder()
|
||||||
|
.donation(donation)
|
||||||
|
.totalDonationAmount(fetchCurrentDonationAmount())
|
||||||
|
.build();
|
||||||
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(DONATION_NOTIFICATION_TEMPLATE_KEY, model);
|
||||||
|
Long targetServerId = Long.parseLong(System.getenv("DEBRA_DONATION_NOTIFICATION_SERVER_ID"));
|
||||||
|
return FutureUtils.toSingleFutureGeneric(postTargetService.sendEmbedInPostTarget(messageToSend, DebraPostTarget.DEBRA_DONATION_NOTIFICATION, targetServerId));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
abstracto.featureFlags.debra.featureName=debra
|
||||||
|
abstracto.featureFlags.debra.enabled=false
|
||||||
|
|
||||||
|
abstracto.postTargets.debraDonationNotification.name=debraDonationNotification
|
||||||
|
|
||||||
|
sissi.debra.websocketURL=ws://spenden.baba.fm:8765/
|
||||||
|
sissi.debra.donationsPageURL=https://em.altruja.de/discord-und-r-austria-2021
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||||
|
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||||
|
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||||
|
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||||
|
<property name="utilityModule" value="(SELECT id FROM module WHERE name = 'utility')"/>
|
||||||
|
<property name="debraFeature" value="(SELECT id FROM feature WHERE key = 'debra')"/>
|
||||||
|
|
||||||
|
<changeSet author="Sheldan" id="debra-commands">
|
||||||
|
<insert tableName="command">
|
||||||
|
<column name="name" value="donations"/>
|
||||||
|
<column name="module_id" valueComputed="${utilityModule}"/>
|
||||||
|
<column name="feature_id" valueComputed="${debraFeature}"/>
|
||||||
|
</insert>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||||
|
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||||
|
<include file="feature.xml" relativeToChangelogFile="true"/>
|
||||||
|
<include file="command.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||||
|
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||||
|
<changeSet author="Sheldan" id="debra_feature-insertion">
|
||||||
|
<insert tableName="feature">
|
||||||
|
<column name="key" value="debra"/>
|
||||||
|
</insert>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||||
|
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||||
|
<include file="1.3.6/collection.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>quotes</module>
|
<module>quotes</module>
|
||||||
<module>meetup</module>
|
<module>meetup</module>
|
||||||
|
<module>debra</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ PROMETHEUS_PORT=9090
|
|||||||
PGADMIN_PORT=5050
|
PGADMIN_PORT=5050
|
||||||
# default authentication for pg admin
|
# default authentication for pg admin
|
||||||
PGADMIN_DEFAULT_EMAIL=sheldan@sheldan.dev
|
PGADMIN_DEFAULT_EMAIL=sheldan@sheldan.dev
|
||||||
|
DEBRA_DONATION_NOTIFICATION_SERVER_ID=0
|
||||||
PGADMIN_DEFAULT_PASSWORD=admin
|
PGADMIN_DEFAULT_PASSWORD=admin
|
||||||
TOKEN=<INSERT TOKEN>
|
TOKEN=<INSERT TOKEN>
|
||||||
YOUTUBE_API_KEY=<INSERT KEY>
|
YOUTUBE_API_KEY=<INSERT KEY>
|
||||||
|
|||||||
@@ -184,6 +184,16 @@
|
|||||||
<destFileName>meetup.zip</destFileName>
|
<destFileName>meetup.zip</destFileName>
|
||||||
</artifactItem>
|
</artifactItem>
|
||||||
|
|
||||||
|
<artifactItem>
|
||||||
|
<groupId>dev.sheldan.sissi.templates</groupId>
|
||||||
|
<artifactId>debra-templates</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>zip</type>
|
||||||
|
<overWrite>true</overWrite>
|
||||||
|
<outputDirectory>${file.basedir}/deployment/template-artifacts/</outputDirectory>
|
||||||
|
<destFileName>debra.zip</destFileName>
|
||||||
|
</artifactItem>
|
||||||
|
|
||||||
<!-- sissi template customizations -->
|
<!-- sissi template customizations -->
|
||||||
|
|
||||||
<artifactItem>
|
<artifactItem>
|
||||||
@@ -340,6 +350,16 @@
|
|||||||
<destFileName>meetup.zip</destFileName>
|
<destFileName>meetup.zip</destFileName>
|
||||||
</artifactItem>
|
</artifactItem>
|
||||||
|
|
||||||
|
<artifactItem>
|
||||||
|
<groupId>dev.sheldan.sissi.templates.translations</groupId>
|
||||||
|
<artifactId>debra-translations</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>zip</type>
|
||||||
|
<overWrite>true</overWrite>
|
||||||
|
<outputDirectory>${file.basedir}/deployment/translation-artifacts/</outputDirectory>
|
||||||
|
<destFileName>debra.zip</destFileName>
|
||||||
|
</artifactItem>
|
||||||
|
|
||||||
<!-- custom -->
|
<!-- custom -->
|
||||||
|
|
||||||
<!-- abstracto liquibase artifacts -->
|
<!-- abstracto liquibase artifacts -->
|
||||||
@@ -521,6 +541,17 @@
|
|||||||
<destFileName>meetup.zip</destFileName>
|
<destFileName>meetup.zip</destFileName>
|
||||||
</artifactItem>
|
</artifactItem>
|
||||||
|
|
||||||
|
<artifactItem>
|
||||||
|
<groupId>dev.sheldan.sissi.application.module</groupId>
|
||||||
|
<artifactId>debra</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<classifier>liquibase</classifier>
|
||||||
|
<type>zip</type>
|
||||||
|
<overWrite>true</overWrite>
|
||||||
|
<outputDirectory>${file.basedir}/deployment/liquibase-artifacts/</outputDirectory>
|
||||||
|
<destFileName>debra.zip</destFileName>
|
||||||
|
</artifactItem>
|
||||||
|
|
||||||
<!-- customizations -->
|
<!-- customizations -->
|
||||||
|
|
||||||
<artifactItem>
|
<artifactItem>
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"template_artifacts": [
|
"template_artifacts": [
|
||||||
"core","starboard", "link-embed", "moderation", "entertainment", "custom-command", "utility", "webservices", "remind", "suggestion", "modmail", "assignable-roles",
|
"core","starboard", "link-embed", "moderation", "entertainment", "custom-command", "utility", "webservices", "remind", "suggestion", "modmail", "assignable-roles",
|
||||||
"quotes", "meetup",
|
"quotes", "meetup", "debra",
|
||||||
"moderation-custom",
|
"moderation-custom",
|
||||||
"moderation-template-overrides"
|
"moderation-template-overrides"
|
||||||
],
|
],
|
||||||
"translation_artifacts": [
|
"translation_artifacts": [
|
||||||
"core",
|
"core",
|
||||||
"starboard", "link-embed", "moderation", "entertainment", "custom-command", "utility", "webservices", "suggestion", "remind", "modmail", "assignable-roles",
|
"starboard", "link-embed", "moderation", "entertainment", "custom-command", "utility", "webservices", "suggestion", "remind", "modmail", "assignable-roles",
|
||||||
"quotes", "meetup",
|
"quotes", "meetup", "debra",
|
||||||
"moderation-custom",
|
"moderation-custom",
|
||||||
"moderation-translation-overrides"
|
"moderation-translation-overrides"
|
||||||
],
|
],
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
{ "zip": "starboard", "file": "starboard-changeLog.xml"},
|
{ "zip": "starboard", "file": "starboard-changeLog.xml"},
|
||||||
{ "zip": "quotes", "file": "quotes-changeLog.xml"},
|
{ "zip": "quotes", "file": "quotes-changeLog.xml"},
|
||||||
{ "zip": "meetup", "file": "meetup-changeLog.xml"},
|
{ "zip": "meetup", "file": "meetup-changeLog.xml"},
|
||||||
|
{ "zip": "debra", "file": "debra-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"},
|
||||||
|
|||||||
@@ -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">
|
||||||
|
<parent>
|
||||||
|
<artifactId>module-templates</artifactId>
|
||||||
|
<groupId>dev.sheldan.sissi.templates</groupId>
|
||||||
|
<version>1.3.6-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>debra-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>debra-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,5 @@
|
|||||||
|
{
|
||||||
|
<#assign donationAmount=donationAmount>
|
||||||
|
<#setting locale="de_DE">
|
||||||
|
"additionalMessage": "<#include "donations_response_description">"
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<#include "donation_amount_not_found_exception_text">
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"embeds": [
|
||||||
|
{
|
||||||
|
"title": {
|
||||||
|
<#setting locale="de_DE">
|
||||||
|
<#assign donatorName=donation.donatorName>
|
||||||
|
<#assign donationAmount=donation.amount>
|
||||||
|
"title": "<@safe_include "debra_donation_notification_embed_title"/>"
|
||||||
|
},
|
||||||
|
<#assign donationMessage=donation.message>
|
||||||
|
"description": "${donationMessage?json_string}",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
<#assign totalDonationAmount=totalDonationAmount>
|
||||||
|
"name": "<@safe_include "debra_donation_notification_embed_field_amount_title"/>",
|
||||||
|
"value": "<@safe_include "debra_donation_notification_embed_field_amount_value"/>"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"footer": {
|
||||||
|
"text": "<@safe_include "debra_donation_notification_embed_footer"/>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>quotes-templates</module>
|
<module>quotes-templates</module>
|
||||||
<module>meetup-templates</module>
|
<module>meetup-templates</module>
|
||||||
|
<module>debra-templates</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -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">
|
||||||
|
<parent>
|
||||||
|
<artifactId>module-translations</artifactId>
|
||||||
|
<groupId>dev.sheldan.sissi.templates.translations</groupId>
|
||||||
|
<version>1.3.6-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>debra-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>debra-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 @@
|
|||||||
|
Aktuell wurden **${donationAmount} Euro** für Debra Austria gespendet. Spende auch du unter https://tiny.cc/schmetterling2021.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Aktueller Spendenbetrag
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
${totalDonationAmount} Euro
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Spende auch du für Debra Austria unter http://tiny.cc/schmetterling2021.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
:bell: ${donatorName} hat ${donationAmount} Euro gespendet :bell:
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Currently **${donationAmount} Euro** were donated for Debra Austra. Donate via https://tiny.cc/schmetterling2021 too.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Shows the current donation amount and a link to donate.
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Retrieves the current donation amount from the respective website, parses the donation amount and shows this in a message.
|
||||||
|
Also shows a link on where to donate and for that.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Debra
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
No donation amount was found.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Current donations
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
${totalDonationAmount} Euro
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Also donate for Debra austria via http://tiny.cc/schmetterling2021.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
:bell: ${donatorName} donated ${donationAmount} Euro. :bell:
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>quote-translations</module>
|
<module>quote-translations</module>
|
||||||
<module>meetup-translations</module>
|
<module>meetup-translations</module>
|
||||||
|
<module>debra-translations</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user