Skip to content

Commit

Permalink
Add data notice and /about command
Browse files Browse the repository at this point in the history
  • Loading branch information
NyCodeGHG committed Nov 11, 2022
1 parent 5c069df commit a93edac
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bot/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import java.util.*
plugins {
`regenbogen-ice-module`
id("com.google.devtools.ksp") version "1.7.10-1.0.6"
id("dev.schlaubi.mikbot.gradle-plugin") version "2.6.2"
id("dev.schlaubi.mikbot.gradle-plugin") version "2.6.3"
idea
}

group = "dev.nycode"
version = "0.6.3"
version = "0.6.4"

repositories {
mavenCentral()
Expand All @@ -19,14 +19,14 @@ repositories {

dependencies {
compileOnly(kotlin("stdlib-jdk8"))
mikbot("dev.schlaubi", "mikbot-api", "3.14.0-SNAPSHOT")
mikbot("dev.schlaubi", "mikbot-api", "3.15.0-SNAPSHOT")
ksp("dev.schlaubi", "mikbot-plugin-processor", "2.3.0")
ksp("com.kotlindiscord.kord.extensions", "annotation-processor", "1.5.5-SNAPSHOT")
implementation(libs.marudor)
implementation(libs.regenbogen.ice)
implementation(libs.ktor.client.logging)
implementation(projects.rwMutex)
plugin("dev.schlaubi", "mikbot-health", "1.4.0")
plugin("dev.schlaubi", "mikbot-health", "1.5.0")
}

mikbotPlugin {
Expand All @@ -46,7 +46,7 @@ tasks {
dependsOn(generateDefaultResourceBundle)
}
assembleBot {
bundledPlugins.set(listOf("health@1.4.0", "ktor@2.7.0"))
bundledPlugins.set(listOf("health@1.5.0", "ktor@2.8.0"))
}
runBot {
environment["DOWNLOAD_PLUGINS"] = "health,ktor"
Expand Down
2 changes: 2 additions & 0 deletions bot/src/main/kotlin/RegenbogenICEPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.kotlindiscord.kord.extensions.builders.ExtensibleBotBuilder
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.utils.loadModule
import dev.kord.core.on
import dev.nycode.regenbogenice.commands.aboutCommand
import dev.nycode.regenbogenice.commands.currentRideCommand
import dev.nycode.regenbogenice.notification.notificationCommand
import dev.nycode.regenbogenice.presence.RailTrackPresence
Expand Down Expand Up @@ -69,6 +70,7 @@ class RegenbogenICEExtension : Extension() {
override suspend fun setup() {
currentRideCommand()
notificationCommand()
aboutCommand()
kord.on<AllShardsReadyEvent> {
presence.start()
}
Expand Down
23 changes: 23 additions & 0 deletions bot/src/main/kotlin/commands/AboutCommand.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package dev.nycode.regenbogenice.commands

import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.rest.builder.message.create.embed
import dev.nycode.regenbogenice.RegenbogenICEExtension

suspend fun RegenbogenICEExtension.aboutCommand() = publicSlashCommand {
name = "commands.about"
description = "commands.about.description"

action {
respond {
embed {
title = "Regenbogen ICE"
description = translate("commands.about.text")
field(translate("source-code")) {
"https://github.com/mikbot/regenbogen-ice"
}
}
}
}
}
4 changes: 4 additions & 0 deletions bot/src/main/kotlin/commands/CurrentRideCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import dev.nycode.regenbogenice.locale.updateLocaleAsync
import dev.nycode.regenbogenice.presence.REGENBOGEN_ICE_TZN
import dev.nycode.regenbogenice.train.TrainOverride
import dev.nycode.regenbogenice.train.fetchCurrentTrip
import dev.nycode.regenbogenice.util.dataNotice
import dev.schlaubi.hafalsch.marudor.Marudor
import dev.schlaubi.hafalsch.marudor.entity.JourneyInformation
import dev.schlaubi.hafalsch.rainbow_ice.entity.TrainVehicle
Expand Down Expand Up @@ -145,6 +146,9 @@ context (InteractionResponseModifyBuilder)
inline = true
}
}
dataNotice {
translate(it)
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions bot/src/main/kotlin/notification/NotificationSender.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import dev.nycode.regenbogenice.commands.displayName
import dev.nycode.regenbogenice.commands.formatTrainTime
import dev.nycode.regenbogenice.locale.userLocaleCollection
import dev.nycode.regenbogenice.train.isObsolete
import dev.nycode.regenbogenice.util.dataNotice
import dev.nycode.regenbogenice.util.isFuture
import dev.nycode.regenbogenice.util.isPast
import dev.schlaubi.hafalsch.rainbow_ice.entity.TrainVehicle
Expand Down Expand Up @@ -146,6 +147,9 @@ suspend fun buildNotificationMessage(
}
}
}
dataNotice {
translate(it)
}
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions bot/src/main/kotlin/util/EmbedNotice.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package dev.nycode.regenbogenice.util

import dev.kord.rest.builder.message.EmbedBuilder

inline fun EmbedBuilder.dataNotice(translate: (String) -> String) {
footer {
text = translate("general.data_notice")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ converter.station.not_found=Haltestelle `{0}` nicht gefunden.
converter.station.empty_station=Haltestelle konnte nicht gefunden werden.
notification.train_near_you=Der Zug {0} ist bald in deiner Nähe.
notification.next_stop=Nächster Halt:
general.data_notice=Daten bereitgestellt von https://regenbogen-ice.de
commands.about=about
commands.about.description=Zeigt Informationen über den Bot.
commands.about.text=Dieser Bot zeigt Informationen über verschiedene deutsche Hochgeschwindigkeitszüge auf ihren Fahrten an.\n\nDieser Bot wurde unabhängig von den ursprünglichen Machern von [regenbogen-ice.de](https://regenbogen-ice.de) entwickelt, von denen die Daten freundlicherweise zur Verfügung gestellt werden. :heart:
source-code=Quellcode
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ converter.station.station=Station
converter.station.not_found=Station `{0}` not found
notification.train_near_you=The train {0} will soon be near you
notification.next_stop=Next Stop:
general.data_notice=Data provided by https://regenbogen-ice.de
commands.about=about
commands.about.description=Shows information about the bot.
commands.about.text=This bot shows information about various german high speed trains on their journeys.\nThis bot was developed independently of the original creators of [regenbogen-ice.de](https://regenbogen-ice.de), from whom the data is kindly provided. :heart:
source-code=Source Code

0 comments on commit a93edac

Please sign in to comment.