diff --git a/build.gradle b/build.gradle index 04f4e02..b639fa8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,3 @@ -import org.apache.tools.ant.filters.ReplaceTokens - plugins { id 'java' id 'org.jetbrains.kotlin.jvm' version '1.3.31' @@ -51,6 +49,7 @@ dependencies { implementation "com.fasterxml.jackson.core:jackson-databind" implementation "com.fasterxml.jackson.module:jackson-module-kotlin" + implementation 'org.gitlab:java-gitlab-api:4.1.0' } diff --git a/src/main/kotlin/nl/voidcorp/discord/commands/general/ReportCommand.kt b/src/main/kotlin/nl/voidcorp/discord/commands/general/ReportCommand.kt new file mode 100644 index 0000000..d2f1f95 --- /dev/null +++ b/src/main/kotlin/nl/voidcorp/discord/commands/general/ReportCommand.kt @@ -0,0 +1,28 @@ +package nl.voidcorp.discord.commands.general + +import nl.voidcorp.discord.command.Command +import nl.voidcorp.discord.command.CommandMessage +import nl.voidcorp.discord.command.CommandResult +import org.gitlab.api.GitlabAPI +import org.gitlab.api.TokenType +import org.springframework.stereotype.Service + +@Service +class ReportCommand : Command( + "report", + helpMesage = "Report a bug or request a feature for the bot!", + usage = "report bug/feature \"name\" \"description\"" +) { + val api = GitlabAPI.connect("https://gitlab.voidcorp.nl/", "KUqA3G9DnPVtCgitmfgU", TokenType.PRIVATE_TOKEN) + override fun handle(event: CommandMessage): CommandResult { + if (event.params.size != 4) return CommandResult.PARAMETERS + val theProject = api.projects.first { it.name.contains("ottobotv2") } + val (type, title, descr) = event.params.drop(1) + if (type.toLowerCase() !in listOf("bug", "feature")) return CommandResult.PARAMETERS + + + val issue = api.createIssue(theProject.id, 0, null, type.toLowerCase().capitalize(), descr, title) + event.reply("Thanks for reporting, a new issue was created: ${theProject.webUrl}/issues/${issue.iid}") + return CommandResult.SUCCESS + } +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8aba5b2..526416d 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -8,4 +8,4 @@ spring.jpa.generate-ddl=true spring.jpa.hibernate.ddl-auto=create-drop spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true -ottobot.version=1.3 \ No newline at end of file +ottobot.version=1.4 \ No newline at end of file