added module responsible for accumulating the dependencies and resulting in a jar

added channels module
added help info object to command configuration
added description field to parameter
added modules for commands (and packed modules), they are mapped by name
added post command execution interface
added support for optional parameters
added support for using guildchannel as parameter
added printing of modules to help command
added service beans to wrap over the operations on the repository
added synchronizing of channels/roles on startup (controlled by flag)
added builder annotations to model classes
added more model classes
This commit is contained in:
Sheldan
2019-12-12 16:47:54 +01:00
parent 42cfe33b3a
commit 5c6b7b9a78
61 changed files with 1136 additions and 138 deletions

View File

@@ -0,0 +1,23 @@
<?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>command-base</artifactId>
<groupId>dev.sheldan.abstracto.command</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>channels</artifactId>
<dependencies>
<dependency>
<groupId>dev.sheldan.abstracto.core</groupId>
<artifactId>core-interface</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,18 @@
package dev.sheldan.abstracto.command.channels;
import dev.sheldan.abstracto.command.Module;
import dev.sheldan.abstracto.command.module.ModuleInfo;
import org.springframework.stereotype.Component;
@Component
public class ChannelsModule implements Module {
@Override
public ModuleInfo getInfo() {
return ModuleInfo.builder().name("channels").description("Includes utilities to configure the channel configuration stored in the database").build();
}
@Override
public String getParentModule() {
return "default";
}
}

View File

@@ -0,0 +1,49 @@
package dev.sheldan.abstracto.command.channels;
import dev.sheldan.abstracto.command.Command;
import dev.sheldan.abstracto.command.execution.Configuration;
import dev.sheldan.abstracto.command.execution.Context;
import dev.sheldan.abstracto.command.execution.Parameter;
import dev.sheldan.abstracto.command.execution.Result;
import dev.sheldan.abstracto.core.models.AChannel;
import dev.sheldan.abstracto.core.service.ChannelService;
import dev.sheldan.abstracto.core.service.PostTargetService;
import net.dv8tion.jda.api.entities.GuildChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
@Service
public class PostTarget implements Command {
@Autowired
private PostTargetService service;
@Autowired
private ChannelService channelService;
@Override
public Result execute(Context context) {
GuildChannel channel = (GuildChannel) context.getParameters().getParameters().get(1);
String targetName = (String) context.getParameters().getParameters().get(0);
AChannel dbChannel = channelService.loadChannel(channel.getIdLong());
service.createOrUpdate(targetName, dbChannel);
return Result.fromSuccess();
}
@Override
public Configuration getConfiguration() {
Parameter channel = Parameter.builder().name("channel").type(GuildChannel.class).description("The channel to post towards").build();
Parameter postTargetName = Parameter.builder().name("name").type(String.class).description("The name of the post target to redirect").build();
List<Parameter> parameters = Arrays.asList(postTargetName, channel);
return Configuration.builder()
.name("posttarget")
.module("channels")
.parameters(parameters)
.description("Sets the target of a post done by the bot")
.causesReaction(false)
.build();
}
}