[OPB-3] adding initial structure of oneplus bot with deployment and selected modules

adding volume configuration to grafana and postgres
adding .env file for variables in docker compose
adding handling of password for prometheus
adding port configuration for more services
adding custom starboard notifications
updating readme and adding release job
 adding settings.xml for build
This commit is contained in:
Sheldan
2021-03-17 01:15:21 +01:00
parent 44a56d67c7
commit 71896bf3b6
77 changed files with 6086 additions and 0 deletions

30
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,30 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Execute build
on:
push:
branches:
- master
- feature/**
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn -s settings.xml -B install --file pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
user: Sheldan
token: ${{ secrets.ABSTRACTO_PAT }}

36
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,36 @@
name: Publish package to GitHub Packages
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Set up Java for publishing to GitHub Packages
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Load current version
id: version
run: echo "version=$(mvn --file pom.xml -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_ENV
- name: Publish to GitHub Packages
run: mvn -s settings.xml --file pom.xml -B deploy -Dmaven.wagon.http.pool=false -DskipTests=true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
user: Sheldan
token: ${{ secrets.ABSTRACTO_PAT }}
- name: Login to GitHub Packages Docker Registry
uses: docker/login-action@v1
with:
registry: docker.pkg.github.com
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push deployment container
working-directory: ./deployment/image-packaging/src/main/docker
run: docker-compose build && docker-compose push
env:
REGISTRY_PREFIX: docker.pkg.github.com/sheldan/oneplusbot/
VERSION: ${{ env.version }}

25
.gitignore vendored Normal file
View File

@@ -0,0 +1,25 @@
# Compiled class file
*.class
.idea/
target/
*.iml
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

11
README.md Normal file
View File

@@ -0,0 +1,11 @@
# r/oneplus Discord server bot
This repository contains the rewrite of the [Bot](https://github.com/Rithari/OnePlusBot), which is still in use. The features will be gradually be ported
and most of them will be in [abstracto](https://github.com/Sheldan/abstracto), but some of the features need to be customized, as they are r/oneplus specific.
The migration of the existing data from the database is handled via one time migration, and can be found [here](https://github.com/Sheldan/OnePlusBot-migration).
Custom features which were ported
- [ ] FAQ
- [ ] Setup channel handling
- [ ] Referral link handling

View File

@@ -0,0 +1,98 @@
<?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.oneplus.bot.application</groupId>
<artifactId>application</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>executable</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>dev.sheldan.abstracto.core</groupId>
<artifactId>core-impl</artifactId>
</dependency>
<dependency>
<groupId>dev.sheldan.abstracto.core</groupId>
<artifactId>metrics-impl</artifactId>
</dependency>
<!-- modules containing commands -->
<dependency>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>utility-impl</artifactId>
</dependency>
<dependency>
<groupId>dev.sheldan.abstracto.scheduling</groupId>
<artifactId>scheduling-impl</artifactId>
</dependency>
<dependency>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>entertainment-impl</artifactId>
</dependency>
<dependency>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>link-embed-impl</artifactId>
</dependency>
<dependency>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>starboard-impl</artifactId>
</dependency>
<dependency>
<groupId>dev.sheldan.oneplus.bot.application.custom</groupId>
<artifactId>starboard-custom</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,37 @@
package dev.sheldan.oneplus.bot.executable;
import dev.sheldan.abstracto.core.service.Startup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@EnableAutoConfiguration(exclude = { FreeMarkerAutoConfiguration.class })
@ComponentScan(basePackages = {"dev.sheldan.abstracto", "dev.sheldan.oneplus.bot"})
@EnableCaching
@EnableJpaRepositories(basePackages = {"dev.sheldan.abstracto", "dev.sheldan.oneplus.bot"})
@EntityScan(basePackages = {"dev.sheldan.abstracto", "dev.sheldan.oneplus.bot"})
@EnableTransactionManagement
public class Application implements CommandLineRunner {
@Autowired
private Startup startup;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
public void run(String... args) throws Exception {
startup.startBot();
}
}

View File

@@ -0,0 +1,19 @@
spring.datasource.url=jdbc:postgresql://localhost:5432/abstracto
spring.datasource.username= abstracto
spring.datasource.password= abstracto
spring.jpa.properties.hibernate.default_schema=abstracto
spring.quartz.jdbc.initialize-schema=never
spring.jpa.hibernate.ddl-auto = none
spring.jpa.show-sql = false
spring.jpa.properties.hibernate.format_sql = true
log4j.logger.org.hibernate.SQL=trace
log4j.logger.org.hibernate.type.descriptor.sql=trace
log4j.logger.org.hibernate.type=trace
management.metrics.tags.application=oneplus-bot
spring.security.user.name=abstracto
spring.security.user.password=password
spring.security.user.roles=USER

View File

@@ -0,0 +1,9 @@
spring.datasource.url=jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}
spring.datasource.username= ${DB_USER}
spring.datasource.password= ${DB_PASS}
spring.jpa.hibernate.default_schema=${DB_NAME}
spring.quartz.jdbc.initialize-schema=never
management.metrics.tags.application=oneplus-bot
spring.security.user.name= ${REST_USER_NAME}
spring.security.user.password= ${REST_PASSWORD}
spring.security.user.roles=USER

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
<property name="LOG_PATH" value="logs"/>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread]) %highlight(%-5level) %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<appender name="logFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/log.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>
%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>
${LOG_PATH}/archived/log_%d{dd-MM-yyyy}.log
</fileNamePattern>
<maxHistory>10</maxHistory>
<totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
</appender>
<logger name="dev.sheldan.abstracto" level="INFO"/>
<root level="info">
<appender-ref ref="logFileAppender"/>
<appender-ref ref="stdout"/>
</root>
</configuration>

View File

@@ -0,0 +1,19 @@
<?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.oneplus.bot.application</groupId>
<artifactId>application</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>dev.sheldan.oneplus.bot.application.custom</groupId>
<artifactId>oneplus-bot-customizations</artifactId>
<packaging>pom</packaging>
<modules>
<module>starboard-custom</module>
</modules>
</project>

View File

@@ -0,0 +1,49 @@
<?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.oneplus.bot.application.custom</groupId>
<artifactId>oneplus-bot-customizations</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>starboard-custom</artifactId>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<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.modules</groupId>
<artifactId>starboard-int</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -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>

View File

@@ -0,0 +1,33 @@
package dev.sheldan.oneplus.bot.custom.starboard.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.abstracto.starboard.config.StarboardFeatureConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
@Component
public class StarboardCustomFeature implements FeatureConfig {
@Autowired
private StarboardFeatureConfig starboardFeature;
@Override
public FeatureDefinition getFeature() {
return StarboardCustomFeatureDefinition.STARBOARD_NOTIFICATION;
}
@Override
public List<FeatureConfig> getRequiredFeatures() {
return Arrays.asList(starboardFeature);
}
@Override
public List<PostTargetEnum> getRequiredPostTargets() {
return Arrays.asList(StarboardCustomPostTarget.STARBOARD_NOTIFICATION);
}
}

View File

@@ -0,0 +1,15 @@
package dev.sheldan.oneplus.bot.custom.starboard.config;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import lombok.Getter;
@Getter
public enum StarboardCustomFeatureDefinition implements FeatureDefinition {
STARBOARD_NOTIFICATION("starboardNotification");
private String key;
StarboardCustomFeatureDefinition(String key) {
this.key = key;
}
}

View File

@@ -0,0 +1,15 @@
package dev.sheldan.oneplus.bot.custom.starboard.config;
import dev.sheldan.abstracto.core.config.PostTargetEnum;
import lombok.Getter;
@Getter
public enum StarboardCustomPostTarget implements PostTargetEnum {
STARBOARD_NOTIFICATION("starboardNotification");
private String key;
StarboardCustomPostTarget(String key) {
this.key = key;
}
}

View File

@@ -0,0 +1,10 @@
package dev.sheldan.oneplus.bot.custom.starboard.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@PropertySource("classpath:starboard-custom.properties")
public class StarboardCustomProperties {
}

View File

@@ -0,0 +1,94 @@
package dev.sheldan.oneplus.bot.custom.starboard.listener;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.listener.DefaultListenerResult;
import dev.sheldan.abstracto.core.service.MemberService;
import dev.sheldan.abstracto.core.service.MessageService;
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.starboard.listener.StarboardPostCreatedListener;
import dev.sheldan.abstracto.starboard.model.StarboardPostCreatedModel;
import dev.sheldan.abstracto.starboard.model.database.StarboardPost;
import dev.sheldan.abstracto.starboard.service.management.StarboardPostManagementService;
import dev.sheldan.oneplus.bot.custom.starboard.config.StarboardCustomFeatureDefinition;
import dev.sheldan.oneplus.bot.custom.starboard.config.StarboardCustomPostTarget;
import dev.sheldan.oneplus.bot.custom.starboard.model.StarboardPostCreatedNotificationModel;
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.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
public class StarboardPostCreatedListenerBean implements StarboardPostCreatedListener {
@Autowired
private PostTargetService postTargetService;
@Autowired
private StarboardPostManagementService starboardPostManagementService;
@Autowired
private MessageService messageService;
@Autowired
private MemberService memberService;
@Autowired
private StarboardPostCreatedListenerBean self;
@Autowired
private TemplateService templateService;
private static final String STARBOARD_POST_CREATED_NOTIFICATION_TEMPLATE_KEY = "starboard_post_created_notification";
@Override
public DefaultListenerResult execute(StarboardPostCreatedModel model) {
Long serverId = model.getServerId();
CompletableFuture<Message> starboardMessageFuture = messageService.loadMessage(serverId, model.getStarboardMessage().getChannelId(), model.getStarboardMessage().getMessageId());
CompletableFuture<Message> starredMessageFuture = messageService.loadMessage(serverId, model.getStarredMessage().getChannelId(), model.getStarredMessage().getMessageId());
CompletableFuture<Member> starredUserFuture = memberService.retrieveMemberInServer(model.getStarredUser());
CompletableFuture<Member> starringUserFuture = memberService.retrieveMemberInServer(model.getLastStarrer());
List<CompletableFuture> futures = Arrays.asList(starboardMessageFuture, starredMessageFuture, starredUserFuture, starringUserFuture);
CompletableFuture.allOf(starboardMessageFuture, starredMessageFuture, starredUserFuture, starringUserFuture)
.whenComplete((unused, throwable) -> self.sendNotification(futures, model));
log.info("Starboard created event for post {}.", model.getStarboardPostId());
return DefaultListenerResult.PROCESSED;
}
@Transactional
public void sendNotification(List<CompletableFuture> futures, StarboardPostCreatedModel model) {
StarboardPost post = starboardPostManagementService.findByStarboardPostId(model.getStarboardPostId()).orElse(null);
Message starboardMessage = futures.get(0).isCompletedExceptionally() ? null : (Message) futures.get(0).join();
Message starredMessage = futures.get(1).isCompletedExceptionally() ? null : (Message) futures.get(1).join();
Member starredMember = futures.get(2).isCompletedExceptionally() ? null : (Member) futures.get(2).join();
Member starringMember = futures.get(3).isCompletedExceptionally() ? null : (Member) futures.get(3).join();
StarboardPostCreatedNotificationModel templateModel = StarboardPostCreatedNotificationModel
.builder()
.post(post)
.starboardMessage(starboardMessage)
.starredMessage(starredMessage)
.starredMember(starredMember)
.starringMember(starringMember)
.starboardMessageSimple(model.getStarboardMessage())
.starredMessageSimple(model.getStarredMessage())
.starredUserId(model.getStarredUser().getUserId())
.starringUserId(model.getLastStarrer().getUserId())
.build();
MessageToSend messageToSend = templateService.renderEmbedTemplate(STARBOARD_POST_CREATED_NOTIFICATION_TEMPLATE_KEY, templateModel);
postTargetService.sendEmbedInPostTarget(messageToSend, StarboardCustomPostTarget.STARBOARD_NOTIFICATION, model.getServerId());
}
@Override
public FeatureDefinition getFeature() {
return StarboardCustomFeatureDefinition.STARBOARD_NOTIFICATION;
}
}

View File

@@ -0,0 +1,89 @@
package dev.sheldan.oneplus.bot.custom.starboard.listener;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.listener.DefaultListenerResult;
import dev.sheldan.abstracto.core.service.MemberService;
import dev.sheldan.abstracto.core.service.MessageService;
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.starboard.listener.StarboardPostDeletedListener;
import dev.sheldan.abstracto.starboard.model.StarboardPostDeletedModel;
import dev.sheldan.abstracto.starboard.service.management.StarboardPostManagementService;
import dev.sheldan.oneplus.bot.custom.starboard.config.StarboardCustomFeatureDefinition;
import dev.sheldan.oneplus.bot.custom.starboard.config.StarboardCustomPostTarget;
import dev.sheldan.oneplus.bot.custom.starboard.model.StarboardPostDeletedNotificationModel;
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.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
public class StarboardPostDeletedListenerBean implements StarboardPostDeletedListener {
@Autowired
private PostTargetService postTargetService;
@Autowired
private StarboardPostManagementService starboardPostManagementService;
@Autowired
private MessageService messageService;
@Autowired
private MemberService memberService;
@Autowired
private StarboardPostDeletedListenerBean self;
@Autowired
private TemplateService templateService;
private static final String STARBOARD_POST_DELETED_NOTIFICATION_TEMPLATE_KEY = "starboard_post_deleted_notification";
@Override
public DefaultListenerResult execute(StarboardPostDeletedModel model) {
Long serverId = model.getServerId();
CompletableFuture<Message> starboardMessageFuture = messageService.loadMessage(serverId, model.getStarboardMessage().getChannelId(), model.getStarboardMessage().getMessageId());
CompletableFuture<Message> starredMessageFuture = messageService.loadMessage(serverId, model.getStarredMessage().getChannelId(), model.getStarredMessage().getMessageId());
CompletableFuture<Member> starredUserFuture = memberService.retrieveMemberInServer(model.getStarredUser());
CompletableFuture<Member> starringUserFuture = memberService.retrieveMemberInServer(model.getLastStarrer());
List<CompletableFuture> futures = Arrays.asList(starboardMessageFuture, starredMessageFuture, starredUserFuture, starringUserFuture);
CompletableFuture.allOf(starboardMessageFuture, starredMessageFuture, starredUserFuture, starringUserFuture)
.whenComplete((unused, throwable) -> self.sendNotification(futures, model));
log.info("Starboard deleted event for post {}.", model.getStarboardPostId());
return DefaultListenerResult.PROCESSED;
}
@Transactional
public void sendNotification(List<CompletableFuture> futures, StarboardPostDeletedModel model) {
Message starboardMessage = futures.get(0).isCompletedExceptionally() ? null : (Message) futures.get(0).join();
Message starredMessage = futures.get(1).isCompletedExceptionally() ? null : (Message) futures.get(1).join();
Member starredMember = futures.get(2).isCompletedExceptionally() ? null : (Member) futures.get(2).join();
Member starringMember = futures.get(3).isCompletedExceptionally() ? null : (Member) futures.get(3).join();
StarboardPostDeletedNotificationModel templateModel = StarboardPostDeletedNotificationModel
.builder()
.starboardMessage(starboardMessage)
.starredMessage(starredMessage)
.starredMember(starredMember)
.starringMember(starringMember)
.starredUserId(model.getStarredUser().getUserId())
.starringUserId(model.getLastStarrer().getUserId())
.build();
MessageToSend messageToSend = templateService.renderEmbedTemplate(STARBOARD_POST_DELETED_NOTIFICATION_TEMPLATE_KEY, templateModel);
postTargetService.sendEmbedInPostTarget(messageToSend, StarboardCustomPostTarget.STARBOARD_NOTIFICATION, model.getServerId());
}
@Override
public FeatureDefinition getFeature() {
return StarboardCustomFeatureDefinition.STARBOARD_NOTIFICATION;
}
}

View File

@@ -0,0 +1,24 @@
package dev.sheldan.oneplus.bot.custom.starboard.model;
import dev.sheldan.abstracto.core.models.ServerChannelMessage;
import dev.sheldan.abstracto.starboard.model.database.StarboardPost;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
@Getter
@Setter
@Builder
public class StarboardPostCreatedNotificationModel {
private StarboardPost post;
private ServerChannelMessage starboardMessageSimple;
private Message starboardMessage;
private ServerChannelMessage starredMessageSimple;
private Message starredMessage;
private Member starredMember;
private Long starredUserId;
private Member starringMember;
private Long starringUserId;
}

View File

@@ -0,0 +1,22 @@
package dev.sheldan.oneplus.bot.custom.starboard.model;
import dev.sheldan.abstracto.core.models.ServerChannelMessage;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
@Getter
@Setter
@Builder
public class StarboardPostDeletedNotificationModel {
private ServerChannelMessage starboardMessageSimple;
private Message starboardMessage;
private ServerChannelMessage starredMessageSimple;
private Message starredMessage;
private Member starredMember;
private Long starredUserId;
private Member starringMember;
private Long starringUserId;
}

View File

@@ -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-3.8.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext ../dbchangelog-3.8.xsd
http://www.liquibase.org/xml/ns/pro ../dbchangelog-3.8.xsd" >
<include file="starboard-custom-seedData/data.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -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-3.8.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
<include file="feature.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -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-3.8.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
<changeSet author="Sheldan" id="starboard_custom_feature-insertion">
<insert tableName="feature">
<column name="key" value="starboardNotification"/>
</insert>
</changeSet>
</databaseChangeLog>

View File

@@ -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-3.8.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog-3.8.xsd
http://www.liquibase.org/xml/ns/pro dbchangelog-3.8.xsd" >
<include file="1.0-starboard-custom/collection.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,4 @@
abstracto.postTargets.starboardNotification.name=starboardNotification
abstracto.featureFlags.starboardNotification.featureName=starboardNotification
abstracto.featureFlags.starboardNotification.enabled=false

52
application/pom.xml Normal file
View File

@@ -0,0 +1,52 @@
<?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.oneplus.bot</groupId>
<artifactId>oneplusbot</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>dev.sheldan.oneplus.bot.application</groupId>
<artifactId>application</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>executable</module>
<module>oneplus-bot-customizations</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>dev.sheldan.abstracto</groupId>
<artifactId>bundle</artifactId>
<version>${abstracto.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>dev.sheldan.abstracto.core</groupId>
<artifactId>core-int</artifactId>
</dependency>
<dependency>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>utility-int</artifactId>
</dependency>
<dependency>
<groupId>dev.sheldan.abstracto.scheduling</groupId>
<artifactId>scheduling-int</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,36 @@
<?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.oneplus.bot.deployment</groupId>
<artifactId>deployment</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<artifactId>docker-compose</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assembly-docker-compose-configuration</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/docker-compose.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,19 @@
<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>docker-compose</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<outputDirectory>./docker-compose</outputDirectory>
<directory>${project.basedir}/src/main/resources/</directory>
<includes>
<include>**/*</include>
</includes>
<filtered>true</filtered>
</fileSet>
</fileSets>
</assembly>

View File

@@ -0,0 +1,27 @@
# database configuration
DATABASE_HOST=database
DATABASE_PORT=5432
DATABASE_USER=abstracto
DATABASE_NAME=abstracto
DATABASE_PASSWORD=abstracto
# deployment configuration, whether or not the container should execute the parts on startup
EXECUTE_DEPLOYMENT=true
EXECUTE_LIQUIBASE=true
EXECUTE_TEMPLATES=true
# whether or not remote debug should be enabled on the application
REMOTE_DEBUG=false
DEBUG_PORT=5005
TOMCAT_PORT=8080
# authentication for actuator endpoints
REST_USER_NAME=abstracto
REST_PASSWORD=password
# port grafana will be reachable
GRAFANA_PORT=3000
# port prometheus will be reachable
PROMETHEUS_PORT=9090
# port pg admin will be reachable
PGADMIN_PORT=5050
# default authentication for pg admin
PGADMIN_DEFAULT_EMAIL=sheldan@sheldan.dev
PGADMIN_DEFAULT_PASSWORD=admin
TOKEN=<INSERT TOKEN>

View File

@@ -0,0 +1,10 @@
# Setup for local docker-compose deployment
* Install docker [here](https://docs.docker.com/get-docker/)
* Install docker-compose [here](https://docs.docker.com/compose/install/).
* Execute `docker-compose build` in `image-packaging`.
* Fill out values in `.env` for token and database password. There are some default values, but token is required to be changed.
* Execute `fill-prometheus-file-sh` in order to populate the prometheus config with the correct password (https://github.com/prometheus/prometheus/issues/2357)
* Execute `docker-compose up` in this directory and wait for completion.
* Per default pgAdmin is available on `localhost:5050` with the configured user and password. It will contain a configuration in the servers list.

View File

@@ -0,0 +1,105 @@
version: '3.7'
services:
db:
image: ${REGISTRY_PREFIX}oneplus_bot_database
container_name: database
restart: always
environment:
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_USER: ${DATABASE_USER}
ports:
- "${DATABASE_PORT}:5432"
networks:
- oneplusbot
volumes:
- db-data:/var/lib/postgresql/data
deployment_container:
container_name: deployment
image: ${REGISTRY_PREFIX}oneplus_bot_deployment
depends_on:
- db
environment:
DB_PASS: ${DATABASE_PASSWORD}
DB_HOST: ${DATABASE_HOST}
DB_PORT: ${DATABASE_PORT}
DB_USER: ${DATABASE_USER}
DB_NAME: ${DATABASE_NAME}
EXECUTE_DEPLOYMENT: ${EXECUTE_DEPLOYMENT}
EXECUTE_LIQUIBASE: ${EXECUTE_LIQUIBASE}
EXECUTE_TEMPLATES: ${EXECUTE_TEMPLATES}
LIQUIBASE_PATH: ${LIQUIBASE_PATH:-/liquibase}
POSTGRES_DRIVER_PATH: ${EXECUTE_DEPLOYMENT:-/postgres/driver.jar}
WAIT_HOSTS: database:5432
networks:
- oneplusbot
bot:
image: ${REGISTRY_PREFIX}oneplus_bot
depends_on:
- db
- deployment_container
restart: on-failure
container_name: oneplusbot
environment:
TOKEN: ${TOKEN}
REMOTE_DEBUG: ${REMOTE_DEBUG}
DB_PASS: ${DATABASE_PASSWORD}
DB_HOST: ${DATABASE_HOST}
DB_PORT: ${DATABASE_PORT}
DB_USER: ${DATABASE_USER}
DB_NAME: ${DATABASE_NAME}
REST_USER_NAME: ${REST_USER_NAME}
REST_PASSWORD: ${REST_PASSWORD}
command: sh -c "while ping -c1 deployment_container &>/dev/null; do sleep 1; done; echo 'Liquibase finished!' && ./start.sh"
ports:
- "${DEBUG_PORT}:5005"
- "${TOMCAT_PORT}:8080"
networks:
- oneplusbot
pgadmin:
container_name: pgadmin
image: ${REGISTRY_PREFIX}oneplus_bot_pg_admin
depends_on:
- db
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD}
ports:
- "${PGADMIN_PORT}:80"
restart: unless-stopped
networks:
- oneplusbot
prometheus:
container_name: prometheus
image: ${REGISTRY_PREFIX}oneplus_bot_prometheus
depends_on:
- bot
ports:
- "${PROMETHEUS_PORT}:9090"
restart: unless-stopped
networks:
- oneplusbot
volumes:
- ./res/prometheus-scrapper-password-filled:/etc/prometheus/micrometer_password
grafana:
container_name: grafana
image: ${REGISTRY_PREFIX}oneplus_bot_grafana
depends_on:
- prometheus
- bot
ports:
- "${GRAFANA_PORT}:3000"
restart: unless-stopped
volumes:
- grafana-user-data:/var/lib/grafana
networks:
- oneplusbot
networks:
oneplusbot:
driver: bridge
name: oneplusbot-network
volumes:
db-data:
grafana-user-data:

View File

@@ -0,0 +1,5 @@
#!/bin/bash
set -o allexport
source .env
set +o allexport
envsubst < res/prometheus-scrapper-password > res/prometheus-scrapper-password-filled

View File

@@ -0,0 +1 @@
${REST_PASSWORD}

View File

@@ -0,0 +1,266 @@
<?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.oneplus.bot.deployment</groupId>
<artifactId>deployment</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>image-packaging</artifactId>
<packaging>pom</packaging>
<properties>
<file.basedir>${project.basedir}/src/main/docker/</file.basedir>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactItems>
<!-- backend jar -->
<artifactItem>
<groupId>dev.sheldan.oneplus.bot.application</groupId>
<artifactId>executable</artifactId>
<version>${project.version}</version>
<classifier>exec</classifier>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/oneplusbot/bot</outputDirectory>
<destFileName>app.jar</destFileName>
</artifactItem>
<!-- template artefacts -->
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.templates</groupId>
<artifactId>core</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/template-artifacts/</outputDirectory>
<destFileName>core.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.templates</groupId>
<artifactId>entertainment</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/template-artifacts/</outputDirectory>
<destFileName>entertainment.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.templates</groupId>
<artifactId>link-embed</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/template-artifacts/</outputDirectory>
<destFileName>link-embed.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.templates</groupId>
<artifactId>starboard</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/template-artifacts/</outputDirectory>
<destFileName>starboard.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.templates</groupId>
<artifactId>utility</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/template-artifacts/</outputDirectory>
<destFileName>utility.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.oneplus.bot.templates.modules</groupId>
<artifactId>starboard-custom-templates</artifactId>
<version>${project.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/template-artifacts/</outputDirectory>
<destFileName>starboard-custom.zip</destFileName>
</artifactItem>
<!-- translation artefacts -->
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.translations</groupId>
<artifactId>utility</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/translation-artifacts/</outputDirectory>
<destFileName>utility.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.translations</groupId>
<artifactId>core</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/translation-artifacts/</outputDirectory>
<destFileName>core.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.translations</groupId>
<artifactId>entertainment</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/translation-artifacts/</outputDirectory>
<destFileName>entertainment.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.translations</groupId>
<artifactId>link-embed</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/translation-artifacts/</outputDirectory>
<destFileName>link-embed.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.translations</groupId>
<artifactId>starboard</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/translation-artifacts/</outputDirectory>
<destFileName>starboard.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.translations</groupId>
<artifactId>utility</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/translation-artifacts/</outputDirectory>
<destFileName>utility.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.oneplus.bot.templates.translations</groupId>
<artifactId>starboard-custom</artifactId>
<version>${project.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/translation-artifacts/</outputDirectory>
<destFileName>starboard-custom.zip</destFileName>
</artifactItem>
<!-- liquibase artifacts -->
<artifactItem>
<groupId>dev.sheldan.abstracto.scheduling</groupId>
<artifactId>scheduling-impl</artifactId>
<version>${abstracto.version}</version>
<classifier>liquibase</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/liquibase-artifacts/</outputDirectory>
<destFileName>scheduling.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto.core</groupId>
<artifactId>core-impl</artifactId>
<version>${abstracto.version}</version>
<classifier>liquibase</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/liquibase-artifacts/</outputDirectory>
<destFileName>core.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>utility-impl</artifactId>
<version>${abstracto.version}</version>
<classifier>liquibase</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/liquibase-artifacts/</outputDirectory>
<destFileName>utility.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>entertainment-impl</artifactId>
<version>${abstracto.version}</version>
<classifier>liquibase</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/liquibase-artifacts/</outputDirectory>
<destFileName>entertainment.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>link-embed-impl</artifactId>
<version>${abstracto.version}</version>
<classifier>liquibase</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/liquibase-artifacts/</outputDirectory>
<destFileName>link-embed.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>starboard-impl</artifactId>
<version>${abstracto.version}</version>
<classifier>liquibase</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/liquibase-artifacts/</outputDirectory>
<destFileName>starboard.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>utility-impl</artifactId>
<version>${abstracto.version}</version>
<classifier>liquibase</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/liquibase-artifacts/</outputDirectory>
<destFileName>utility.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.oneplus.bot.application.custom</groupId>
<artifactId>starboard-custom</artifactId>
<version>${project.version}</version>
<classifier>liquibase</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/liquibase-artifacts/</outputDirectory>
<destFileName>starboard-custom.zip</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,4 @@
FROM postgres
MAINTAINER Sheldan
VOLUME /tmp
ADD sql/init.sql /docker-entrypoint-initdb.d/init.sql

View File

@@ -0,0 +1 @@
CREATE SCHEMA abstracto

View File

@@ -0,0 +1,6 @@
FROM abstracto_deployment:latest
MAINTAINER Sheldan
ADD template-artifacts /templates
ADD translation-artifacts /translations
ADD liquibase-artifacts /liquibase-zips
ADD config /

View File

@@ -0,0 +1,15 @@
{
"template_artifacts": ["utility", "core", "entertainment", "starboard", "link-embed", "starboard-custom"],
"translation_artifacts": ["utility", "core", "entertainment", "starboard", "link-embed", "starboard-custom"],
"liquibase_artifacts": [
{ "zip": "scheduling", "file": "scheduling-changeLog.xml" },
{ "zip": "core", "file": "core-changeLog.xml" },
{ "zip": "utility", "file": "utility-changeLog.xml"},
{ "zip": "entertainment", "file": "entertainment-changeLog.xml"},
{ "zip": "link-embed", "file": "link-embed-changeLog.xml"},
{ "zip": "starboard", "file": "starboard-changeLog.xml"},
{ "zip": "starboard-custom", "file": "starboard-custom-changeLog.xml"}
]
}

View File

@@ -0,0 +1,21 @@
version: "3.7"
services:
bot:
build: oneplusbot
image: ${REGISTRY_PREFIX}oneplus_bot:${VERSION:-latest}
database:
build: database
image: ${REGISTRY_PREFIX}oneplus_bot_database:${VERSION:-latest}
pg_admin:
build: pgAdmin
image: ${REGISTRY_PREFIX}oneplus_bot_pg_admin:${VERSION:-latest}
deployment_container:
build: deployment
image: ${REGISTRY_PREFIX}oneplus_bot_deployment:${VERSION:-latest}
prometheus:
build: prometheus
image: ${REGISTRY_PREFIX}oneplus_bot_prometheus:${VERSION:-latest}
grafana:
build: grafana
image: ${REGISTRY_PREFIX}oneplus_bot_grafana:${VERSION:-latest}

View File

@@ -0,0 +1,5 @@
FROM grafana/grafana
MAINTAINER Sheldan
ADD ./provisioning /etc/grafana/provisioning
ADD ./config.ini /etc/grafana/config.ini
ADD ./dashboards /var/lib/grafana/dashboards

View File

@@ -0,0 +1,2 @@
[paths]
provisioning = conf/provisioning

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,6 @@
- name: 'oneplus-dashboards'
org_id: 1
folder: ''
type: 'file'
options:
folder: '/var/lib/grafana/dashboards'

View File

@@ -0,0 +1,9 @@
datasources:
- access: 'proxy'
editable: true
is_default: true
name: 'prometheus'
org_id: 1
type: 'prometheus'
url: 'http://prometheus:9090'
version: 1

View File

@@ -0,0 +1,8 @@
FROM openjdk:8-jdk-alpine
MAINTAINER Sheldan
VOLUME /tmp
ADD bot/app.jar /app.jar
ADD config/* /config/
ADD wrapper/*.sh /
RUN chmod +x /start.sh
CMD ["/start.sh"]

View File

@@ -0,0 +1,2 @@
logging.config=config/logback.xml

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
<property name="LOG_PATH" value="logs"/>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread]) %highlight(%-5level) %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<appender name="logFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/log.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>
%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>
${LOG_PATH}/archived/log_%d{dd-MM-yyyy}.log
</fileNamePattern>
<maxHistory>10</maxHistory>
<totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
</appender>
<root level="info">
<appender-ref ref="logFileAppender"/>
<appender-ref ref="stdout"/>
</root>
</configuration>

View File

@@ -0,0 +1,7 @@
#!/bin/sh
DEBUG_PARAMS=""
if [ "x$REMOTE_DEBUG" = 'xtrue' ]; then
DEBUG_PARAMS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
echo "Starting with remote debugging on port 5005"
fi;
java ${DEBUG_PARAMS} -jar app.jar

View File

@@ -0,0 +1,4 @@
FROM dpage/pgadmin4
MAINTAINER Sheldan
VOLUME /tmp
ADD config/servers.json /pgadmin4/servers.json

View File

@@ -0,0 +1,13 @@
{
"Servers": {
"1": {
"Name": "OnePlusBot database",
"Group": "Server Group 1",
"Port": 5432,
"Username": "abstracto",
"Host": "db",
"SSLMode": "prefer",
"MaintenanceDB": "postgres"
}
}
}

View File

@@ -0,0 +1,3 @@
FROM prom/prometheus
MAINTAINER Sheldan
ADD prometheus.yml /etc/prometheus/prometheus.yml

View File

@@ -0,0 +1,17 @@
global:
scrape_interval: 10s
scrape_timeout: 10s
evaluation_interval: 1m
scrape_configs:
- job_name: oneplus_bot_micrometer
honor_timestamps: true
scrape_interval: 5s
scrape_timeout: 5s
metrics_path: /actuator/prometheus
scheme: http
static_configs:
- targets:
- 172.17.0.1:8080
basic_auth:
username: "abstracto"
password_file: /etc/prometheus/micrometer_password

21
deployment/pom.xml Normal file
View File

@@ -0,0 +1,21 @@
<?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>oneplusbot</artifactId>
<groupId>dev.sheldan.oneplus.bot</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>dev.sheldan.oneplus.bot.deployment</groupId>
<artifactId>deployment</artifactId>
<packaging>pom</packaging>
<modules>
<module>docker-compose</module>
<module>image-packaging</module>
</modules>
</project>

48
pom.xml Normal file
View File

@@ -0,0 +1,48 @@
<?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>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath/>
</parent>
<groupId>dev.sheldan.oneplus.bot</groupId>
<artifactId>oneplusbot</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<abstracto.version>1.2</abstracto.version>
<abstracto.templates.version>1.2</abstracto.templates.version>
</properties>
<modules>
<module>application</module>
<module>templates</module>
<module>deployment</module>
</modules>
<repositories>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/Sheldan/*</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>

36
settings.xml Normal file
View File

@@ -0,0 +1,36 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/Sheldan/*</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>${env.user}</username>
<password>${env.token}</password>
</server>
</servers>
</settings>

View File

@@ -0,0 +1,21 @@
<?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.oneplus.bot.templates</groupId>
<artifactId>templates</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>dev.sheldan.oneplus.bot.templates.modules</groupId>
<artifactId>oneplus-bot-modules</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>starboard-custom</module>
</modules>
</project>

View File

@@ -0,0 +1,39 @@
<?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.oneplus.bot.templates.modules</groupId>
<artifactId>oneplus-bot-modules</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>starboard-custom-templates</artifactId>
<packaging>pom</packaging>
<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>starboard-custom-templates-${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -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>

View File

@@ -0,0 +1,41 @@
{
"title": {
"title": "<@safe_include "starboard_post_created_title"/>"
},
<#include "abstracto_color">,
"description": "<@safe_include "starboard_post_created_description"/>",
"fields": [
{
"name": "<@safe_include "starboard_post_notification_field_starboard_message"/>",
<#if starboardMessage??>
"value": "[<@safe_include "starboard_post_notification_field_starboard_message_jump"/>](${starboardMessage.jumpUrl})"
<#else>
"value": "${post.starboardMessageId?c}"
</#if>
},
{
"name": "<@safe_include "starboard_post_notification_field_starred_message"/>",
<#if starredMessage??>
"value": "[<@safe_include "starboard_post_notification_field_starboard_message_jump"/>](${starredMessage.jumpUrl})"
<#else>
"value": "${post.postMessageId?c}"
</#if>
},
{
"name": "<@safe_include "starboard_post_notification_field_starred_user"/>",
<#if starredMember??>
"value": "${starredMember.asMention}"
<#else>
"value": "${starredUserId?c} (<@safe_include "user_left_server"/>)"
</#if>
},
{
"name": "<@safe_include "starboard_post_notification_field_starring_user"/>",
<#if starringMember??>
"value": "${starringMember.asMention}"
<#else>
"value": "${starringUserId?c} (<@safe_include "user_left_server"/>)"
</#if>
}
]
}

View File

@@ -0,0 +1,33 @@
{
"title": {
"title": "<@safe_include "starboard_post_deleted_title"/>"
},
<#include "abstracto_color">,
"description": "<@safe_include "starboard_post_deleted_description"/>",
"fields": [
{
"name": "<@safe_include "starboard_post_notification_field_starred_message"/>",
<#if starredMessage??>
"value": "[<@safe_include "starboard_post_notification_field_starboard_message_jump"/>](${starredMessage.jumpUrl})"
<#else>
"value": "${starredMessageSimple.jumpUrl}"
</#if>
},
{
"name": "<@safe_include "starboard_post_notification_field_starred_user"/>",
<#if starredMember??>
"value": "${starredMember.asMention}"
<#else>
"value": "${starredUserId?c} (<@safe_include "user_left_server"/>)"
</#if>
},
{
"name": "<@safe_include "starboard_post_notification_field_starring_user"/>",
<#if starringMember??>
"value": "${starringMember.asMention}"
<#else>
"value": "${starringUserId?c} (<@safe_include "user_left_server"/>)"
</#if>
}
]
}

22
templates/pom.xml Normal file
View File

@@ -0,0 +1,22 @@
<?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.oneplus.bot</groupId>
<artifactId>oneplusbot</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modules>
<module>oneplus-bot-modules</module>
<module>translations</module>
</modules>
<groupId>dev.sheldan.oneplus.bot.templates</groupId>
<artifactId>templates</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
</project>

View File

@@ -0,0 +1,18 @@
<?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.oneplus.bot.templates</groupId>
<artifactId>templates</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>dev.sheldan.oneplus.bot.templates.translations</groupId>
<artifactId>translations</artifactId>
<packaging>pom</packaging>
<modules>
<module>starboard-custom-translations</module>
</modules>
</project>

View File

@@ -0,0 +1,39 @@
<?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.oneplus.bot.templates.translations</groupId>
<artifactId>translations</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>starboard-custom</artifactId>
<packaging>pom</packaging>
<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>starboard-custom-translations-${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -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>

View File

@@ -0,0 +1 @@
The channel where the notifications about starboard posts should be posted to. Currently: ${currentTarget}

View File

@@ -0,0 +1 @@
Starboard post ${post.id?c} was created, because it reached the threshold.

View File

@@ -0,0 +1 @@
Starboard post was deleted, because it fell under the threshold.