mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-22 13:14:12 +00:00
added initial version containing ping/echo command and first draft of the command handling structure
This commit is contained in:
36
abstracto-application/command/command-int/pom.xml
Normal file
36
abstracto-application/command/command-int/pom.xml
Normal 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.abstracto.command</groupId>
|
||||
<artifactId>command</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<artifactId>command-int</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<artifactId>JDA</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>club.minnced</groupId>
|
||||
<artifactId>opus-java</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,11 @@
|
||||
package dev.sheldan.abstracto.command;
|
||||
|
||||
import dev.sheldan.abstracto.command.execution.Configuration;
|
||||
import dev.sheldan.abstracto.command.execution.Context;
|
||||
import dev.sheldan.abstracto.command.execution.Result;
|
||||
|
||||
public interface Command<T> {
|
||||
|
||||
Result execute(Context context);
|
||||
Configuration getConfiguration();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package dev.sheldan.abstracto.command.execution;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter @Setter @Builder
|
||||
public class Configuration {
|
||||
|
||||
private String name;
|
||||
private String module;
|
||||
private String description;
|
||||
private List<Parameter> parameters;
|
||||
private boolean causesReaction;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package dev.sheldan.abstracto.command.execution;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
|
||||
@Builder
|
||||
@Getter
|
||||
public class Context {
|
||||
private TextChannel channel;
|
||||
private User author;
|
||||
private Message message;
|
||||
private Parameters parameters;
|
||||
private JDA jda;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.abstracto.command.execution;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter @Setter @Builder
|
||||
public class Parameter {
|
||||
private String name;
|
||||
private Class type;
|
||||
private boolean optional;
|
||||
private boolean remainder;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package dev.sheldan.abstracto.command.execution;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Builder
|
||||
public class Parameters {
|
||||
@Getter
|
||||
private List<Object> parameters;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package dev.sheldan.abstracto.command.execution;
|
||||
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter @Setter @Builder
|
||||
public class Result {
|
||||
private ResultState result;
|
||||
private String message;
|
||||
|
||||
public static Result fromSuccess() {
|
||||
return Result.builder().result(ResultState.SUCCESSFUL).build();
|
||||
}
|
||||
|
||||
public static Result fromError(String message){
|
||||
return Result.builder().result(ResultState.ERROR).message(message).build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package dev.sheldan.abstracto.command.execution;
|
||||
|
||||
public enum ResultState {
|
||||
ERROR, SUCCESSFUL, IGNORED
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.abstracto.command.meta;
|
||||
|
||||
|
||||
import dev.sheldan.abstracto.command.Command;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CommandRegistry {
|
||||
Command findCommandByParameters(String name, UnParsedCommandParameter context);
|
||||
Command findCommand(String message);
|
||||
List<Command> getAllCommands();
|
||||
boolean isCommand(Message message);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package dev.sheldan.abstracto.command.meta;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter @Setter
|
||||
public class UnParsedCommandParameter {
|
||||
private List<String> parameters;
|
||||
}
|
||||
Reference in New Issue
Block a user