Added date format to currency converter response.
This commit is contained in:
parent
8b63846270
commit
bc8bf6bf57
4 changed files with 20 additions and 14 deletions
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -1,3 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
|
@ -7,6 +8,7 @@
|
|||
<option name="customRuleSets">
|
||||
<list>
|
||||
<option value="K:\java\semver\config\pmd.xml" />
|
||||
<option value="$PROJECT_DIR$/../../java/bld-exec/config/pmd.xml" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="skipTestSources" value="false" />
|
||||
|
|
13
build.gradle
13
build.gradle
|
@ -13,7 +13,7 @@ plugins {
|
|||
id 'org.jetbrains.kotlin.jvm' version '1.9.10'
|
||||
id 'org.jetbrains.kotlin.kapt' version '1.9.10'
|
||||
id 'org.jetbrains.kotlinx.kover' version '0.7.3'
|
||||
id 'org.sonarqube' version '4.3.1.3277'
|
||||
id 'org.sonarqube' version '4.4.1.3373'
|
||||
id 'pmd'
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ defaultTasks 'deploy'
|
|||
|
||||
final def packageName = 'net.thauvin.erik.mobibot'
|
||||
final def deployDir = 'deploy'
|
||||
final def semverProcessor = "net.thauvin.erik:semver:1.2.0"
|
||||
final def semverProcessor = "net.thauvin.erik:semver:1.2.1"
|
||||
|
||||
final def isCI = (System.getenv('CI') != null)
|
||||
|
||||
|
@ -77,15 +77,16 @@ dependencies {
|
|||
|
||||
implementation 'com.rometools:rome:2.1.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.11.0'
|
||||
implementation 'com.squareup.okio:okio:3.6.0'
|
||||
implementation 'net.aksingh:owm-japis:2.5.3.0'
|
||||
implementation 'net.objecthunter:exp4j:0.4.8'
|
||||
implementation 'org.json:json:20230618'
|
||||
implementation 'org.jsoup:jsoup:1.16.1'
|
||||
|
||||
// Thauvin
|
||||
implementation 'net.thauvin.erik:cryptoprice:1.0.0'
|
||||
implementation 'net.thauvin.erik:jokeapi:0.9-SNAPSHOT'
|
||||
implementation 'net.thauvin.erik:pinboard-poster:1.0.3'
|
||||
implementation 'net.thauvin.erik:cryptoprice:1.0.1'
|
||||
implementation 'net.thauvin.erik:jokeapi:0.9.0'
|
||||
implementation 'net.thauvin.erik:pinboard-poster:1.1.0'
|
||||
implementation 'net.thauvin.erik.urlencoder:urlencoder-lib:1.4.0'
|
||||
|
||||
testImplementation 'com.willowtreeapps.assertk:assertk-jvm:0.27.0'
|
||||
|
@ -211,7 +212,7 @@ sonarqube {
|
|||
property('sonar.organization', 'ethauvin-github')
|
||||
property('sonar.projectKey', 'ethauvin_mobibot')
|
||||
property('sonar.host.url', 'https://sonarcloud.io')
|
||||
property('sonar.coverage.jacoco.xmlReportPaths', "${project.buildDir}/reports/kover/report.xml")
|
||||
property('sonar.coverage.jacoco.xmlReportPaths', "${layout.buildDirectory.get()}/reports/kover/report.xml")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ import org.pircbotx.hooks.types.GenericMessageEvent
|
|||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.IOException
|
||||
import java.math.BigDecimal
|
||||
import java.net.URL
|
||||
import java.text.DecimalFormat
|
||||
import java.util.*
|
||||
|
||||
|
||||
|
@ -101,7 +101,7 @@ class CurrencyConverter : AbstractModule() {
|
|||
event.sendMessage(helpFormat(helpCmdSyntax("%c $CURRENCY_CMD 100 USD to EUR", nick, isPrivateMsgEnabled)))
|
||||
event.sendMessage(
|
||||
helpFormat(
|
||||
helpCmdSyntax("%c $CURRENCY_CMD 50,000 GBP to BTC", nick, isPrivateMsgEnabled)
|
||||
helpCmdSyntax("%c $CURRENCY_CMD 50,000 GBP to USD", nick, isPrivateMsgEnabled)
|
||||
)
|
||||
)
|
||||
event.sendMessage("To list the supported currency codes:")
|
||||
|
@ -132,6 +132,9 @@ class CurrencyConverter : AbstractModule() {
|
|||
// Currency symbols
|
||||
private val SYMBOLS: TreeMap<String, String> = TreeMap()
|
||||
|
||||
// Decimal format
|
||||
private val DECIMAL_FORMAT = DecimalFormat("0.00")
|
||||
|
||||
/**
|
||||
* Converts from a currency to another.
|
||||
*/
|
||||
|
@ -156,7 +159,7 @@ class CurrencyConverter : AbstractModule() {
|
|||
val json = JSONObject(body)
|
||||
|
||||
if (json.getString("result") == "success") {
|
||||
val result = json.getDouble("conversion_result")
|
||||
val result = DECIMAL_FORMAT.format(json.getDouble("conversion_result"))
|
||||
PublicMessage(
|
||||
"${cmds[0]} ${SYMBOLS[to]} = $result ${SYMBOLS[from]}"
|
||||
)
|
||||
|
@ -188,8 +191,8 @@ class CurrencyConverter : AbstractModule() {
|
|||
if (json.getString("result") == "success") {
|
||||
val codes = json.getJSONArray("supported_codes")
|
||||
for (i in 0 until codes.length()) {
|
||||
val code = codes.getJSONArray(i);
|
||||
SYMBOLS[code.getString(0)] = code.getString(1);
|
||||
val code = codes.getJSONArray(i)
|
||||
SYMBOLS[code.getString(0)] = code.getString(1)
|
||||
}
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#Generated by the Semver Plugin for Gradle
|
||||
#Fri Sep 22 04:02:33 PDT 2023
|
||||
version.buildmeta=20230922040233
|
||||
#Wed Oct 04 08:46:27 PDT 2023
|
||||
version.buildmeta=20231004084627
|
||||
version.major=0
|
||||
version.minor=8
|
||||
version.patch=0
|
||||
version.prerelease=rc
|
||||
version.project=mobibot
|
||||
version.semver=0.8.0-rc+20230922040233
|
||||
version.semver=0.8.0-rc+20231004084627
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue