diff --git a/build.gradle b/build.gradle
index 25c909e..acceb2d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -40,21 +40,22 @@ dependencies {
compileOnly 'pircbot:pircbot:1.5.0:sources'
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
-
- implementation 'com.rometools:rome:1.15.0'
- implementation 'commons-cli:commons-cli:1.4'
- implementation 'commons-net:commons-net:3.8.0'
- implementation 'net.aksingh:owm-japis:2.5.3.0'
- implementation 'net.objecthunter:exp4j:0.4.8'
- implementation 'net.thauvin.erik:pinboard-poster:1.0.3'
- implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0-RC'
- implementation 'org.json:json:20210307'
- implementation 'org.jsoup:jsoup:1.13.1'
- implementation 'org.twitter4j:twitter4j-core:4.0.7'
+
implementation "org.apache.logging.log4j:log4j-api:$versions.log4j"
implementation "org.apache.logging.log4j:log4j-core:$versions.log4j"
implementation "org.apache.logging.log4j:log4j-slf4j-impl:$versions.log4j"
+ implementation 'commons-cli:commons-cli:1.4'
+ implementation 'commons-net:commons-net:3.8.0'
+ implementation 'org.apache.commons:commons-lang3:3.12.0'
+
+ implementation 'com.rometools:rome:1.15.0'
+ implementation 'net.aksingh:owm-japis:2.5.3.0'
+ implementation 'net.objecthunter:exp4j:0.4.8'
+ implementation 'net.thauvin.erik:pinboard-poster:1.0.3'
+ implementation 'org.json:json:20210307'
+ implementation 'org.jsoup:jsoup:1.13.1'
+ implementation 'org.twitter4j:twitter4j-core:4.0.7'
compileOnly "com.github.spotbugs:spotbugs-annotations:$versions.spotbugs"
testCompileOnly "com.github.spotbugs:spotbugs-annotations:$versions.spotbugs"
diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml
index 2080b7b..afd1e14 100644
--- a/config/detekt/baseline.xml
+++ b/config/detekt/baseline.xml
@@ -2,7 +2,6 @@
- ComplexCondition:Addons.kt$Addons$((isPrivate && module.isPrivateMsgEnabled) || !isPrivate) && module.commands.contains(cmd)
ComplexMethod:EntriesMgr.kt$EntriesMgr$ fun saveEntries( bot: Mobibot, entries: List<EntryLink>, history: MutableList<String>, isDayBackup: Boolean )
ComplexMethod:Weather2.kt$Weather2.Companion$ @JvmStatic @Throws(ModuleException::class) fun getWeather(query: String, apiKey: String?): List<Message>
LongMethod:EntriesMgr.kt$EntriesMgr$ fun saveEntries( bot: Mobibot, entries: List<EntryLink>, history: MutableList<String>, isDayBackup: Boolean )
@@ -15,49 +14,14 @@
LongParameterList:Comment.kt$Comment$(bot: Mobibot, cmd: String, sender: String, entry: EntryLink, index: Int, commentIndex: Int)
LongParameterList:Mobibot.kt$Mobibot$( nick: String, list: List<String>, maxPerLine: Int, isPrivate: Boolean, isBold: Boolean = false, isIndent: Boolean = false )
LongParameterList:Twitter.kt$Twitter.Companion$( consumerKey: String?, consumerSecret: String?, token: String?, tokenSecret: String?, handle: String?, message: String, isDm: Boolean )
- MagicNumber:AddLog.kt$AddLog$4
- MagicNumber:Comment.kt$Comment$3
- MagicNumber:CurrencyConverter.kt$CurrencyConverter$11
- MagicNumber:CurrencyConverter.kt$CurrencyConverter$3
- MagicNumber:CurrencyConverter.kt$CurrencyConverter.Companion$3
- MagicNumber:CurrencyConverter.kt$CurrencyConverter.Companion$4
- MagicNumber:CurrencyConverter.kt$CurrencyConverter.Companion$8
- MagicNumber:Cycle.kt$Cycle$10
- MagicNumber:Dice.kt$Dice$7
- MagicNumber:FeedReader.kt$FeedReader$5
- MagicNumber:Ignore.kt$Ignore$8
- MagicNumber:Mobibot.kt$Mobibot$10
- MagicNumber:Mobibot.kt$Mobibot$1000L
- MagicNumber:Mobibot.kt$Mobibot$3
- MagicNumber:Mobibot.kt$Mobibot$5
- MagicNumber:Mobibot.kt$Mobibot$8
- MagicNumber:Modules.kt$Modules$7
- MagicNumber:Recap.kt$Recap.Companion$10
- MagicNumber:Tell.kt$Tell$50
- MagicNumber:Tell.kt$Tell$7
- MagicNumber:Twitter.kt$Twitter$1000L
- MagicNumber:Twitter.kt$Twitter$60L
- MagicNumber:Users.kt$Users$8
- MagicNumber:Utils.kt$Utils$30
- MagicNumber:Utils.kt$Utils$365
- MagicNumber:Utils.kt$Utils$7
- MagicNumber:View.kt$View$8
- MagicNumber:Weather2.kt$Weather2.Companion$1.60934
- MagicNumber:Weather2.kt$Weather2.Companion$32
- MagicNumber:Weather2.kt$Weather2.Companion$5
- MagicNumber:Weather2.kt$Weather2.Companion$9
- MagicNumber:WorldTime.kt$WorldTime$17
- MagicNumber:WorldTime.kt$WorldTime.Companion$3
- MagicNumber:WorldTime.kt$WorldTime.Companion$3600
- MagicNumber:WorldTime.kt$WorldTime.Companion$60
- MagicNumber:WorldTime.kt$WorldTime.Companion$86.4
NestedBlockDepth:Addons.kt$Addons$ fun add(command: AbstractCommand, props: Properties)
NestedBlockDepth:Comment.kt$Comment$override fun commandResponse( sender: String, login: String, args: String, isOp: Boolean, isPrivate: Boolean )
NestedBlockDepth:CurrencyConverter.kt$CurrencyConverter$ override fun run(sender: String, cmd: String, args: String, isPrivate: Boolean)
NestedBlockDepth:CurrencyConverter.kt$CurrencyConverter$override fun helpResponse(sender: String, isPrivate: Boolean): Boolean
- NestedBlockDepth:CurrencyConverter.kt$CurrencyConverter.Companion$ @JvmStatic fun convertCurrency(query: String): Message
+ NestedBlockDepth:CurrencyConverter.kt$CurrencyConverter.Companion$ @Suppress("MagicNumber") @JvmStatic fun convertCurrency(query: String): Message
NestedBlockDepth:EntriesMgr.kt$EntriesMgr$ @Throws(IOException::class, FeedException::class) fun loadEntries(file: String, channel: String, entries: MutableList<EntryLink>): String
NestedBlockDepth:EntriesMgr.kt$EntriesMgr$ fun saveEntries( bot: Mobibot, entries: List<EntryLink>, history: MutableList<String>, isDayBackup: Boolean )
+ NestedBlockDepth:EntriesMgr.kt$EntriesMgr$// Daily backup private fun dailyBackup( bot: Mobibot, history: MutableList<String> )
NestedBlockDepth:EntryLink.kt$EntryLink$ private fun setTags(tags: List<String?>)
NestedBlockDepth:FeedReader.kt$FeedReader$ override fun run()
NestedBlockDepth:GoogleSearch.kt$GoogleSearch$ override fun run(sender: String, cmd: String, args: String, isPrivate: Boolean)
@@ -85,6 +49,5 @@
TooGenericExceptionCaught:Weather2.kt$Weather2.Companion$e: NullPointerException
TooManyFunctions:Mobibot.kt$Mobibot : PircBot
TooManyFunctions:Tell.kt$Tell : AbstractCommand
- TooManyFunctions:Utils.kt$Utils$Utils
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/Addons.kt b/src/main/kotlin/net/thauvin/erik/mobibot/Addons.kt
index 72f4dcd..c2151a0 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/Addons.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/Addons.kt
@@ -97,8 +97,9 @@ class Addons {
return true
}
}
- for (module in modules) {
- if (((isPrivate && module.isPrivateMsgEnabled) || !isPrivate) && module.commands.contains(cmd)) {
+ 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
}
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/FeedReader.kt b/src/main/kotlin/net/thauvin/erik/mobibot/FeedReader.kt
index 0cba397..4e20d32 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/FeedReader.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/FeedReader.kt
@@ -48,6 +48,7 @@ class FeedReader(
private val url: String
) : Runnable {
// Maximum number of feed items to display
+ @Suppress("MagicNumber")
private val maxItems = 5
/**
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt b/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt
index ffa13a5..bf30f72 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt
@@ -207,6 +207,7 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert
}
var retries = 0
while (retries++ < MAX_RECONNECT && !isConnected) {
+ @Suppress("MagicNumber")
sleep(10)
try {
connect(ircServer, ircPort)
@@ -240,6 +241,7 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert
/**
* Responds with the default help.
*/
+ @Suppress("MagicNumber")
fun helpDefault(sender: String, isOp: Boolean, isPrivate: Boolean) {
send(sender, "Type a URL on $channel to post it.", isPrivate)
send(sender, "For more information on a specific command, type:", isPrivate)
@@ -305,6 +307,7 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert
if (weblogUrl.isNotBlank()) {
version = weblogUrl
}
+ @Suppress("MagicNumber")
sleep(5)
connect()
}
@@ -361,6 +364,7 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert
timer.cancel()
twitter.shutdown()
twitter.notification("$name stopped by $sender on $channel")
+ @Suppress("MagicNumber")
sleep(3)
quitServer("The Bot Is Out There!")
exitProcess(0)
@@ -467,6 +471,7 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert
*/
fun sleep(secs: Int) {
try {
+ @Suppress("MagicNumber")
Thread.sleep(secs * 1000L)
} catch (ignore: InterruptedException) {
// Do nothing
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt b/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt
index d5c3486..2304bc0 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt
@@ -51,6 +51,7 @@ import java.util.stream.Collectors
/**
* Miscellaneous utilities.
*/
+@Suppress("TooManyFunctions")
object Utils {
private val searchFlags = arrayOf("%c", "%n")
@@ -234,6 +235,7 @@ object Utils {
/**
* Converts milliseconds to year month week day hour and minutes.
*/
+ @Suppress("MagicNumber")
@JvmStatic
fun uptime(uptime: Long): String {
val info = StringBuilder()
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/AddLog.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/AddLog.kt
index 261a154..c0c0275 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/AddLog.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/AddLog.kt
@@ -63,6 +63,7 @@ class AddLog(bot: Mobibot) : AbstractCommand(bot) {
return
}
}
+ @Suppress("MagicNumber")
bot.sendList(sender, history, 4, isPrivate, isIndent = true)
}
}
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Cycle.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Cycle.kt
index a62b87f..32c06e5 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Cycle.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Cycle.kt
@@ -36,6 +36,7 @@ import net.thauvin.erik.mobibot.Mobibot
import net.thauvin.erik.mobibot.Utils
class Cycle(bot: Mobibot) : AbstractCommand(bot) {
+ @Suppress("MagicNumber")
private val wait = 10
override val name = "cycle"
override val help = listOf("To have the bot leave the channel and come back:", Utils.helpFormat("%c $name"))
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Ignore.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Ignore.kt
index cdcc77f..cb635f2 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Ignore.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Ignore.kt
@@ -140,6 +140,7 @@ class Ignore(bot: Mobibot) : AbstractCommand(bot) {
if (ignored.size > 0) {
bot.send(sender, "The following nicks are ignored:", isPrivate)
+ @Suppress("MagicNumber")
bot.sendList(sender, ignored.sorted(), 8, isPrivate, isIndent = true)
} else {
bot.send(sender, "No one is currently ${Utils.bold("ignored")}.", isPrivate)
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Modules.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Modules.kt
index d2d780b..50ddc93 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Modules.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Modules.kt
@@ -58,6 +58,7 @@ class Modules(bot: Mobibot) : AbstractCommand(bot) {
send(sender, "There are no enabled modules.", isPrivate)
} else {
send(sender, "The enabled modules are: ", isPrivate)
+ @Suppress("MagicNumber")
sendList(sender, modulesNames, 7, isPrivate, isIndent = true)
}
} else {
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Recap.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Recap.kt
index 364fc5f..cbcf5d0 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Recap.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Recap.kt
@@ -60,6 +60,7 @@ class Recap(bot: Mobibot) : AbstractCommand(bot) {
Utils.utcDateTime(LocalDateTime.now(Clock.systemUTC()))
+ " - $sender" + (if (isAction) " " else ": ") + message
)
+ @Suppress("MagicNumber")
if (recaps.size > 10) {
recaps.removeAt(0)
}
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Users.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Users.kt
index 759b54c..1d1ec6e 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Users.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Users.kt
@@ -62,6 +62,7 @@ class Users(bot: Mobibot) : AbstractCommand(bot) {
}
}
+ @Suppress("MagicNumber")
bot.sendList(sender, nicks.sorted(), 8, isPrivate, isIndent = true)
}
}
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/links/Comment.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/links/Comment.kt
index 8b55a5d..9a8685a 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/links/Comment.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/links/Comment.kt
@@ -65,6 +65,7 @@ class Comment(bot: Mobibot) : AbstractCommand(bot) {
isOp: Boolean,
isPrivate: Boolean
) {
+ @Suppress("MagicNumber")
val cmds = args.substring(1).split("[.:]".toRegex(), 3)
val index = cmds[0].toInt() - 1
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/links/View.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/links/View.kt
index 7bca9bd..0627d93 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/links/View.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/links/View.kt
@@ -40,6 +40,7 @@ import net.thauvin.erik.mobibot.entries.EntriesUtils
import net.thauvin.erik.mobibot.entries.EntryLink
class View(bot: Mobibot) : AbstractCommand(bot) {
+ @Suppress("MagicNumber")
private val maxEntries = 8
override val name = VIEW_CMD
override val help = listOf(
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 0890a25..80b7f79 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
@@ -53,9 +53,11 @@ class Tell(bot: Mobibot) : AbstractCommand(bot) {
private val serializedObject: String
// Maximum number of days to keep messages
+ @Suppress("MagicNumber")
private var maxDays = 7
// Message maximum queue size
+ @Suppress("MagicNumber")
private var maxSize = 50
/**
@@ -227,8 +229,7 @@ class Tell(bot: Mobibot) : AbstractCommand(bot) {
save()
}
} else if (message.sender.equals(nickname, ignoreCase = true) && message.isReceived
- && !message.isNotified
- ) {
+ && !message.isNotified) {
bot.send(
nickname,
"Your message ${reverseColor("[ID " + message.id + ']')} was sent to " +
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 0a3136a..00fe777 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntriesMgr.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntriesMgr.kt
@@ -71,6 +71,53 @@ object EntriesMgr {
// Maximum number of backlogs to keep
private const val maxBacklogs = 10
+ // Daily backup
+ private fun dailyBackup(
+ bot: Mobibot,
+ history: MutableList
+ ) {
+ if (bot.backlogsUrl.isNotBlank()) {
+ if (!history.contains(bot.today)) {
+ history.add(bot.today)
+ while (history.size > maxBacklogs) {
+ history.removeAt(0)
+ }
+ }
+ OutputStreamWriter(
+ Files.newOutputStream(Paths.get(bot.logsDir + NAV_XML)), StandardCharsets.UTF_8
+ ).use { fw ->
+ val output = SyndFeedOutput()
+ val rss: SyndFeed = SyndFeedImpl()
+ val items: MutableList = mutableListOf()
+ var item: SyndEntry
+ with(rss) {
+ feedType = "rss_2.0"
+ title = "${bot.channel} IRC Links Backlogs"
+ description = "Backlogs of Links from ${bot.ircServer} on ${bot.channel}"
+ link = bot.backlogsUrl
+ publishedDate = Calendar.getInstance().time
+ }
+ var date: String
+ items.clear()
+ for (i in history.size - 1 downTo 0) {
+ date = history[i]
+ item = SyndEntryImpl()
+ with(item) {
+ link = bot.backlogsUrl + date + ".xml"
+ title = date
+ description = SyndContentImpl().apply { value = "Links for $date" }
+ }
+ items.add(item)
+ }
+ rss.entries = items
+ if (bot.logger.isDebugEnabled) bot.logger.debug("Writing the backlog feed.")
+ output.output(rss, fw)
+ }
+ } else {
+ bot.logger.warn("Unable to generate the backlogs feed. No property configured.")
+ }
+ }
+
/**
* Loads the backlogs.
*/
@@ -139,7 +186,7 @@ object EntriesMgr {
if (bot.logsDir.isNotBlank() && bot.weblogUrl.isNotBlank()) {
try {
val output = SyndFeedOutput()
- var rss: SyndFeed = SyndFeedImpl()
+ val rss: SyndFeed = SyndFeedImpl()
val items: MutableList = mutableListOf()
var item: SyndEntry
OutputStreamWriter(
@@ -153,12 +200,12 @@ object EntriesMgr {
publishedDate = Calendar.getInstance().time
language = "en"
}
- var buff: StringBuilder
+ val buff: StringBuilder = StringBuilder()
var comment: EntryComment
for (i in entries.size - 1 downTo 0) {
with(entries[i]) {
- buff = StringBuilder()
- .append("Posted by ")
+ buff.setLength(0)
+ buff.append("Posted by ")
.append(nick)
.append(" on output.output(rss, fw) }
if (isDayBackup) {
- if (bot.backlogsUrl.isNotBlank()) {
- if (!history.contains(bot.today)) {
- history.add(bot.today)
- while (history.size > maxBacklogs) {
- history.removeAt(0)
- }
- }
- OutputStreamWriter(
- Files.newOutputStream(Paths.get(bot.logsDir + NAV_XML)), StandardCharsets.UTF_8
- ).use { fw ->
- rss = SyndFeedImpl()
- with(rss) {
- feedType = "rss_2.0"
- title = "${bot.channel} IRC Links Backlogs"
- description = "Backlogs of Links from ${bot.ircServer} on ${bot.channel}"
- link = bot.backlogsUrl
- publishedDate = Calendar.getInstance().time
- }
- var date: String
- items.clear()
- for (i in history.size - 1 downTo 0) {
- date = history[i]
- item = SyndEntryImpl()
- with(item) {
- link = bot.backlogsUrl + date + ".xml"
- title = date
- description = SyndContentImpl().apply { value = "Links for $date" }
- }
- items.add(item)
- }
- rss.entries = items
- if (bot.logger.isDebugEnabled) bot.logger.debug("Writing the backlog feed.")
- output.output(rss, fw)
- }
- } else {
- bot.logger.warn("Unable to generate the backlogs feed. No property configured.")
- }
+ dailyBackup(bot, history)
}
} catch (e: FeedException) {
if (bot.logger.isWarnEnabled) bot.logger.warn("Unable to generate the entries feed.", e)
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/modules/CurrencyConverter.kt b/src/main/kotlin/net/thauvin/erik/mobibot/modules/CurrencyConverter.kt
index 9542395..acf3669 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/CurrencyConverter.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/CurrencyConverter.kt
@@ -86,6 +86,7 @@ class CurrencyConverter(bot: Mobibot) : ThreadedModule(bot) {
}
} else if (args.contains(CURRENCY_RATES_KEYWORD)) {
send(sender, "The currency rates for ${Utils.bold(pubDate)} are:", isPrivate)
+ @Suppress("MagicNumber")
sendList(sender, currencyRates(), 3, isPrivate, isIndent = true)
} else {
helpResponse(sender, isPrivate)
@@ -122,6 +123,7 @@ class CurrencyConverter(bot: Mobibot) : ThreadedModule(bot) {
isPrivate
)
send(sender, "The supported currencies are: ", isPrivate)
+ @Suppress("MagicNumber")
sendList(sender, ArrayList(EXCHANGE_RATES.keys), 11, isPrivate, isIndent = true)
}
}
@@ -150,6 +152,7 @@ class CurrencyConverter(bot: Mobibot) : ThreadedModule(bot) {
/**
* Converts from a currency to another.
*/
+ @Suppress("MagicNumber")
@JvmStatic
fun convertCurrency(query: String): Message {
val cmds = query.split(" ")
@@ -185,6 +188,7 @@ class CurrencyConverter(bot: Mobibot) : ThreadedModule(bot) {
fun currencyRates(): List {
val rates = mutableListOf()
for ((key, value) in EXCHANGE_RATES) {
+ @Suppress("MagicNumber")
rates.add(" $key: ${StringUtils.leftPad(value, 8)}")
}
return rates
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/modules/Dice.kt b/src/main/kotlin/net/thauvin/erik/mobibot/modules/Dice.kt
index 42eb680..53c39ad 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/Dice.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/Dice.kt
@@ -73,6 +73,7 @@ class Dice(bot: Mobibot) : AbstractModule(bot) {
}
private fun roll(): Pair {
+ @Suppress("MagicNumber")
return Pair(Random.nextInt(1, 7), Random.nextInt(1, 7))
}
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 a479fd1..7fdefd4 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/Twitter.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/Twitter.kt
@@ -145,6 +145,7 @@ class Twitter(bot: Mobibot) : ThreadedModule(bot) {
if (bot.logger.isDebugEnabled) {
bot.logger.debug("Scheduling {} for posting on Twitter.", EntriesUtils.buildLinkCmd(index))
}
+ @Suppress("MagicNumber")
bot.timer.schedule(TwitterTimer(bot, index), Constants.TIMER_DELAY * 60L * 1000L)
}
}
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 23f9665..8c01cff 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/Weather2.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/Weather2.kt
@@ -89,6 +89,7 @@ class Weather2(bot: Mobibot) : ThreadedModule(bot) {
}
private fun getTemps(d: Double?): String {
+ @Suppress("MagicNumber")
val c = (d!! - 32) * 5 / 9
return "${d.roundToInt()} °F, ${c.roundToInt()} °C"
}
@@ -186,6 +187,7 @@ class Weather2(bot: Mobibot) : ThreadedModule(bot) {
}
private fun wind(w: Double): String {
+ @Suppress("MagicNumber")
val kmh = w * 1.60934
return "${w.roundToInt()} mph, ${kmh.roundToInt()} km/h"
}
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 d93f0b1..0b21462 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/WorldTime.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/WorldTime.kt
@@ -60,6 +60,7 @@ class WorldTime(bot: Mobibot) : AbstractModule(bot) {
/**
* Returns the current Internet (beat) Time.
*/
+ @Suppress("MagicNumber")
private fun internetTime(): String {
val zdt = ZonedDateTime.now(ZoneId.of("UTC+01:00"))
val beats = ((zdt[ChronoField.SECOND_OF_MINUTE] + zdt[ChronoField.MINUTE_OF_HOUR] * 60
@@ -171,6 +172,7 @@ class WorldTime(bot: Mobibot) : AbstractModule(bot) {
countries["ZULU"] = "Zulu"
countries["INTERNET"] = BEATS_KEYWORD
countries["BEATS"] = BEATS_KEYWORD
+ @Suppress("MagicNumber")
ZoneId.getAvailableZoneIds().stream()
.filter { tz: String ->
!tz.contains("/") && tz.length == 3 && !countries.containsKey(tz)
@@ -191,6 +193,7 @@ class WorldTime(bot: Mobibot) : AbstractModule(bot) {
with(bot) {
if (args.isEmpty()) {
send(sender, "The supported countries/zones are: ", isPrivate)
+ @Suppress("MagicNumber")
sendList(sender, ArrayList(COUNTRIES_MAP.keys), 17, isPrivate = false)
} else {
val msg = time(args)
diff --git a/version.properties b/version.properties
index bff0913..9d6cb44 100644
--- a/version.properties
+++ b/version.properties
@@ -1,9 +1,9 @@
#Generated by the Semver Plugin for Gradle
-#Sat May 01 21:41:40 PDT 2021
-version.buildmeta=568
+#Mon May 03 14:17:39 PDT 2021
+version.buildmeta=576
version.major=0
version.minor=8
version.patch=0
version.prerelease=beta
version.project=mobibot
-version.semver=0.8.0-beta+568
+version.semver=0.8.0-beta+576