Added capitalizeWords extension function.
This commit is contained in:
parent
79efd005d1
commit
aab28b5979
4 changed files with 26 additions and 5 deletions
|
@ -101,6 +101,12 @@ object Utils {
|
|||
@JvmStatic
|
||||
fun String.capitalise(): String = this.replaceFirstChar { it.uppercase() }
|
||||
|
||||
/**
|
||||
* Capitalize words
|
||||
*/
|
||||
fun String.capitalizeWords(): String = split(" ").map { it.lowercase().capitalise() }.joinToString(" ")
|
||||
|
||||
|
||||
/**
|
||||
* Colorize a string.
|
||||
*/
|
||||
|
|
|
@ -38,6 +38,7 @@ import net.aksingh.owmjapis.model.CurrentWeather
|
|||
import net.thauvin.erik.mobibot.Mobibot
|
||||
import net.thauvin.erik.mobibot.Utils.bold
|
||||
import net.thauvin.erik.mobibot.Utils.capitalise
|
||||
import net.thauvin.erik.mobibot.Utils.capitalizeWords
|
||||
import net.thauvin.erik.mobibot.Utils.encodeUrl
|
||||
import net.thauvin.erik.mobibot.Utils.helpFormat
|
||||
import net.thauvin.erik.mobibot.msg.ErrorMessage
|
||||
|
@ -135,7 +136,12 @@ class Weather2(bot: Mobibot) : ThreadedModule(bot) {
|
|||
owm.currentWeatherByCityName(city, country)
|
||||
}
|
||||
if (cwd.hasCityName()) {
|
||||
messages.add(PublicMessage("City: ${cwd.cityName} [${country.value}]"))
|
||||
messages.add(
|
||||
PublicMessage(
|
||||
"City: ${cwd.cityName}, " +
|
||||
country.name.replace('_', ' ').capitalizeWords() + " [${country.value}]"
|
||||
)
|
||||
)
|
||||
with(cwd.mainData) {
|
||||
if (this != null) {
|
||||
if (hasTemp()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue