This commit is contained in:
Erik C. Thauvin 2021-05-13 21:37:16 -07:00
parent 11a75a7179
commit 790bd3159e
23 changed files with 67 additions and 69 deletions

View file

@ -14,6 +14,9 @@
<option name="JD_INDENT_ON_CONTINUATION" value="true" /> <option name="JD_INDENT_ON_CONTINUATION" value="true" />
</JavaCodeStyleSettings> </JavaCodeStyleSettings>
<JetCodeStyleSettings> <JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value />
</option>
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" /> <option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" /> <option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" /> <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />

View file

@ -1,6 +1,5 @@
<component name="ProjectCodeStyleConfiguration"> <component name="ProjectCodeStyleConfiguration">
<state> <state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" /> <option name="USE_PER_PROJECT_SETTINGS" value="true" />
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Erik's Code Style" />
</state> </state>
</component> </component>

View file

@ -116,12 +116,6 @@ detekt {
baseline = file("${projectDir}/config/detekt/baseline.xml") 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 { jar {
manifest.attributes('Main-Class': mainClassName, manifest.attributes('Main-Class': mainClassName,
'Class-Path': '. ./lib/' + configurations.runtimeClasspath.collect { it.getName() }.join(' ./lib/')) 'Class-Path': '. ./lib/' + configurations.runtimeClasspath.collect { it.getName() }.join(' ./lib/'))

View file

@ -34,6 +34,7 @@
<ID>NestedBlockDepth:Tell.kt$Tell$ @JvmOverloads fun send(nickname: String, isMessage: Boolean = false)</ID> <ID>NestedBlockDepth:Tell.kt$Tell$ @JvmOverloads fun send(nickname: String, isMessage: Boolean = false)</ID>
<ID>NestedBlockDepth:Tell.kt$Tell$// Delete message. private fun deleteMessage(sender: String, args: String, isOp: Boolean, isPrivate: Boolean)</ID> <ID>NestedBlockDepth:Tell.kt$Tell$// Delete message. private fun deleteMessage(sender: String, args: String, isOp: Boolean, isPrivate: Boolean)</ID>
<ID>NestedBlockDepth:TellMessagesMgr.kt$TellMessagesMgr$ fun save(file: String, messages: List&lt;TellMessage?&gt;?, logger: Logger)</ID> <ID>NestedBlockDepth:TellMessagesMgr.kt$TellMessagesMgr$ fun save(file: String, messages: List&lt;TellMessage?&gt;?, logger: Logger)</ID>
<ID>NestedBlockDepth:TwitterOAuth.kt$TwitterOAuth$ @Throws(TwitterException::class, IOException::class) @JvmStatic fun main(args: Array&lt;String&gt;)</ID>
<ID>NestedBlockDepth:Weather2.kt$Weather2$ override fun run(sender: String, cmd: String, args: String, isPrivate: Boolean)</ID> <ID>NestedBlockDepth:Weather2.kt$Weather2$ override fun run(sender: String, cmd: String, args: String, isPrivate: Boolean)</ID>
<ID>NestedBlockDepth:Weather2.kt$Weather2.Companion$ @JvmStatic @Throws(ModuleException::class) fun getWeather(query: String, apiKey: String?): List&lt;Message&gt;</ID> <ID>NestedBlockDepth:Weather2.kt$Weather2.Companion$ @JvmStatic @Throws(ModuleException::class) fun getWeather(query: String, apiKey: String?): List&lt;Message&gt;</ID>
<ID>NestedBlockDepth:WorldTime.kt$WorldTime$override fun commandResponse( sender: String, cmd: String, args: String, isPrivate: Boolean )</ID> <ID>NestedBlockDepth:WorldTime.kt$WorldTime$override fun commandResponse( sender: String, cmd: String, args: String, isPrivate: Boolean )</ID>

View file

@ -27,7 +27,7 @@ tell-max-size=50
#pinboard-api-token=user\:TOKEN #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 <consumerKey> <consumerSecret> # and then: java -cp mobibot.jar net.thauvin.erik.mobibot.TwitterOAuth <consumerKey> <consumerSecret>
# #
#twitter-consumerKey= #twitter-consumerKey=

View file

@ -48,6 +48,8 @@ import static net.thauvin.erik.mobibot.Utils.bold;
* @since 1.0 * @since 1.0
*/ */
public final class War extends AbstractModule { public final class War extends AbstractModule {
// Random
private static final SecureRandom RANDOM = new SecureRandom();
// War command // War command
private static final String WAR_CMD = "war"; private static final String WAR_CMD = "war";
// Deck of card // 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" }; new String[]{ "Ace", "King", "Queen", "Jack", "10", "9", "8", "7", "6", "5", "4", "3", "2" };
// Suits for the deck of card // Suits for the deck of card
private static final String[] WAR_SUITS = new String[]{ "Hearts", "Spades", "Diamonds", "Clubs" }; private static final String[] WAR_SUITS = new String[]{ "Hearts", "Spades", "Diamonds", "Clubs" };
// Random
private static final SecureRandom RANDOM = new SecureRandom();
/** /**
* The default constructor. * The default constructor.

View file

@ -33,7 +33,7 @@ package net.thauvin.erik.mobibot
import net.thauvin.erik.mobibot.commands.AbstractCommand import net.thauvin.erik.mobibot.commands.AbstractCommand
import net.thauvin.erik.mobibot.modules.AbstractModule import net.thauvin.erik.mobibot.modules.AbstractModule
import java.util.* import java.util.Properties
/** /**
* Modules and Commands addons. * Modules and Commands addons.

View file

@ -31,7 +31,7 @@
*/ */
package net.thauvin.erik.mobibot package net.thauvin.erik.mobibot
import java.util.* import java.util.Locale
/** /**
* The `Constants`. * The `Constants`.

View file

@ -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.commands.tell.Tell
import net.thauvin.erik.mobibot.entries.EntriesMgr import net.thauvin.erik.mobibot.entries.EntriesMgr
import net.thauvin.erik.mobibot.entries.EntryLink 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.Calc
import net.thauvin.erik.mobibot.modules.CryptoPrices
import net.thauvin.erik.mobibot.modules.CurrencyConverter import net.thauvin.erik.mobibot.modules.CurrencyConverter
import net.thauvin.erik.mobibot.modules.Dice import net.thauvin.erik.mobibot.modules.Dice
import net.thauvin.erik.mobibot.modules.GoogleSearch import net.thauvin.erik.mobibot.modules.GoogleSearch
@ -99,7 +99,8 @@ import java.io.IOException
import java.io.PrintStream import java.io.PrintStream
import java.nio.file.Files import java.nio.file.Files
import java.nio.file.Paths import java.nio.file.Paths
import java.util.* import java.util.Properties
import java.util.Timer
import java.util.logging.ConsoleHandler import java.util.logging.ConsoleHandler
import java.util.regex.Pattern import java.util.regex.Pattern
import kotlin.system.exitProcess import kotlin.system.exitProcess
@ -492,8 +493,7 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert
* Returns the bot's version. * Returns the bot's version.
*/ */
override fun onVersion(sourceNick: String, sourceLogin: String, sourceHostname: String, target: String) { override fun onVersion(sourceNick: String, sourceLogin: String, sourceHostname: String, target: String) {
sendRawLine("NOTICE " + sourceNick + " :\u0001VERSION " + ReleaseInfo.PROJECT + ' ' + ReleaseInfo.VERSION sendRawLine("NOTICE $sourceNick :\u0001VERSION ${ReleaseInfo.PROJECT} ${ReleaseInfo.VERSION}\u0001")
+ "\u0001")
} }
companion object { companion object {

View file

@ -32,7 +32,6 @@
package net.thauvin.erik.mobibot package net.thauvin.erik.mobibot
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import net.thauvin.erik.mobibot.entries.EntryLink import net.thauvin.erik.mobibot.entries.EntryLink
@ -40,7 +39,7 @@ import net.thauvin.erik.pinboard.PinboardPoster
import java.time.ZoneId import java.time.ZoneId
import java.time.ZonedDateTime import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter import java.time.format.DateTimeFormatter
import java.util.* import java.util.Date
/** /**
* Handles posts to pinboard.in. * Handles posts to pinboard.in.

View file

@ -32,7 +32,7 @@
package net.thauvin.erik.mobibot package net.thauvin.erik.mobibot
import java.util.* import java.util.TimerTask
class TwitterTimer(var bot: Mobibot, private var index: Int) : TimerTask() { class TwitterTimer(var bot: Mobibot, private var index: Int) : TimerTask() {
override fun run() { override fun run() {

View file

@ -44,7 +44,7 @@ import java.nio.charset.StandardCharsets
import java.time.LocalDateTime import java.time.LocalDateTime
import java.time.ZoneId import java.time.ZoneId
import java.time.format.DateTimeFormatter import java.time.format.DateTimeFormatter
import java.util.* import java.util.Date
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import java.util.stream.Collectors import java.util.stream.Collectors

View file

@ -327,7 +327,7 @@ class Tell(bot: Mobibot) : AbstractCommand(bot) {
const val MAX_DAYS_PROP = "tell-max-days" const val MAX_DAYS_PROP = "tell-max-days"
/** /**
* Max size proeprty. * Max size property.
*/ */
const val MAX_SIZE_PROP = "tell-max-size" const val MAX_SIZE_PROP = "tell-max-size"

View file

@ -47,7 +47,7 @@ import java.io.OutputStreamWriter
import java.nio.charset.StandardCharsets import java.nio.charset.StandardCharsets
import java.nio.file.Files import java.nio.file.Files
import java.nio.file.Paths import java.nio.file.Paths
import java.util.* import java.util.Calendar
/** /**
* Manages the feed entries. * Manages the feed entries.

View file

@ -36,7 +36,8 @@ import com.rometools.rome.feed.synd.SyndCategoryImpl
import net.thauvin.erik.mobibot.commands.links.LinksMgr import net.thauvin.erik.mobibot.commands.links.LinksMgr
import org.apache.commons.lang3.StringUtils import org.apache.commons.lang3.StringUtils
import java.io.Serializable import java.io.Serializable
import java.util.* import java.util.Calendar
import java.util.Date
/** /**
* The class used to store link entries. * The class used to store link entries.

View file

@ -52,10 +52,10 @@ class Calc(bot: Mobibot) : AbstractModule(bot) {
try { try {
bot.send(calculate(args)) bot.send(calculate(args))
} catch (e: IllegalArgumentException) { } 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.") bot.send("No idea. This is the kind of math I don't get.")
} catch (e: UnknownFunctionOrVariableException) { } 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.") bot.send("No idea. I must've some form of Dyscalculia.")
} }
} else { } else {

View file

@ -79,7 +79,7 @@ class StockQuote(bot: Mobibot) : ThreadedModule(bot) {
const val INVALID_SYMBOL = "Invalid symbol." const val INVALID_SYMBOL = "Invalid symbol."
// Alpha Advantage URL // 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 // Quote command
private const val STOCK_CMD = "stock" private const val STOCK_CMD = "stock"
@ -122,7 +122,8 @@ class StockQuote(bot: Mobibot) : ThreadedModule(bot) {
fun getQuote(symbol: String, apiKey: String?): List<Message> { fun getQuote(symbol: String, apiKey: String?): List<Message> {
if (apiKey.isNullOrBlank()) { if (apiKey.isNullOrBlank()) {
throw ModuleException( 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()) { return if (symbol.isNotBlank()) {
val debugMessage = "getQuote($symbol)" val debugMessage = "getQuote($symbol)"
@ -133,7 +134,7 @@ class StockQuote(bot: Mobibot) : ThreadedModule(bot) {
// Search for symbol/keywords // Search for symbol/keywords
response = Utils.urlReader( response = Utils.urlReader(
URL( URL(
"${ALAPHAVANTAGE_URL}SYMBOL_SEARCH&keywords=" + Utils.encodeUrl(symbol) "${ALPHAVANTAGE_URL}SYMBOL_SEARCH&keywords=" + Utils.encodeUrl(symbol)
+ "&apikey=" + Utils.encodeUrl(apiKey) + "&apikey=" + Utils.encodeUrl(apiKey)
) )
) )
@ -147,7 +148,7 @@ class StockQuote(bot: Mobibot) : ThreadedModule(bot) {
// Get quote for symbol // Get quote for symbol
response = Utils.urlReader( response = Utils.urlReader(
URL( URL(
"${ALAPHAVANTAGE_URL}GLOBAL_QUOTE&symbol=" "${ALPHAVANTAGE_URL}GLOBAL_QUOTE&symbol="
+ Utils.encodeUrl(symbolInfo.getString("1. symbol")) + Utils.encodeUrl(symbolInfo.getString("1. symbol"))
+ "&apikey=" + Utils.encodeUrl(apiKey) + "&apikey=" + Utils.encodeUrl(apiKey)
) )

View file

@ -42,7 +42,6 @@ import net.thauvin.erik.mobibot.msg.NoticeMessage
import twitter4j.TwitterException import twitter4j.TwitterException
import twitter4j.TwitterFactory import twitter4j.TwitterFactory
import twitter4j.conf.ConfigurationBuilder import twitter4j.conf.ConfigurationBuilder
import java.util.*
/** /**
* The Twitter module. * The Twitter module.

View file

@ -102,7 +102,8 @@ class Weather2(bot: Mobibot) : ThreadedModule(bot) {
fun getWeather(query: String, apiKey: String?): List<Message> { fun getWeather(query: String, apiKey: String?): List<Message> {
if (apiKey.isNullOrBlank()) { if (apiKey.isNullOrBlank()) {
throw ModuleException( 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 owm = OWM(apiKey)
val messages = mutableListOf<Message>() val messages = mutableListOf<Message>()

View file

@ -41,8 +41,8 @@ import java.time.ZoneId
import java.time.ZonedDateTime import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoField import java.time.temporal.ChronoField
import java.util.* import java.util.Collections
import kotlin.collections.ArrayList import java.util.Locale
/** /**
* The WorldTime module. * The WorldTime module.
@ -146,7 +146,7 @@ class WorldTime(bot: Mobibot) : AbstractModule(bot) {
countries["MX"] = "America/Mexico_City" countries["MX"] = "America/Mexico_City"
countries["NL"] = "Europe/Amsterdam" countries["NL"] = "Europe/Amsterdam"
countries["NO"] = "Europe/Oslo" countries["NO"] = "Europe/Oslo"
countries["NP"] = "Asia/Katmandu" countries["NP"] = "Asia/Kathmandu"
countries["NZ"] = "Pacific/Auckland" countries["NZ"] = "Pacific/Auckland"
countries["PDT"] = "America/Los_Angeles" countries["PDT"] = "America/Los_Angeles"
countries["PH"] = "Asia/Manila" countries["PH"] = "Asia/Manila"

View file

@ -35,7 +35,7 @@ import org.testng.annotations.BeforeSuite
import java.io.IOException import java.io.IOException
import java.nio.file.Files import java.nio.file.Files
import java.nio.file.Paths import java.nio.file.Paths
import java.util.* import java.util.Properties
/** /**
* Access to `local.properties`. * Access to `local.properties`.

View file

@ -56,7 +56,7 @@ import java.io.File
import java.io.IOException import java.io.IOException
import java.net.URL import java.net.URL
import java.time.LocalDateTime import java.time.LocalDateTime
import java.util.* import java.util.Calendar
/** /**
* The `Utils Test` class. * The `Utils Test` class.

View file

@ -1,9 +1,9 @@
#Generated by the Semver Plugin for Gradle #Generated by the Semver Plugin for Gradle
#Wed May 12 19:01:23 PDT 2021 #Thu May 13 21:34:31 PDT 2021
version.buildmeta=751 version.buildmeta=771
version.major=0 version.major=0
version.minor=8 version.minor=8
version.patch=0 version.patch=0
version.prerelease=beta version.prerelease=beta
version.project=mobibot version.project=mobibot
version.semver=0.8.0-beta+751 version.semver=0.8.0-beta+771