Merge branch 'bug/everyoneinweather' into 'master'
Fix weather being able to use @ See merge request jdejeu/ottobotv2!6
This commit is contained in:
commit
b78a331592
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue