diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 6407ef6..321b376 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -14,6 +14,9 @@
+
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
index 23f4bb5..79ee123 100644
--- a/.idea/codeStyles/codeStyleConfig.xml
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -1,6 +1,5 @@
-
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 5fe6323..871deaa 100644
--- a/build.gradle
+++ b/build.gradle
@@ -116,12 +116,6 @@ detekt {
baseline = file("${projectDir}/config/detekt/baseline.xml")
}
-javadoc {
- options.tags = ['created']
- options.author = true
- options.links('http://www.jibble.org/javadocs/pircbot/', 'http://docs.oracle.com/javase/8/docs/api/')
-}
-
jar {
manifest.attributes('Main-Class': mainClassName,
'Class-Path': '. ./lib/' + configurations.runtimeClasspath.collect { it.getName() }.join(' ./lib/'))
diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml
index 81addac..07ee2ba 100644
--- a/config/detekt/baseline.xml
+++ b/config/detekt/baseline.xml
@@ -34,6 +34,7 @@
NestedBlockDepth:Tell.kt$Tell$ @JvmOverloads fun send(nickname: String, isMessage: Boolean = false)
NestedBlockDepth:Tell.kt$Tell$// Delete message. private fun deleteMessage(sender: String, args: String, isOp: Boolean, isPrivate: Boolean)
NestedBlockDepth:TellMessagesMgr.kt$TellMessagesMgr$ fun save(file: String, messages: List<TellMessage?>?, logger: Logger)
+ NestedBlockDepth:TwitterOAuth.kt$TwitterOAuth$ @Throws(TwitterException::class, IOException::class) @JvmStatic fun main(args: Array<String>)
NestedBlockDepth:Weather2.kt$Weather2$ override fun run(sender: String, cmd: String, args: String, isPrivate: Boolean)
NestedBlockDepth:Weather2.kt$Weather2.Companion$ @JvmStatic @Throws(ModuleException::class) fun getWeather(query: String, apiKey: String?): List<Message>
NestedBlockDepth:WorldTime.kt$WorldTime$override fun commandResponse( sender: String, cmd: String, args: String, isPrivate: Boolean )
diff --git a/properties/mobibot.properties b/properties/mobibot.properties
index 4043eeb..8089d08 100644
--- a/properties/mobibot.properties
+++ b/properties/mobibot.properties
@@ -27,7 +27,7 @@ tell-max-size=50
#pinboard-api-token=user\:TOKEN
#
-# Configure app at: https://apps.twitter.com/
+# Configure app at: https://developer.twitter.com/en/apps
# and then: java -cp mobibot.jar net.thauvin.erik.mobibot.TwitterOAuth
#
#twitter-consumerKey=
diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/War.java b/src/main/java/net/thauvin/erik/mobibot/modules/War.java
index 8c18b9f..7795e33 100644
--- a/src/main/java/net/thauvin/erik/mobibot/modules/War.java
+++ b/src/main/java/net/thauvin/erik/mobibot/modules/War.java
@@ -48,6 +48,8 @@ import static net.thauvin.erik.mobibot.Utils.bold;
* @since 1.0
*/
public final class War extends AbstractModule {
+ // Random
+ private static final SecureRandom RANDOM = new SecureRandom();
// War command
private static final String WAR_CMD = "war";
// Deck of card
@@ -55,8 +57,6 @@ public final class War extends AbstractModule {
new String[]{ "Ace", "King", "Queen", "Jack", "10", "9", "8", "7", "6", "5", "4", "3", "2" };
// Suits for the deck of card
private static final String[] WAR_SUITS = new String[]{ "Hearts", "Spades", "Diamonds", "Clubs" };
- // Random
- private static final SecureRandom RANDOM = new SecureRandom();
/**
* The default constructor.
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/Addons.kt b/src/main/kotlin/net/thauvin/erik/mobibot/Addons.kt
index c2151a0..5496fd9 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/Addons.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/Addons.kt
@@ -33,7 +33,7 @@ package net.thauvin.erik.mobibot
import net.thauvin.erik.mobibot.commands.AbstractCommand
import net.thauvin.erik.mobibot.modules.AbstractModule
-import java.util.*
+import java.util.Properties
/**
* Modules and Commands addons.
@@ -100,8 +100,8 @@ class Addons {
val mods = if (isPrivate) modules.filter { it.isPrivateMsgEnabled } else modules
for (module in mods) {
if (module.commands.contains(cmd)) {
- module.commandResponse(sender, cmd, args, isPrivate)
- return true
+ module.commandResponse(sender, cmd, args, isPrivate)
+ return true
}
}
return false
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/Constants.kt b/src/main/kotlin/net/thauvin/erik/mobibot/Constants.kt
index 317cc35..d1b33b3 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/Constants.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/Constants.kt
@@ -31,7 +31,7 @@
*/
package net.thauvin.erik.mobibot
-import java.util.*
+import java.util.Locale
/**
* The `Constants`.
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt b/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt
index 1efd54b..90997bc 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt
@@ -64,8 +64,8 @@ import net.thauvin.erik.mobibot.commands.links.View
import net.thauvin.erik.mobibot.commands.tell.Tell
import net.thauvin.erik.mobibot.entries.EntriesMgr
import net.thauvin.erik.mobibot.entries.EntryLink
-import net.thauvin.erik.mobibot.modules.CryptoPrices
import net.thauvin.erik.mobibot.modules.Calc
+import net.thauvin.erik.mobibot.modules.CryptoPrices
import net.thauvin.erik.mobibot.modules.CurrencyConverter
import net.thauvin.erik.mobibot.modules.Dice
import net.thauvin.erik.mobibot.modules.GoogleSearch
@@ -99,7 +99,8 @@ import java.io.IOException
import java.io.PrintStream
import java.nio.file.Files
import java.nio.file.Paths
-import java.util.*
+import java.util.Properties
+import java.util.Timer
import java.util.logging.ConsoleHandler
import java.util.regex.Pattern
import kotlin.system.exitProcess
@@ -358,7 +359,7 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert
helpResponse(sender, args, true)
} else if (isOp && Constants.KILL_CMD == cmd) { // kill
twitter.notification("$name killed by $sender on $channel")
- sendRawLine("QUIT : Poof!")
+ sendRawLine("QUIT :Poof!")
exitProcess(0)
} else if (isOp && Constants.DIE_CMD == cmd) { // die
send("$sender has just signed my death sentence.")
@@ -492,8 +493,7 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert
* Returns the bot's version.
*/
override fun onVersion(sourceNick: String, sourceLogin: String, sourceHostname: String, target: String) {
- sendRawLine("NOTICE " + sourceNick + " :\u0001VERSION " + ReleaseInfo.PROJECT + ' ' + ReleaseInfo.VERSION
- + "\u0001")
+ sendRawLine("NOTICE $sourceNick :\u0001VERSION ${ReleaseInfo.PROJECT} ${ReleaseInfo.VERSION}\u0001")
}
companion object {
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/PinboardUtils.kt b/src/main/kotlin/net/thauvin/erik/mobibot/PinboardUtils.kt
index 29460ed..8c388f9 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/PinboardUtils.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/PinboardUtils.kt
@@ -32,7 +32,6 @@
package net.thauvin.erik.mobibot
-import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking
import net.thauvin.erik.mobibot.entries.EntryLink
@@ -40,7 +39,7 @@ import net.thauvin.erik.pinboard.PinboardPoster
import java.time.ZoneId
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
-import java.util.*
+import java.util.Date
/**
* Handles posts to pinboard.in.
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/TwitterTimer.kt b/src/main/kotlin/net/thauvin/erik/mobibot/TwitterTimer.kt
index 0b8ad2a..6b3a4b3 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/TwitterTimer.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/TwitterTimer.kt
@@ -32,7 +32,7 @@
package net.thauvin.erik.mobibot
-import java.util.*
+import java.util.TimerTask
class TwitterTimer(var bot: Mobibot, private var index: Int) : TimerTask() {
override fun run() {
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt b/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt
index 2304bc0..82ce058 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt
@@ -44,7 +44,7 @@ import java.nio.charset.StandardCharsets
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
-import java.util.*
+import java.util.Date
import java.util.concurrent.TimeUnit
import java.util.stream.Collectors
@@ -82,13 +82,13 @@ object Utils {
val replace = arrayOf(if (isPrivate) "/msg $botNick" else "$botNick:", botNick)
return StringUtils.replaceEach(text, searchFlags, replace)
}
-
+
/**
* Capitalize a string.
*/
@JvmStatic
fun capitalize(s: String?): String? = s?.replaceFirstChar { it.uppercase() }
-
+
/**
* Colorize a string.
*/
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/Tell.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/Tell.kt
index 80b7f79..9052110 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/Tell.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/Tell.kt
@@ -327,7 +327,7 @@ class Tell(bot: Mobibot) : AbstractCommand(bot) {
const val MAX_DAYS_PROP = "tell-max-days"
/**
- * Max size proeprty.
+ * Max size property.
*/
const val MAX_SIZE_PROP = "tell-max-size"
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntriesMgr.kt b/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntriesMgr.kt
index 00fe777..50a8e6a 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntriesMgr.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntriesMgr.kt
@@ -47,7 +47,7 @@ import java.io.OutputStreamWriter
import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.nio.file.Paths
-import java.util.*
+import java.util.Calendar
/**
* Manages the feed entries.
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntryLink.kt b/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntryLink.kt
index 08d10e7..09f22a7 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntryLink.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntryLink.kt
@@ -36,7 +36,8 @@ import com.rometools.rome.feed.synd.SyndCategoryImpl
import net.thauvin.erik.mobibot.commands.links.LinksMgr
import org.apache.commons.lang3.StringUtils
import java.io.Serializable
-import java.util.*
+import java.util.Calendar
+import java.util.Date
/**
* The class used to store link entries.
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/modules/Calc.kt b/src/main/kotlin/net/thauvin/erik/mobibot/modules/Calc.kt
index a197391..11602e6 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/Calc.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/Calc.kt
@@ -52,10 +52,10 @@ class Calc(bot: Mobibot) : AbstractModule(bot) {
try {
bot.send(calculate(args))
} catch (e: IllegalArgumentException) {
- if (bot.logger.isWarnEnabled) bot.logger.warn("Failed to calcualte: $args", e)
+ if (bot.logger.isWarnEnabled) bot.logger.warn("Failed to calculate: $args", e)
bot.send("No idea. This is the kind of math I don't get.")
} catch (e: UnknownFunctionOrVariableException) {
- if (bot.logger.isWarnEnabled) bot.logger.warn("Unable to calcualte: $args", e)
+ if (bot.logger.isWarnEnabled) bot.logger.warn("Unable to calculate: $args", e)
bot.send("No idea. I must've some form of Dyscalculia.")
}
} else {
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/modules/StockQuote.kt b/src/main/kotlin/net/thauvin/erik/mobibot/modules/StockQuote.kt
index f8e1a8f..60c5f0f 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/StockQuote.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/StockQuote.kt
@@ -79,7 +79,7 @@ class StockQuote(bot: Mobibot) : ThreadedModule(bot) {
const val INVALID_SYMBOL = "Invalid symbol."
// Alpha Advantage URL
- private const val ALAPHAVANTAGE_URL = "https://www.alphavantage.co/query?function="
+ private const val ALPHAVANTAGE_URL = "https://www.alphavantage.co/query?function="
// Quote command
private const val STOCK_CMD = "stock"
@@ -122,7 +122,8 @@ class StockQuote(bot: Mobibot) : ThreadedModule(bot) {
fun getQuote(symbol: String, apiKey: String?): List {
if (apiKey.isNullOrBlank()) {
throw ModuleException(
- "${Utils.capitalize(STOCK_CMD)} is disabled. The API key is missing.")
+ "${Utils.capitalize(STOCK_CMD)} is disabled. The API key is missing."
+ )
}
return if (symbol.isNotBlank()) {
val debugMessage = "getQuote($symbol)"
@@ -132,10 +133,10 @@ class StockQuote(bot: Mobibot) : ThreadedModule(bot) {
with(messages) {
// Search for symbol/keywords
response = Utils.urlReader(
- URL(
- "${ALAPHAVANTAGE_URL}SYMBOL_SEARCH&keywords=" + Utils.encodeUrl(symbol)
- + "&apikey=" + Utils.encodeUrl(apiKey)
- )
+ URL(
+ "${ALPHAVANTAGE_URL}SYMBOL_SEARCH&keywords=" + Utils.encodeUrl(symbol)
+ + "&apikey=" + Utils.encodeUrl(apiKey)
+ )
)
var json = getJsonResponse(response, debugMessage)
val symbols = json.getJSONArray("bestMatches")
@@ -146,11 +147,11 @@ class StockQuote(bot: Mobibot) : ThreadedModule(bot) {
// Get quote for symbol
response = Utils.urlReader(
- URL(
- "${ALAPHAVANTAGE_URL}GLOBAL_QUOTE&symbol="
- + Utils.encodeUrl(symbolInfo.getString("1. symbol"))
- + "&apikey=" + Utils.encodeUrl(apiKey)
- )
+ URL(
+ "${ALPHAVANTAGE_URL}GLOBAL_QUOTE&symbol="
+ + Utils.encodeUrl(symbolInfo.getString("1. symbol"))
+ + "&apikey=" + Utils.encodeUrl(apiKey)
+ )
)
json = getJsonResponse(response, debugMessage)
val quote = json.getJSONObject("Global Quote")
@@ -159,36 +160,36 @@ class StockQuote(bot: Mobibot) : ThreadedModule(bot) {
return messages
}
add(
- PublicMessage(
- "Symbol: " + Utils.unescapeXml(quote.getString("01. symbol"))
- + " [" + Utils.unescapeXml(symbolInfo.getString("2. name")) + ']'
- )
+ PublicMessage(
+ "Symbol: " + Utils.unescapeXml(quote.getString("01. symbol"))
+ + " [" + Utils.unescapeXml(symbolInfo.getString("2. name")) + ']'
+ )
)
add(PublicMessage(" Price: " + Utils.unescapeXml(quote.getString("05. price"))))
add(
- PublicMessage(
- " Previous: " + Utils.unescapeXml(quote.getString("08. previous close"))
- )
+ PublicMessage(
+ " Previous: " + Utils.unescapeXml(quote.getString("08. previous close"))
+ )
)
add(NoticeMessage(" Open: " + Utils.unescapeXml(quote.getString("02. open"))))
add(NoticeMessage(" High: " + Utils.unescapeXml(quote.getString("03. high"))))
add(NoticeMessage(" Low: " + Utils.unescapeXml(quote.getString("04. low"))))
add(
- NoticeMessage(
- " Volume: " + Utils.unescapeXml(quote.getString("06. volume"))
- )
+ NoticeMessage(
+ " Volume: " + Utils.unescapeXml(quote.getString("06. volume"))
+ )
)
add(
- NoticeMessage(
- " Latest: "
- + Utils.unescapeXml(quote.getString("07. latest trading day"))
- )
+ NoticeMessage(
+ " Latest: "
+ + Utils.unescapeXml(quote.getString("07. latest trading day"))
+ )
)
add(
- NoticeMessage(
- " Change: " + Utils.unescapeXml(quote.getString("09. change")) + " ["
- + Utils.unescapeXml(quote.getString("10. change percent")) + ']'
- )
+ NoticeMessage(
+ " Change: " + Utils.unescapeXml(quote.getString("09. change")) + " ["
+ + Utils.unescapeXml(quote.getString("10. change percent")) + ']'
+ )
)
}
}
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/modules/Twitter.kt b/src/main/kotlin/net/thauvin/erik/mobibot/modules/Twitter.kt
index eb08dd5..09441a4 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/Twitter.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/Twitter.kt
@@ -42,7 +42,6 @@ import net.thauvin.erik.mobibot.msg.NoticeMessage
import twitter4j.TwitterException
import twitter4j.TwitterFactory
import twitter4j.conf.ConfigurationBuilder
-import java.util.*
/**
* The Twitter module.
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/modules/Weather2.kt b/src/main/kotlin/net/thauvin/erik/mobibot/modules/Weather2.kt
index 8c01cff..ae49759 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/Weather2.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/Weather2.kt
@@ -102,7 +102,8 @@ class Weather2(bot: Mobibot) : ThreadedModule(bot) {
fun getWeather(query: String, apiKey: String?): List {
if (apiKey.isNullOrBlank()) {
throw ModuleException(
- "${Utils.capitalize(WEATHER_CMD)} is disabled. The API key is missing.")
+ "${Utils.capitalize(WEATHER_CMD)} is disabled. The API key is missing."
+ )
}
val owm = OWM(apiKey)
val messages = mutableListOf()
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/modules/WorldTime.kt b/src/main/kotlin/net/thauvin/erik/mobibot/modules/WorldTime.kt
index 0d74165..78c91ec 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/WorldTime.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/WorldTime.kt
@@ -41,8 +41,8 @@ import java.time.ZoneId
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoField
-import java.util.*
-import kotlin.collections.ArrayList
+import java.util.Collections
+import java.util.Locale
/**
* The WorldTime module.
@@ -146,7 +146,7 @@ class WorldTime(bot: Mobibot) : AbstractModule(bot) {
countries["MX"] = "America/Mexico_City"
countries["NL"] = "Europe/Amsterdam"
countries["NO"] = "Europe/Oslo"
- countries["NP"] = "Asia/Katmandu"
+ countries["NP"] = "Asia/Kathmandu"
countries["NZ"] = "Pacific/Auckland"
countries["PDT"] = "America/Los_Angeles"
countries["PH"] = "Asia/Manila"
diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/LocalProperties.kt b/src/test/kotlin/net/thauvin/erik/mobibot/LocalProperties.kt
index 0c7095e..70434a4 100644
--- a/src/test/kotlin/net/thauvin/erik/mobibot/LocalProperties.kt
+++ b/src/test/kotlin/net/thauvin/erik/mobibot/LocalProperties.kt
@@ -35,7 +35,7 @@ import org.testng.annotations.BeforeSuite
import java.io.IOException
import java.nio.file.Files
import java.nio.file.Paths
-import java.util.*
+import java.util.Properties
/**
* Access to `local.properties`.
diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/UtilsTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/UtilsTest.kt
index a57d591..8b75b72 100644
--- a/src/test/kotlin/net/thauvin/erik/mobibot/UtilsTest.kt
+++ b/src/test/kotlin/net/thauvin/erik/mobibot/UtilsTest.kt
@@ -56,7 +56,7 @@ import java.io.File
import java.io.IOException
import java.net.URL
import java.time.LocalDateTime
-import java.util.*
+import java.util.Calendar
/**
* The `Utils Test` class.
diff --git a/version.properties b/version.properties
index 7802055..3846e61 100644
--- a/version.properties
+++ b/version.properties
@@ -1,9 +1,9 @@
#Generated by the Semver Plugin for Gradle
-#Wed May 12 19:01:23 PDT 2021
-version.buildmeta=751
+#Thu May 13 21:34:31 PDT 2021
+version.buildmeta=771
version.major=0
version.minor=8
version.patch=0
version.prerelease=beta
version.project=mobibot
-version.semver=0.8.0-beta+751
+version.semver=0.8.0-beta+771