Add report command, which can be used to add bugreports or feature requests

merge-requests/2/head
Julius de Jeu 2019-06-11 15:19:10 +02:00
parent 08723f71eb
commit fd0bc1843d
3 changed files with 30 additions and 3 deletions

View File

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

View File

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

View File

@ -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
ottobot.version=1.4