Fixed formatting.
This commit is contained in:
parent
bf985d5626
commit
df7384570e
2 changed files with 11 additions and 10 deletions
|
@ -41,6 +41,7 @@ import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Bitcoin module.
|
* The Bitcoin module.
|
||||||
|
@ -104,8 +105,9 @@ class Bitcoin(bot: Mobibot) : ThreadedModule(bot) {
|
||||||
// BTC command
|
// BTC command
|
||||||
private const val BTC_CMD = "btc"
|
private const val BTC_CMD = "btc"
|
||||||
|
|
||||||
// XBT command
|
private fun JSONObject.getDecimal(key: String): String {
|
||||||
private const val XBT_CMD = "xbt"
|
return DecimalFormat("0.00").format(this.getBigDecimal(key))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the bitcoin market price.
|
* Retrieves the bitcoin market price.
|
||||||
|
@ -121,10 +123,10 @@ class Bitcoin(bot: Mobibot) : ThreadedModule(bot) {
|
||||||
val bpi = json.getJSONObject(currency.trim().uppercase())
|
val bpi = json.getJSONObject(currency.trim().uppercase())
|
||||||
val symbol = bpi.getString("symbol");
|
val symbol = bpi.getString("symbol");
|
||||||
with(messages) {
|
with(messages) {
|
||||||
add(PublicMessage("BITCOIN: $symbol" + bpi.getBigDecimal("last") + " [$currency]"))
|
add(PublicMessage("BITCOIN: $symbol" + bpi.getDecimal("last") + " [$currency]"))
|
||||||
add(NoticeMessage(" 15m: $symbol" + bpi.getBigDecimal("15m")))
|
add(NoticeMessage(" 15m: $symbol" + bpi.getDecimal("15m")))
|
||||||
add(NoticeMessage(" Buy: $symbol" + bpi.getBigDecimal("buy")))
|
add(NoticeMessage(" Buy: $symbol" + bpi.getDecimal("buy")))
|
||||||
add(NoticeMessage(" Sell: $symbol" + bpi.getBigDecimal("sell")))
|
add(NoticeMessage(" Sell: $symbol" + bpi.getDecimal("sell")))
|
||||||
}
|
}
|
||||||
return messages
|
return messages
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
|
@ -141,6 +143,5 @@ class Bitcoin(bot: Mobibot) : ThreadedModule(bot) {
|
||||||
init {
|
init {
|
||||||
commands.add(BITCOIN_CMD)
|
commands.add(BITCOIN_CMD)
|
||||||
commands.add(BTC_CMD)
|
commands.add(BTC_CMD)
|
||||||
commands.add(XBT_CMD)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#Generated by the Semver Plugin for Gradle
|
#Generated by the Semver Plugin for Gradle
|
||||||
#Tue May 04 17:52:51 PDT 2021
|
#Tue May 04 21:29:29 PDT 2021
|
||||||
version.buildmeta=618
|
version.buildmeta=628
|
||||||
version.major=0
|
version.major=0
|
||||||
version.minor=8
|
version.minor=8
|
||||||
version.patch=0
|
version.patch=0
|
||||||
version.prerelease=beta
|
version.prerelease=beta
|
||||||
version.project=mobibot
|
version.project=mobibot
|
||||||
version.semver=0.8.0-beta+618
|
version.semver=0.8.0-beta+628
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue