Added Sanitize function.
This commit is contained in:
parent
384331b287
commit
0d144d4b10
7 changed files with 70 additions and 31 deletions
|
@ -31,9 +31,6 @@
|
|||
*/
|
||||
package net.thauvin.erik.mobibot.modules
|
||||
|
||||
import net.thauvin.erik.mobibot.Utils.obfuscate
|
||||
import net.thauvin.erik.mobibot.Utils.replaceEach
|
||||
|
||||
/**
|
||||
* The `ModuleException` class.
|
||||
*/
|
||||
|
@ -64,22 +61,6 @@ class ModuleException : Exception {
|
|||
this.debugMessage = debugMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the sanitized message (e.g. remove API keys, etc.)
|
||||
*/
|
||||
fun getSanitizedMessage(vararg sanitize: String): String {
|
||||
val obfuscate = sanitize.map { it.obfuscate() }.toTypedArray()
|
||||
return when {
|
||||
cause?.message != null -> {
|
||||
cause.javaClass.name + ": " + cause.message!!.replaceEach(sanitize, obfuscate)
|
||||
}
|
||||
message != null -> {
|
||||
message.javaClass.name + ": " + message.replaceEach(sanitize, obfuscate)
|
||||
}
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val serialVersionUID = 1L
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ class StockQuote(bot: Mobibot) : ThreadedModule(bot) {
|
|||
val data = arrayOf(
|
||||
"Open" to "02. open",
|
||||
"High" to "03. high",
|
||||
"Low" to "04. low",
|
||||
"Low" to "04. low",
|
||||
"Volume" to "06. volume",
|
||||
"Latest" to "07. latest trading day"
|
||||
)
|
||||
|
|
|
@ -42,7 +42,6 @@ import java.time.ZonedDateTime
|
|||
import java.time.format.DateTimeFormatter
|
||||
import java.time.temporal.ChronoField
|
||||
import java.util.Collections
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* The WorldTime module.
|
||||
|
@ -65,12 +64,12 @@ class WorldTime(bot: Mobibot) : AbstractModule(bot) {
|
|||
/**
|
||||
* Returns the current Internet (beat) Time.
|
||||
*/
|
||||
@Suppress("MagicNumber")
|
||||
@Suppress("MagicNumber", "ImplicitDefaultLocale")
|
||||
private fun internetTime(): String {
|
||||
val zdt = ZonedDateTime.now(ZoneId.of("UTC+01:00"))
|
||||
val beats = ((zdt[ChronoField.SECOND_OF_MINUTE] + zdt[ChronoField.MINUTE_OF_HOUR] * 60
|
||||
+ zdt[ChronoField.HOUR_OF_DAY] * 3600) / 86.4).toInt()
|
||||
return String.format(Locale.getDefault(), "%c%03d", '@', beats)
|
||||
return String.format("%c%03d", '@', beats)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue