diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/ReleaseInfo.kt b/src/main/kotlin/net/thauvin/erik/mobibot/ReleaseInfo.kt index e92c408..423ab6e 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/ReleaseInfo.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/ReleaseInfo.kt @@ -14,12 +14,12 @@ import java.time.ZoneId */ object ReleaseInfo { const val PROJECT = "mobibot" - const val VERSION = "0.8.0-rc+20250509175846" + const val VERSION = "0.8.0-rc+20250509223055" @JvmField @Suppress("MagicNumber") val BUILD_DATE: LocalDateTime = LocalDateTime.ofInstant( - Instant.ofEpochMilli(1746838726462L), ZoneId.systemDefault() + Instant.ofEpochMilli(1746855055425L), ZoneId.systemDefault() ) const val WEBSITE = "https://mobitopia.org/mobibot/" diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Info.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Info.kt index 8888c9b..7a8b59c 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Info.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Info.kt @@ -98,8 +98,7 @@ class Info(private val tell: Tell, private val seen: Seen) : AbstractCommand() { } else if (isEmpty()) { return "0 second" } - - return this.joinToString(" ") + return joinToString(" ") } } } diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/modules/StockQuote2.kt b/src/main/kotlin/net/thauvin/erik/mobibot/modules/StockQuote2.kt index 143c41b..eadc64c 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/StockQuote2.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/StockQuote2.kt @@ -157,7 +157,7 @@ class StockQuote2 : AbstractModule() { add( PublicMessage( - "Symbol: $tickerSymbol" + "Symbol: ${tickerSymbol.bold()}" ) ) @@ -168,6 +168,16 @@ class StockQuote2 : AbstractModule() { "Price: ".padEnd(pad).prependIndent() + c ) ) + add( + PublicMessage( + "Previous: ".padEnd(pad).prependIndent() + previous + ) + ) + add( + NoticeMessage( + "Symbol: ${tickerSymbol.bold()}" + ) + ) add( NoticeMessage( "Change: ".padEnd(pad).prependIndent() + change + " [$changePercent%]" @@ -188,11 +198,6 @@ class StockQuote2 : AbstractModule() { "Open: ".padEnd(pad).prependIndent() + open ) ) - add( - PublicMessage( - "Previous: ".padEnd(pad).prependIndent() + previous - ) - ) add( NoticeMessage( "Latest: ".padEnd(pad).prependIndent() + latest @@ -242,10 +247,15 @@ class StockQuote2 : AbstractModule() { val json = getJsonResponse(response, debugMessage) val count = json.getInt("count") if (count == 0) { - add(ErrorMessage("Nothing found.")) + add(ErrorMessage("Nothing found for: ${keywords.bold()}")) return messages } + add( + NoticeMessage( + "Search results for: ${keywords.bold()}" + ) + ) val results = json.getJSONArray("result") for (i in 0 until count) { @@ -254,7 +264,7 @@ class StockQuote2 : AbstractModule() { val name = result.getString("description") add( - NoticeMessage("${symbol.bold()}: $name") + NoticeMessage("${symbol.bold()}: $name".prependIndent()) ) if (i >= 4) { diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/StockQuote2Test.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/StockQuote2Test.kt index 5ba8414..73d80de 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/StockQuote2Test.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/StockQuote2Test.kt @@ -119,10 +119,10 @@ class StockQuote2Test : LocalProperties() { val messages = getSanitizedQuote(symbol, apiKey) assertThat(messages, "response not empty").isNotEmpty() assertThat(messages, "getQuote($symbol)").index(0).prop(Message::msg) - .isEqualTo("Symbol: AAPL") + .isEqualTo("Symbol: \u0002AAPL\u0002") assertThat(messages, "getQuote($symbol)").index(1).prop(Message::msg) .matches("\\s+Price:\\s+\\d+\\.\\d+.*".toRegex()) - assertThat(messages, "getQuote($symbol)").index(7).prop(Message::msg) + assertThat(messages, "getQuote($symbol)").index(8).prop(Message::msg) .matches("\\s+Latest:\\s+\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2} UTC".toRegex()) } @@ -156,12 +156,12 @@ class StockQuote2Test : LocalProperties() { val keywords = "alphabet inc" val messages = getSanitizedLookup(keywords, apiKey) assertThat(messages, "messages should not be empty").isNotEmpty() - assertThat(messages, "lookup($keywords)").index(1).prop(Message::msg) - .matches("\u0002\\w+\u0002: .*".toRegex()) + assertThat(messages, "lookup($keywords)").index(0).prop(Message::msg) + .isEqualTo("Search results for: \u0002alphabet inc\u0002") var hasGoog = false for (msg in messages) { - if (msg.msg.matches("\u0002GOOG\u0002: .*".toRegex())) { + if (msg.msg.matches("\\s+\u0002GOOG\u0002: .*".toRegex())) { hasGoog = true break } @@ -179,5 +179,14 @@ class StockQuote2Test : LocalProperties() { .isEqualTo("Please specify at least one search term.") } + @Test + @Throws(ModuleException::class) + fun `Lookup not found`() { + val keywords = "foo motors" + val messages = getSanitizedLookup(keywords, apiKey) + assertThat(messages, "response not empty").isNotEmpty() + assertThat(messages, "lookup($keywords)").index(0).prop(Message::msg) + .isEqualTo("Nothing found for: \u0002foo motors\u0002") + } } }