Skip to content

Commit

Permalink
Merge branch 'main' into translations
Browse files Browse the repository at this point in the history
  • Loading branch information
NoComment1105 committed Nov 28, 2024
2 parents 0991d15 + b4c3fd9 commit 69e4975
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 37 deletions.
2 changes: 0 additions & 2 deletions src/main/kotlin/org/hyacinthbots/lilybot/LilyBot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import org.hyacinthbots.lilybot.extensions.utility.commands.PublicUtilities
import org.hyacinthbots.lilybot.extensions.utility.commands.Reminders
import org.hyacinthbots.lilybot.extensions.utility.commands.RoleMenu
import org.hyacinthbots.lilybot.extensions.utility.commands.StartupHooks
import org.hyacinthbots.lilybot.extensions.utility.commands.StatusPing
import org.hyacinthbots.lilybot.extensions.utility.commands.Tags
import org.hyacinthbots.lilybot.extensions.utility.events.UtilityEvents
import org.hyacinthbots.lilybot.internal.BuildInfo
Expand Down Expand Up @@ -174,7 +173,6 @@ suspend fun main() {
add(::Report)
add(::RoleMenu)
add(::StartupHooks)
add(::StatusPing)
add(::Tags)
add(::ThreadControl)
add(::UtilityEvents)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ import dev.kordex.core.utils.dm
import dev.kordex.core.utils.scheduling.Scheduler
import dev.kordex.core.utils.scheduling.Task
import dev.kordex.core.utils.toDuration
import io.github.oshai.kotlinlogging.KotlinLogging
import io.ktor.client.HttpClient
import io.ktor.client.request.post
import kotlinx.datetime.Clock
import kotlinx.datetime.DateTimePeriod
import kotlinx.datetime.TimeZone
Expand All @@ -47,10 +50,17 @@ import org.hyacinthbots.lilybot.database.entities.ReminderData
import org.hyacinthbots.lilybot.utils.botHasChannelPerms
import org.hyacinthbots.lilybot.utils.fitsEmbedField
import org.hyacinthbots.lilybot.utils.interval
import org.hyacinthbots.lilybot.utils.statusEnv

class Reminders : Extension() {
override val name = "reminders"

/** Logger for status ping. */
private val statusLogger = KotlinLogging.logger("Status ping")

/** Client for status ping. */
private val statusClient = HttpClient {}

/** The scheduler that will track the time for reminder posting. */
private val reminderScheduler = Scheduler()

Expand Down Expand Up @@ -467,6 +477,13 @@ class Reminders : Extension() {
* @since 4.2.0
*/
private suspend fun postReminders() {
// Start status ping

// Doing this status ping in here as this is an already running scheduler and can easily have this added
// to avoid duplicating the scheduler. This should always ping if the bots up too so why make another
statusLogger.debug { "Pinging!" }
statusClient.post(statusEnv)
// End status ping
val reminders = ReminderCollection().getAllReminders()
val dueReminders =
reminders.filter { it.remindTime.toEpochMilliseconds() - Clock.System.now().toEpochMilliseconds() <= 0 }
Expand Down

This file was deleted.

3 changes: 3 additions & 0 deletions src/main/kotlin/org/hyacinthbots/lilybot/utils/_Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ val SENTRY_DSN = envOrNull("SENTRY_DSN")
/** The environment the bot is being run in. production or development. */
val ENVIRONMENT = env("ENVIRONMENT")

/** URL to ping to indicate uptime.*/
val statusEnv = env("STATUS_URL")

const val HYACINTH_GITHUB: String = "https://github.com/HyacinthBots"

0 comments on commit 69e4975

Please sign in to comment.