diff --git a/src/main/kotlin/nl/voidcorp/discord/commands/fun/WeatherCommand.kt b/src/main/kotlin/nl/voidcorp/discord/commands/fun/WeatherCommand.kt index af3f7a3..c49a575 100644 --- a/src/main/kotlin/nl/voidcorp/discord/commands/fun/WeatherCommand.kt +++ b/src/main/kotlin/nl/voidcorp/discord/commands/fun/WeatherCommand.kt @@ -19,7 +19,7 @@ class WeatherCommand : Command("weather", aliases = listOf("rain"), group = Comm } val url = URI("http://wttr.in/${URLEncoder.encode(location, "utf-8")}_Fpm.png").toURL().openStream() - event.message.channel.sendFile(url, "$location.png").content("Weather in ${location.replace("+", " ")}").queue() + event.message.channel.sendFile(url, "$location.png").content("Weather in ${location.replace("+", " ").replace("@here", "@hеre").replace("@everyone", "@еveryone") }").queue() return CommandResult.SUCCESS } diff --git a/src/main/kotlin/nl/voidcorp/discord/commands/general/ReportCommand.kt b/src/main/kotlin/nl/voidcorp/discord/commands/general/ReportCommand.kt index 8bd41ab..c8bc8fb 100644 --- a/src/main/kotlin/nl/voidcorp/discord/commands/general/ReportCommand.kt +++ b/src/main/kotlin/nl/voidcorp/discord/commands/general/ReportCommand.kt @@ -5,14 +5,22 @@ 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.context.annotation.Condition +import org.springframework.context.annotation.ConditionContext +import org.springframework.context.annotation.Conditional +import org.springframework.core.type.AnnotatedTypeMetadata import org.springframework.stereotype.Service +@Conditional(ReportCommand.ReportAvailable::class) +@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) + val api = + GitlabAPI.connect("https://gitlab.voidcorp.nl/", System.getenv("GITLAB_API_TOKEN"), 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") } @@ -24,4 +32,9 @@ class ReportCommand : Command( event.reply("Thanks for reporting, a new issue was created: ${theProject.webUrl}/issues/${issue.iid}") return CommandResult.SUCCESS } + + class ReportAvailable : Condition { + override fun matches(context: ConditionContext, metadata: AnnotatedTypeMetadata) = + System.getenv("GITLAB_API_TOKEN") != null + } } \ No newline at end of file