Updated dependencies.
This commit is contained in:
parent
05b7ca8a41
commit
2c1ea56e79
5 changed files with 10 additions and 14 deletions
|
@ -33,14 +33,11 @@ package net.thauvin.erik.mobibot.modules
|
|||
|
||||
import net.thauvin.erik.crypto.CryptoException
|
||||
import net.thauvin.erik.crypto.CryptoPrice
|
||||
import net.thauvin.erik.crypto.CryptoPrice.Companion.marketPrice
|
||||
import net.thauvin.erik.crypto.CryptoPrice.Companion.spotPrice
|
||||
import net.thauvin.erik.mobibot.Mobibot
|
||||
import net.thauvin.erik.mobibot.Utils.helpFormat
|
||||
import net.thauvin.erik.mobibot.msg.PublicMessage
|
||||
|
||||
import java.text.NumberFormat
|
||||
import java.util.Currency
|
||||
|
||||
/**
|
||||
* The Cryptocurrency Prices module.
|
||||
*/
|
||||
|
@ -56,7 +53,7 @@ class CryptoPrices(bot: Mobibot) : ThreadedModule(bot) {
|
|||
val price = currentPrice(args.split(' '))
|
||||
val amount = try {
|
||||
price.toCurrency()
|
||||
} catch (e: IllegalArgumentException) {
|
||||
} catch (ignore: IllegalArgumentException) {
|
||||
price.amount
|
||||
}
|
||||
send(sender, PublicMessage("${price.base}: $amount [${price.currency}]"))
|
||||
|
@ -82,9 +79,9 @@ class CryptoPrices(bot: Mobibot) : ThreadedModule(bot) {
|
|||
*/
|
||||
fun currentPrice(args: List<String>): CryptoPrice {
|
||||
return if (args.size == 2)
|
||||
marketPrice(args[0], args[1])
|
||||
spotPrice(args[0], args[1])
|
||||
else
|
||||
marketPrice(args[0])
|
||||
spotPrice(args[0])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,11 +45,11 @@ class CryptoPricesTest {
|
|||
var price = currentPrice(listOf("BTC"))
|
||||
assertThat(price.base).describedAs("is BTC").isEqualTo("BTC")
|
||||
assertThat(price.currency).describedAs("is USD").isEqualTo("USD")
|
||||
assertThat(price.amount).describedAs("BTC > 0").isGreaterThan(0.00)
|
||||
assertThat(price.amount.signum() > 0).describedAs("BTC > 0").isTrue
|
||||
|
||||
price = currentPrice(listOf("ETH", "EUR"))
|
||||
assertThat(price.base).describedAs("is ETH").isEqualTo("ETH")
|
||||
assertThat(price.currency).describedAs("is EUR").isEqualTo("EUR")
|
||||
assertThat(price.amount).describedAs("ETH > 0").isGreaterThan(0.00)
|
||||
assertThat(price.amount.signum() > 0).describedAs("ETH > 0").isTrue
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue