diff --git a/.idea/mobibot.iml b/.idea/mobibot.iml index 85e216a..255f0c1 100644 --- a/.idea/mobibot.iml +++ b/.idea/mobibot.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/mobibot.main.iml b/.idea/modules/mobibot.main.iml index 4c00984..c12d92e 100644 --- a/.idea/modules/mobibot.main.iml +++ b/.idea/modules/mobibot.main.iml @@ -1,5 +1,5 @@ - + @@ -8,7 +8,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -95,7 +67,34 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/mobibot.test.iml b/.idea/modules/mobibot.test.iml index 822bffe..9e64bd2 100644 --- a/.idea/modules/mobibot.test.iml +++ b/.idea/modules/mobibot.test.iml @@ -1,5 +1,5 @@ - + @@ -8,7 +8,7 @@ \ No newline at end of file diff --git a/build.gradle b/build.gradle index 9ff3602..8c0d5f3 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,7 @@ repositories { dependencies { kapt(semverProcessor) - implementation(semverProcessor) + compileOnly(semverProcessor) implementation 'pircbot:pircbot:1.5.0' compileOnly 'pircbot:pircbot:1.5.0:sources' diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml index 5d4c70d..dc51202 100644 --- a/config/detekt/baseline.xml +++ b/config/detekt/baseline.xml @@ -3,8 +3,8 @@ ComplexMethod:EntriesMgr.kt$EntriesMgr.Companion$ fun saveEntries( bot: Mobibot, entries: List<EntryLink>, history: MutableList<String>, isDayBackup: Boolean ) - ComplexMethod:Mobibot.kt$Mobibot$override fun onPrivateMessage( sender: String, login: String, hostname: String, message: String ) ComplexMethod:Weather2.kt$Weather2.Companion$ @JvmStatic @Throws(ModuleException::class) fun getWeather(query: String, apiKey: String?): List<Message> + EmptyDefaultConstructor:Message.kt$Message$() LongMethod:EntriesMgr.kt$EntriesMgr.Companion$ fun saveEntries( bot: Mobibot, entries: List<EntryLink>, history: MutableList<String>, isDayBackup: Boolean ) LongMethod:Mobibot.kt$Mobibot.Companion$ @JvmStatic fun main(args: Array<String>) LongMethod:StockQuote.kt$StockQuote.Companion$ @JvmStatic @Throws(ModuleException::class) fun getQuote(symbol: String, apiKey: String?): List<Message> @@ -35,9 +35,9 @@ MagicNumber:Twitter.kt$Twitter$1000L MagicNumber:Twitter.kt$Twitter$60L MagicNumber:Users.kt$Users$8 - MagicNumber:Utils.kt$Utils.Companion$30 - MagicNumber:Utils.kt$Utils.Companion$365 - MagicNumber:Utils.kt$Utils.Companion$7 + 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 @@ -75,7 +75,6 @@ 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 ) ReturnCount:Mobibot.kt$Mobibot$override fun onMessage( channel: String, sender: String, login: String, hostname: String, message: String ) - ReturnCount:Utils.kt$Utils.Companion$ @JvmStatic fun colorize(s: String?, color: String): String ThrowsCount:GoogleSearch.kt$GoogleSearch.Companion$ @JvmStatic @Throws(ModuleException::class) fun searchGoogle(query: String, apiKey: String?, cseKey: String?): List<Message> ThrowsCount:StockQuote.kt$StockQuote.Companion$ @JvmStatic @Throws(ModuleException::class) fun getQuote(symbol: String, apiKey: String?): List<Message> ThrowsCount:StockQuote.kt$StockQuote.Companion$@Throws(ModuleException::class) private fun getJsonResponse(response: String, debugMessage: String): JSONObject @@ -87,6 +86,6 @@ TooGenericExceptionCaught:Weather2.kt$Weather2.Companion$e: NullPointerException TooManyFunctions:Mobibot.kt$Mobibot : PircBot TooManyFunctions:Tell.kt$Tell : AbstractCommand - TooManyFunctions:Utils.kt$Utils$Companion + TooManyFunctions:Utils.kt$Utils$Utils diff --git a/src/main/java/net/thauvin/erik/mobibot/Constants.kt b/src/main/java/net/thauvin/erik/mobibot/Constants.kt index 4f3d1ae..575e29a 100644 --- a/src/main/java/net/thauvin/erik/mobibot/Constants.kt +++ b/src/main/java/net/thauvin/erik/mobibot/Constants.kt @@ -34,7 +34,7 @@ package net.thauvin.erik.mobibot import java.util.* /** - * The `Constants` class. + * The `Constants`. */ object Constants { /** @@ -77,6 +77,11 @@ object Constants { */ const val HELP_CMD = "help" + /** + * The kill command. + */ + const val KILL_CMD = "kill" + /** * The link command. */ diff --git a/src/main/java/net/thauvin/erik/mobibot/Mobibot.kt b/src/main/java/net/thauvin/erik/mobibot/Mobibot.kt index bb03e89..e6c1f8b 100644 --- a/src/main/java/net/thauvin/erik/mobibot/Mobibot.kt +++ b/src/main/java/net/thauvin/erik/mobibot/Mobibot.kt @@ -34,16 +34,17 @@ package net.thauvin.erik.mobibot import net.thauvin.erik.mobibot.PinboardUtils.addPin import net.thauvin.erik.mobibot.PinboardUtils.deletePin import net.thauvin.erik.mobibot.PinboardUtils.updatePin -import net.thauvin.erik.mobibot.Utils.Companion.colorize -import net.thauvin.erik.mobibot.Utils.Companion.ensureDir -import net.thauvin.erik.mobibot.Utils.Companion.getIntProperty -import net.thauvin.erik.mobibot.Utils.Companion.helpFormat -import net.thauvin.erik.mobibot.Utils.Companion.helpIndent -import net.thauvin.erik.mobibot.Utils.Companion.isoLocalDate -import net.thauvin.erik.mobibot.Utils.Companion.today +import net.thauvin.erik.mobibot.Utils.colorize +import net.thauvin.erik.mobibot.Utils.ensureDir +import net.thauvin.erik.mobibot.Utils.getIntProperty +import net.thauvin.erik.mobibot.Utils.helpFormat +import net.thauvin.erik.mobibot.Utils.helpIndent +import net.thauvin.erik.mobibot.Utils.isoLocalDate +import net.thauvin.erik.mobibot.Utils.today import net.thauvin.erik.mobibot.commands.AddLog import net.thauvin.erik.mobibot.commands.ChannelFeed import net.thauvin.erik.mobibot.commands.Cycle +import net.thauvin.erik.mobibot.commands.Debug import net.thauvin.erik.mobibot.commands.Ignore import net.thauvin.erik.mobibot.commands.Info import net.thauvin.erik.mobibot.commands.Me @@ -92,7 +93,6 @@ import org.apache.commons.cli.ParseException import org.apache.logging.log4j.Level import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger -import org.apache.logging.log4j.core.config.Configurator import org.jibble.pircbot.PircBot import java.io.BufferedOutputStream import java.io.FileNotFoundException @@ -126,8 +126,8 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert /** Logger. */ val logger: Logger = LogManager.getLogger(Mobibot::class.java) - // Logger default level - private val loggerLevel: Level + /** Logger default level. */ + val loggerLevel: Level /** Log directory. */ val logsDir: String @@ -407,17 +407,10 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert val isOp = isOp(sender) if (cmd.startsWith(Constants.HELP_CMD)) { // help helpResponse(sender, args, true) - } else if (isOp && "kill" == cmd) { // kill + } else if (isOp && Constants.KILL_CMD == cmd) { // kill twitter.notification("$name killed by $sender on $channel") sendRawLine("QUIT : Poof!") exitProcess(0) - } else if (isOp && Constants.DEBUG_CMD == cmd) { // debug - if (logger.isDebugEnabled) { - Configurator.setLevel(logger.name, loggerLevel) - } else { - Configurator.setLevel(logger.name, Level.DEBUG) - } - send(sender, "Debug logging is " + if (logger.isDebugEnabled) "enabled." else "disabled.", true) } else if (isOp && Constants.DIE_CMD == cmd) { // die send("$sender has just signed my death sentence.") timer.cancel() @@ -718,6 +711,7 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert addons.add(AddLog(this), p) addons.add(ChannelFeed(this, channelName), p) addons.add(Cycle(this), p) + addons.add(Debug(this), p) addons.add(Ignore(this), p) addons.add(Info(this), p) addons.add(Me(this), p) diff --git a/src/main/java/net/thauvin/erik/mobibot/PinboardUtils.kt b/src/main/java/net/thauvin/erik/mobibot/PinboardUtils.kt index 1dad880..addf76b 100644 --- a/src/main/java/net/thauvin/erik/mobibot/PinboardUtils.kt +++ b/src/main/java/net/thauvin/erik/mobibot/PinboardUtils.kt @@ -43,7 +43,7 @@ import java.time.format.DateTimeFormatter import java.util.* /** - * The class to handle posts to pinboard.in. + * Handles posts to pinboard.in. */ object PinboardUtils { /** diff --git a/src/main/java/net/thauvin/erik/mobibot/Utils.kt b/src/main/java/net/thauvin/erik/mobibot/Utils.kt index 09f7062..1aa1829 100644 --- a/src/main/java/net/thauvin/erik/mobibot/Utils.kt +++ b/src/main/java/net/thauvin/erik/mobibot/Utils.kt @@ -49,261 +49,240 @@ import java.util.concurrent.TimeUnit import java.util.stream.Collectors /** - * Miscellaneous utilities class. + * Miscellaneous utilities. */ -class Utils private constructor() { - companion object { - private val searchFlags = arrayOf("%c", "%n") +object Utils { + private val searchFlags = arrayOf("%c", "%n") - /** - * Makes the given int bold. - */ - @JvmStatic - fun bold(i: Int): String { - return bold(i.toString()) + /** + * Makes the given int bold. + */ + @JvmStatic + fun bold(i: Int): String = bold(i.toString()) + + /** + * Makes the given string bold. + */ + @JvmStatic + fun bold(s: String?): String = colorize(s, Colors.BOLD) + + /** + * Colorize a string. + */ + @JvmStatic + fun colorize(s: String?, color: String): String { + return if (s.isNullOrBlank()) { + Colors.NORMAL + } else if (Colors.BOLD == color || Colors.REVERSE == color) { + color + s + color + } else { + color + s + Colors.NORMAL } + } - /** - * Makes the given string bold. - */ - @JvmStatic - fun bold(s: String?): String { - return colorize(s, Colors.BOLD) - } + /** + * Makes the given string cyan. + */ + @JvmStatic + fun cyan(s: String?): String = colorize(s, Colors.CYAN) - /** - * Colorize a string. - */ - @JvmStatic - fun colorize(s: String?, color: String): String { - if (s.isNullOrBlank()) { - return Colors.NORMAL - } else if (Colors.BOLD == color || Colors.REVERSE == color) { - return color + s + color - } - return color + s + Colors.NORMAL - } + /** + * URL encodes the given string. + */ + fun encodeUrl(s: String): String = URLEncoder.encode(s, StandardCharsets.UTF_8) - /** - * Makes the given string cyan. - */ - @JvmStatic - fun cyan(s: String?): String { - return colorize(s, Colors.CYAN) - } - - /** - * URL encodes the given string. - */ - fun encodeUrl(s: String): String { - return URLEncoder.encode(s, StandardCharsets.UTF_8) - } - - /** - * Ensures that the given location (File/URL) has a trailing slash (`/`) to indicate a directory. - */ - @JvmStatic - fun ensureDir(location: String, isUrl: Boolean): String { - return if (location.isNotEmpty()) { - if (isUrl) { - if (location[location.length - 1] == '/') { - location - } else { - "$location/" - } + /** + * Ensures that the given location (File/URL) has a trailing slash (`/`) to indicate a directory. + */ + @JvmStatic + fun ensureDir(location: String, isUrl: Boolean): String { + return if (location.isNotEmpty()) { + if (isUrl) { + if (location[location.length - 1] == '/') { + location } else { - if (location[location.length - 1] == File.separatorChar) { - location - } else { - location + File.separatorChar - } + "$location/" } } else { - location + if (location[location.length - 1] == File.separatorChar) { + location + } else { + location + File.separatorChar + } } + } else { + location } + } - /** - * Returns a property as an int. - */ - @JvmStatic - fun getIntProperty(property: String?, def: Int): Int { - return if (property == null) { + /** + * Returns a property as an int. + */ + @JvmStatic + fun getIntProperty(property: String?, def: Int): Int { + return if (property == null) { + def + } else { + try { + property.toInt() + } catch (ignore: NumberFormatException) { def - } else { - try { - property.toInt() - } catch (ignore: NumberFormatException) { - def - } - } - } - - /** - * Makes the given string green. - */ - @JvmStatic - fun green(s: String?): String { - return colorize(s, Colors.DARK_GREEN) - } - - /** - * Formats a help command by replacing `%c` with the bot's pub/priv command, and `%n` with the bot's - * nick. - */ - @JvmStatic - fun helpFormat(text: String, botNick: String, isPrivate: Boolean): String { - val replace = arrayOf(if (isPrivate) "/msg $botNick" else "$botNick:", botNick) - return StringUtils.replaceEach(text, searchFlags, replace) - } - - /** - * Returns indented help string. - */ - @JvmStatic - @JvmOverloads - fun helpIndent(help: String, isBold: Boolean = true): String { - return " " + if (isBold) bold(help) else help - } - - /** - * Returns the specified date as an ISO local date string. - */ - @JvmStatic - fun isoLocalDate(date: Date): String { - return isoLocalDate(LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault())) - } - - /** - * Returns the specified date as an ISO local date string. - */ - @JvmStatic - fun isoLocalDate(date: LocalDateTime): String { - return date.format(DateTimeFormatter.ISO_LOCAL_DATE) - } - - /** - * Obfuscates the given string. - */ - @JvmStatic - fun obfuscate(s: String): String { - return if (s.isNotBlank()) { - StringUtils.repeat('x', s.length) - } else s - } - - /** - * Returns the plural form of a word, if count > 1. - */ - @JvmStatic - fun plural(count: Long, word: String, plural: String): String { - return if (count > 1) { - plural - } else { - word - } - } - - /** - * Makes the given string red. - */ - @JvmStatic - fun red(s: String?): String { - return colorize(s, Colors.RED) - } - - /** - * Makes the given string reverse color. - */ - @JvmStatic - fun reverseColor(s: String?): String { - return colorize(s, Colors.REVERSE) - } - - /** - * Returns today's date. - */ - @JvmStatic - fun today(): String { - return isoLocalDate(LocalDateTime.now()) - } - - /** - * Converts XML/XHTML entities to plain text. - */ - @JvmStatic - fun unescapeXml(str: String): String { - return Jsoup.parse(str).text() - } - - /** - * Converts milliseconds to year month week day hour and minutes. - */ - @JvmStatic - fun uptime(uptime: Long): String { - val info = StringBuilder() - var days = TimeUnit.MILLISECONDS.toDays(uptime) - val years = days / 365 - days %= 365 - val months = days / 30 - days %= 30 - val weeks = days / 7 - days %= 7 - val hours = TimeUnit.MILLISECONDS.toHours(uptime) - TimeUnit.DAYS.toHours( - TimeUnit.MILLISECONDS.toDays(uptime) - ) - val minutes = TimeUnit.MILLISECONDS.toMinutes(uptime) - TimeUnit.HOURS.toMinutes( - TimeUnit.MILLISECONDS.toHours(uptime) - ) - with(info) { - if (years > 0) { - append(years).append(plural(years, " year ", " years ")) - } - if (months > 0) { - append(weeks).append(plural(months, " month ", " months ")) - } - if (weeks > 0) { - append(weeks).append(plural(weeks, " week ", " weeks ")) - } - if (days > 0) { - append(days).append(plural(days, " day ", " days ")) - } - if (hours > 0) { - append(hours).append(plural(hours, " hour ", " hours ")) - } - append(minutes).append(plural(minutes, " minute", " minutes")) - return toString() - } - } - - /** - * Reads contents of a URL. - */ - @JvmStatic - @Throws(IOException::class) - fun urlReader(url: URL): String { - BufferedReader(InputStreamReader(url.openStream(), StandardCharsets.UTF_8)) - .use { reader -> return reader.lines().collect(Collectors.joining(System.lineSeparator())) } - } - - /** - * Returns the specified date formatted as `yyyy-MM-dd HH:mm`. - */ - @JvmStatic - fun utcDateTime(date: Date): String { - return utcDateTime(LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault())) - } - - /** - * Returns the specified date formatted as `yyyy-MM-dd HH:mm`. - */ - @JvmStatic - fun utcDateTime(date: LocalDateTime?): String { - return if (date != null) { - date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")) - } else { - "" } } } + + /** + * Makes the given string green. + */ + @JvmStatic + fun green(s: String?): String = colorize(s, Colors.DARK_GREEN) + + /** + * Formats a help command by replacing `%c` with the bot's pub/priv command, and `%n` with the bot's + * nick. + */ + @JvmStatic + fun helpFormat(text: String, botNick: String, isPrivate: Boolean): String { + val replace = arrayOf(if (isPrivate) "/msg $botNick" else "$botNick:", botNick) + return StringUtils.replaceEach(text, searchFlags, replace) + } + + /** + * Returns indented help string. + */ + @JvmStatic + @JvmOverloads + fun helpIndent(help: String, isBold: Boolean = true): String { + return " " + if (isBold) bold(help) else help + } + + /** + * Returns the specified date as an ISO local date string. + */ + @JvmStatic + fun isoLocalDate(date: Date): String { + return isoLocalDate(LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault())) + } + + /** + * Returns the specified date as an ISO local date string. + */ + @JvmStatic + fun isoLocalDate(date: LocalDateTime): String = date.format(DateTimeFormatter.ISO_LOCAL_DATE) + + /** + * Obfuscates the given string. + */ + @JvmStatic + fun obfuscate(s: String): String { + return if (s.isNotBlank()) { + StringUtils.repeat('x', s.length) + } else s + } + + /** + * Returns the plural form of a word, if count > 1. + */ + @JvmStatic + fun plural(count: Long, word: String, plural: String): String { + return if (count > 1) { + plural + } else { + word + } + } + + /** + * Makes the given string red. + */ + @JvmStatic + fun red(s: String?): String = colorize(s, Colors.RED) + + /** + * Makes the given string reverse color. + */ + @JvmStatic + fun reverseColor(s: String?): String = colorize(s, Colors.REVERSE) + + /** + * Returns today's date. + */ + @JvmStatic + fun today(): String = isoLocalDate(LocalDateTime.now()) + + /** + * Converts XML/XHTML entities to plain text. + */ + @JvmStatic + fun unescapeXml(str: String): String = Jsoup.parse(str).text() + + /** + * Converts milliseconds to year month week day hour and minutes. + */ + @JvmStatic + fun uptime(uptime: Long): String { + val info = StringBuilder() + var days = TimeUnit.MILLISECONDS.toDays(uptime) + val years = days / 365 + days %= 365 + val months = days / 30 + days %= 30 + val weeks = days / 7 + days %= 7 + val hours = TimeUnit.MILLISECONDS.toHours(uptime) - TimeUnit.DAYS.toHours( + TimeUnit.MILLISECONDS.toDays(uptime) + ) + val minutes = TimeUnit.MILLISECONDS.toMinutes(uptime) - TimeUnit.HOURS.toMinutes( + TimeUnit.MILLISECONDS.toHours(uptime) + ) + with(info) { + if (years > 0) { + append(years).append(plural(years, " year ", " years ")) + } + if (months > 0) { + append(weeks).append(plural(months, " month ", " months ")) + } + if (weeks > 0) { + append(weeks).append(plural(weeks, " week ", " weeks ")) + } + if (days > 0) { + append(days).append(plural(days, " day ", " days ")) + } + if (hours > 0) { + append(hours).append(plural(hours, " hour ", " hours ")) + } + append(minutes).append(plural(minutes, " minute", " minutes")) + return toString() + } + } + + /** + * Reads contents of a URL. + */ + @JvmStatic + @Throws(IOException::class) + fun urlReader(url: URL): String { + BufferedReader(InputStreamReader(url.openStream(), StandardCharsets.UTF_8)) + .use { reader -> return reader.lines().collect(Collectors.joining(System.lineSeparator())) } + } + + /** + * Returns the specified date formatted as `yyyy-MM-dd HH:mm`. + */ + @JvmStatic + fun utcDateTime(date: Date): String { + return utcDateTime(LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault())) + } + + /** + * Returns the specified date formatted as `yyyy-MM-dd HH:mm`. + */ + @JvmStatic + fun utcDateTime(date: LocalDateTime?): String { + return if (date != null) { + date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")) + } else { + "" + } + } } diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Debug.kt b/src/main/java/net/thauvin/erik/mobibot/commands/Debug.kt new file mode 100644 index 0000000..9bf3630 --- /dev/null +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Debug.kt @@ -0,0 +1,58 @@ +/* + * Debug.kt + * + * Copyright (c) 2004-2020, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of this project nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.thauvin.erik.mobibot.commands + +import net.thauvin.erik.mobibot.Mobibot +import org.apache.logging.log4j.Level +import org.apache.logging.log4j.core.config.Configurator + +class Debug(bot: Mobibot) : AbstractCommand(bot) { + override val name = "debug" + override val help = emptyList() + override val isOp = true + override val isPublic = false + override val isVisible = false + + override fun commandResponse(sender: String, login: String, args: String, isOp: Boolean, isPrivate: Boolean) { + if (isOp) { + with(bot) { + if (logger.isDebugEnabled) { + Configurator.setLevel(logger.name, loggerLevel) + } else { + Configurator.setLevel(logger.name, Level.DEBUG) + } + send(sender, "Debug logging is " + if (logger.isDebugEnabled) "enabled." else "disabled.", true) + } + } + } +} diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/tell/Tell.kt b/src/main/java/net/thauvin/erik/mobibot/commands/tell/Tell.kt index f79bb4c..be54085 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/tell/Tell.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/tell/Tell.kt @@ -32,13 +32,13 @@ package net.thauvin.erik.mobibot.commands.tell import net.thauvin.erik.mobibot.Mobibot -import net.thauvin.erik.mobibot.Utils.Companion.bold -import net.thauvin.erik.mobibot.Utils.Companion.getIntProperty -import net.thauvin.erik.mobibot.Utils.Companion.helpFormat -import net.thauvin.erik.mobibot.Utils.Companion.helpIndent -import net.thauvin.erik.mobibot.Utils.Companion.plural -import net.thauvin.erik.mobibot.Utils.Companion.reverseColor -import net.thauvin.erik.mobibot.Utils.Companion.utcDateTime +import net.thauvin.erik.mobibot.Utils.bold +import net.thauvin.erik.mobibot.Utils.getIntProperty +import net.thauvin.erik.mobibot.Utils.helpFormat +import net.thauvin.erik.mobibot.Utils.helpIndent +import net.thauvin.erik.mobibot.Utils.plural +import net.thauvin.erik.mobibot.Utils.reverseColor +import net.thauvin.erik.mobibot.Utils.utcDateTime import net.thauvin.erik.mobibot.commands.AbstractCommand import net.thauvin.erik.mobibot.commands.links.View diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/tell/TellMessagesMgr.kt b/src/main/java/net/thauvin/erik/mobibot/commands/tell/TellMessagesMgr.kt index f3907ec..7a7e927 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/tell/TellMessagesMgr.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/tell/TellMessagesMgr.kt @@ -42,7 +42,6 @@ import java.nio.file.Files import java.nio.file.Paths import java.time.Clock import java.time.LocalDateTime -import java.util.* /** * The Tell Messages Manager. diff --git a/src/main/java/net/thauvin/erik/mobibot/entries/EntriesMgr.kt b/src/main/java/net/thauvin/erik/mobibot/entries/EntriesMgr.kt index 54ba3e6..57702c9 100644 --- a/src/main/java/net/thauvin/erik/mobibot/entries/EntriesMgr.kt +++ b/src/main/java/net/thauvin/erik/mobibot/entries/EntriesMgr.kt @@ -40,7 +40,7 @@ import com.rometools.rome.io.FeedException import com.rometools.rome.io.SyndFeedInput import com.rometools.rome.io.SyndFeedOutput import net.thauvin.erik.mobibot.Mobibot -import net.thauvin.erik.mobibot.Utils.Companion.isoLocalDate +import net.thauvin.erik.mobibot.Utils.isoLocalDate import java.io.IOException import java.io.InputStreamReader import java.io.OutputStreamWriter diff --git a/src/main/java/net/thauvin/erik/mobibot/entries/EntriesUtils.kt b/src/main/java/net/thauvin/erik/mobibot/entries/EntriesUtils.kt index a96bad0..d9ca531 100644 --- a/src/main/java/net/thauvin/erik/mobibot/entries/EntriesUtils.kt +++ b/src/main/java/net/thauvin/erik/mobibot/entries/EntriesUtils.kt @@ -32,52 +32,49 @@ package net.thauvin.erik.mobibot.entries import net.thauvin.erik.mobibot.Constants -import net.thauvin.erik.mobibot.Utils.Companion.bold -import net.thauvin.erik.mobibot.Utils.Companion.green +import net.thauvin.erik.mobibot.Utils.bold +import net.thauvin.erik.mobibot.Utils.green /** - * The `Utils` class. + * Entries utilities. */ -class EntriesUtils private constructor() { - companion object { - /** - * Build link cmd based on its index. e.g: L1 - */ - fun buildLinkCmd(index: Int): String = Constants.LINK_CMD + (index + 1) +object EntriesUtils { + /** + * Build link cmd based on its index. e.g: L1 + */ + fun buildLinkCmd(index: Int): String = Constants.LINK_CMD + (index + 1) - /** - * Builds an entry's comment for display on the channel. - */ - fun buildComment(entryIndex: Int, commentIndex: Int, comment: EntryComment): String = - (buildLinkCmd(entryIndex) + '.' + (commentIndex + 1) + ": [" + comment.nick + "] " - + comment.comment) + /** + * Builds an entry's comment for display on the channel. + */ + fun buildComment(entryIndex: Int, commentIndex: Int, comment: EntryComment): String = + ("${buildLinkCmd(entryIndex)}.${commentIndex + 1}: [${comment.nick}] ${comment.comment}") - /** - * Builds an entry's link for display on the channel. - */ - @JvmOverloads - fun buildLink(entryIndex: Int, entry: EntryLink, isView: Boolean = false): String { - val buff = StringBuilder().append(buildLinkCmd(entryIndex)).append(": ") - .append('[').append(entry.nick).append(']') - if (isView && entry.hasComments()) { - buff.append("[+").append(entry.comments.size).append(']') - } - buff.append(' ') - with(entry) { - if (Constants.NO_TITLE == title) { - buff.append(title) - } else { - buff.append(bold(title)) - } - buff.append(" ( ").append(green(link)).append(" )") - } - return buff.toString() + /** + * Builds an entry's link for display on the channel. + */ + @JvmOverloads + fun buildLink(entryIndex: Int, entry: EntryLink, isView: Boolean = false): String { + val buff = StringBuilder().append(buildLinkCmd(entryIndex)).append(": ") + .append('[').append(entry.nick).append(']') + if (isView && entry.hasComments()) { + buff.append("[+").append(entry.comments.size).append(']') } - - /** - * Build an entry's tags/categories for display on the channel. - */ - fun buildTags(entryIndex: Int, entry: EntryLink): String = - buildLinkCmd(entryIndex) + "T: " + entry.pinboardTags.replace(",", ", ") + buff.append(' ') + with(entry) { + if (Constants.NO_TITLE == title) { + buff.append(title) + } else { + buff.append(bold(title)) + } + buff.append(" ( ").append(green(link)).append(" )") + } + return buff.toString() } + + /** + * Build an entry's tags/categories for display on the channel. + */ + fun buildTags(entryIndex: Int, entry: EntryLink): String = + buildLinkCmd(entryIndex) + "T: " + entry.pinboardTags.replace(",", ", ") } diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.kt b/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.kt index 9038a7a..d02e5d6 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.kt +++ b/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.kt @@ -72,7 +72,7 @@ class CurrencyConverter(bot: Mobibot) : ThreadedModule(bot) { try { loadRates() } catch (e: ModuleException) { - if (bot.logger.isWarnEnabled)logger.warn(e.debugMessage, e) + if (bot.logger.isWarnEnabled) logger.warn(e.debugMessage, e) } } diff --git a/src/main/java/net/thauvin/erik/mobibot/msg/Message.kt b/src/main/java/net/thauvin/erik/mobibot/msg/Message.kt index a6f66f7..9987bd8 100644 --- a/src/main/java/net/thauvin/erik/mobibot/msg/Message.kt +++ b/src/main/java/net/thauvin/erik/mobibot/msg/Message.kt @@ -1,5 +1,5 @@ /* - * Message.java + * Message.kt * * Copyright (c) 2004-2020, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. @@ -41,19 +41,19 @@ open class Message { var DEFAULT_COLOR = Colors.NORMAL } - /** Color */ + /** Message color. */ var color = DEFAULT_COLOR - /** Error */ + /** Error flag. */ var isError = false - /** Notice */ + /** Notice flag. */ var isNotice = false - /** Private */ + /** Private flag. */ var isPrivate = false - /** Message text*/ + /** Message text. */ var msg = "" /** Creates a new message. */ diff --git a/src/test/java/net/thauvin/erik/mobibot/UtilsTest.java b/src/test/java/net/thauvin/erik/mobibot/UtilsTest.java deleted file mode 100644 index bde9d77..0000000 --- a/src/test/java/net/thauvin/erik/mobibot/UtilsTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * UtilsTest.java - * - * Copyright (c) 2004-2019, Erik C. Thauvin (erik@thauvin.net) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of this project nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package net.thauvin.erik.mobibot; - -import org.apache.commons.lang3.StringUtils; -import org.jibble.pircbot.Colors; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.time.LocalDateTime; -import java.util.Calendar; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * The Utils Test class. - * - * @author Erik C. Thauvin - * @created 2017-05-30 - * @since 1.0 - */ -public class UtilsTest { - private static final String ASCII = - " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; - - private final Calendar cal = Calendar.getInstance(); - private final LocalDateTime localDateTime = LocalDateTime.of(1952, 2, 17, 12, 30, 0); - - @BeforeClass - public void setUp() { - cal.set(1952, Calendar.FEBRUARY, 17, 12, 30, 0); - } - - @Test - public void testBold() { - assertThat(Utils.bold(Integer.toString(1))).as("bold(1)").isEqualTo(Colors.BOLD + "1" + Colors.BOLD); - assertThat(Utils.bold(ASCII)).as("bold(ascii").isEqualTo(Colors.BOLD + ASCII + Colors.BOLD); - } - - @Test - public void testColorize() { - assertThat(Utils.colorize(ASCII, Colors.REVERSE)).as("colorize(reverse)").isEqualTo( - Colors.REVERSE + ASCII + Colors.REVERSE); - assertThat(Utils.colorize(ASCII, Colors.RED)).as("colorize(red)").isEqualTo(Colors.RED + ASCII + Colors.NORMAL); - assertThat(Utils.colorize(null, Colors.RED)).as("colorize(null)").isEqualTo(Colors.NORMAL); - } - - @Test - public void testCyan() { - assertThat(Utils.cyan(ASCII)).isEqualTo(Colors.CYAN + ASCII + Colors.NORMAL); - } - - @Test - public void testEnsureDir() { - assertThat(Utils.ensureDir("dir", false)).as("ensureDir(dir, false)").isEqualTo("dir" + File.separatorChar); - assertThat(Utils.ensureDir("https://erik.thauvin.net", true)).as("ensureDir(erik.thauvin.net, true)").isEqualTo( - "https://erik.thauvin.net/"); - } - - @Test - public void testGetIntProperty() { - assertThat(Utils.getIntProperty("10", 1)).as("getIntProperty(10, 1)").isEqualTo(10); - assertThat(Utils.getIntProperty("a", 1)).as("getIntProperty(a, 1)").isEqualTo(1); - } - - @Test - public void testGreen() { - assertThat(Utils.green(ASCII)).isEqualTo(Colors.DARK_GREEN + ASCII + Colors.NORMAL); - } - - @Test - public void testIsoLocalDate() { - assertThat(Utils.isoLocalDate(cal.getTime())).as("isoLocalDate(date)").isEqualTo("1952-02-17"); - assertThat(Utils.isoLocalDate(localDateTime)).as("isoLocalDate(localDate)").isEqualTo("1952-02-17"); - } - - @Test - public void testObfuscate() { - assertThat(Utils.obfuscate(ASCII).length()).as("obfuscate is right length").isEqualTo(ASCII.length()); - assertThat(Utils.obfuscate(ASCII)).as("obfuscate()").isEqualTo(StringUtils.repeat("x", ASCII.length())); - assertThat(Utils.obfuscate(" ")).as("obfuscate(blank)").isEqualTo(" "); - } - - @Test - public void testPlural() { - final String week = "week"; - final String weeks = "weeks"; - - assertThat(Utils.plural(-1, week, weeks)).as("plural(-1)").isEqualTo(week); - assertThat(Utils.plural(0, week, weeks)).as("plural(0)").isEqualTo(week); - assertThat(Utils.plural(1, week, weeks)).as("plural(1)").isEqualTo(week); - assertThat(Utils.plural(2, week, weeks)).as("plural(2)").isEqualTo(weeks); - } - - @Test - public void testReverseColor() { - assertThat(Utils.reverseColor(ASCII)).isEqualTo(Colors.REVERSE + ASCII + Colors.REVERSE); - } - - @Test - public void testToday() { - assertThat(Utils.today()).isEqualTo(Utils.isoLocalDate(LocalDateTime.now())); - } - - @Test - public void testUnescapeXml() { - assertThat(Utils.unescapeXml("<a name="test & ''">")).isEqualTo( - ""); - } - - @Test - public void testUptime() { - assertThat("17 years 2 months 2 weeks 1 day 6 hours 45 minutes").isEqualTo(Utils.uptime(547800300076L)); - } - - @Test - public void testUrlReader() throws IOException { - assertThat(Utils.urlReader(new URL("https://postman-echo.com/status/200"))).as("urlReader()").isEqualTo( - "{\"status\":200}"); - } - - @Test - public void testUtcDateTime() { - assertThat(Utils.utcDateTime(cal.getTime())).as("utcDateTime(date)").isEqualTo("1952-02-17 12:30"); - assertThat(Utils.utcDateTime(localDateTime)).as("utcDateTime(localDate)").isEqualTo("1952-02-17 12:30"); - } -} diff --git a/src/test/java/net/thauvin/erik/mobibot/UtilsTest.kt b/src/test/java/net/thauvin/erik/mobibot/UtilsTest.kt new file mode 100644 index 0000000..6e2c269 --- /dev/null +++ b/src/test/java/net/thauvin/erik/mobibot/UtilsTest.kt @@ -0,0 +1,172 @@ +/* + * UtilsTest.java + * + * Copyright (c) 2004-2019, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of this project nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.thauvin.erik.mobibot + +import net.thauvin.erik.mobibot.Utils.bold +import net.thauvin.erik.mobibot.Utils.colorize +import net.thauvin.erik.mobibot.Utils.cyan +import net.thauvin.erik.mobibot.Utils.ensureDir +import net.thauvin.erik.mobibot.Utils.getIntProperty +import net.thauvin.erik.mobibot.Utils.green +import net.thauvin.erik.mobibot.Utils.isoLocalDate +import net.thauvin.erik.mobibot.Utils.obfuscate +import net.thauvin.erik.mobibot.Utils.plural +import net.thauvin.erik.mobibot.Utils.reverseColor +import net.thauvin.erik.mobibot.Utils.today +import net.thauvin.erik.mobibot.Utils.unescapeXml +import net.thauvin.erik.mobibot.Utils.uptime +import net.thauvin.erik.mobibot.Utils.urlReader +import net.thauvin.erik.mobibot.Utils.utcDateTime +import org.apache.commons.lang3.StringUtils +import org.assertj.core.api.Assertions +import org.jibble.pircbot.Colors +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test +import java.io.File +import java.io.IOException +import java.net.URL +import java.time.LocalDateTime +import java.util.* + +/** + * The `Utils Test` class. + */ +class UtilsTest { + private val ascii = + " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" + private val cal = Calendar.getInstance() + private val localDateTime = LocalDateTime.of(1952, 2, 17, 12, 30, 0) + + @BeforeClass + fun setUp() { + cal[1952, Calendar.FEBRUARY, 17, 12, 30] = 0 + } + + @Test + fun testBold() { + Assertions.assertThat(bold(1.toString())).`as`("bold(1)").isEqualTo(Colors.BOLD + "1" + Colors.BOLD) + Assertions.assertThat(bold(ascii)).`as`("bold(ascii").isEqualTo(Colors.BOLD + ascii + Colors.BOLD) + } + + @Test + fun testColorize() { + Assertions.assertThat(colorize(ascii, Colors.REVERSE)).`as`("colorize(reverse)").isEqualTo( + Colors.REVERSE + ascii + Colors.REVERSE + ) + Assertions.assertThat(colorize(ascii, Colors.RED)).`as`("colorize(red)") + .isEqualTo(Colors.RED + ascii + Colors.NORMAL) + Assertions.assertThat(colorize(null, Colors.RED)).`as`("colorize(null)").isEqualTo(Colors.NORMAL) + } + + @Test + fun testCyan() { + Assertions.assertThat(cyan(ascii)).isEqualTo(Colors.CYAN + ascii + Colors.NORMAL) + } + + @Test + fun testEnsureDir() { + Assertions.assertThat(ensureDir("dir", false)).`as`("ensureDir(dir, false)") + .isEqualTo("dir" + File.separatorChar) + Assertions.assertThat(ensureDir("https://erik.thauvin.net", true)).`as`("ensureDir(erik.thauvin.net, true)") + .isEqualTo("https://erik.thauvin.net/") + } + + @Test + fun testGetIntProperty() { + Assertions.assertThat(getIntProperty("10", 1)).`as`("getIntProperty(10, 1)").isEqualTo(10) + Assertions.assertThat(getIntProperty("a", 1)).`as`("getIntProperty(a, 1)").isEqualTo(1) + } + + @Test + fun testGreen() { + Assertions.assertThat(green(ascii)).isEqualTo(Colors.DARK_GREEN + ascii + Colors.NORMAL) + } + + @Test + fun testIsoLocalDate() { + Assertions.assertThat(isoLocalDate(cal.time)).`as`("isoLocalDate(date)").isEqualTo("1952-02-17") + Assertions.assertThat(isoLocalDate(localDateTime)).`as`("isoLocalDate(localDate)").isEqualTo("1952-02-17") + } + + @Test + fun testObfuscate() { + Assertions.assertThat(obfuscate(ascii).length).`as`("obfuscate is right length").isEqualTo(ascii.length) + Assertions.assertThat(obfuscate(ascii)).`as`("obfuscate()").isEqualTo(StringUtils.repeat("x", ascii.length)) + Assertions.assertThat(obfuscate(" ")).`as`("obfuscate(blank)").isEqualTo(" ") + } + + @Test + fun testPlural() { + val week = "week" + val weeks = "weeks" + Assertions.assertThat(plural(-1, week, weeks)).`as`("plural(-1)").isEqualTo(week) + Assertions.assertThat(plural(0, week, weeks)).`as`("plural(0)").isEqualTo(week) + Assertions.assertThat(plural(1, week, weeks)).`as`("plural(1)").isEqualTo(week) + Assertions.assertThat(plural(2, week, weeks)).`as`("plural(2)").isEqualTo(weeks) + } + + @Test + fun testReverseColor() { + Assertions.assertThat(reverseColor(ascii)).isEqualTo(Colors.REVERSE + ascii + Colors.REVERSE) + } + + @Test + fun testToday() { + Assertions.assertThat(today()).isEqualTo(isoLocalDate(LocalDateTime.now())) + } + + @Test + fun testUnescapeXml() { + Assertions.assertThat(unescapeXml("<a name="test & ''">")).isEqualTo( + "" + ) + } + + @Test + fun testUptime() { + Assertions.assertThat("17 years 2 months 2 weeks 1 day 6 hours 45 minutes").isEqualTo(uptime(547800300076L)) + } + + @Test + @Throws(IOException::class) + fun testUrlReader() { + Assertions.assertThat(urlReader(URL("https://postman-echo.com/status/200"))).`as`("urlReader()").isEqualTo( + "{\"status\":200}" + ) + } + + @Test + fun testUtcDateTime() { + Assertions.assertThat(utcDateTime(cal.time)).`as`("utcDateTime(date)").isEqualTo("1952-02-17 12:30") + Assertions.assertThat(utcDateTime(localDateTime)).`as`("utcDateTime(localDate)").isEqualTo("1952-02-17 12:30") + } +} diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/LookupTest.kt b/src/test/java/net/thauvin/erik/mobibot/modules/LookupTest.kt index aad40e5..ed57c8e 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/LookupTest.kt +++ b/src/test/java/net/thauvin/erik/mobibot/modules/LookupTest.kt @@ -35,7 +35,6 @@ import net.thauvin.erik.mobibot.modules.Lookup.Companion.lookup import net.thauvin.erik.mobibot.modules.Lookup.Companion.whois import org.assertj.core.api.Assertions import org.testng.annotations.Test -import java.util.* /** * The `Lookup Test` class.