diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 797acea..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt b/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt index bee3340..62e0fca 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt @@ -242,8 +242,8 @@ class Mobibot(nickname: String, val channel: String, logsDirPath: String, p: Pro } companion object { - @Throws(Exception::class) @JvmStatic + @Throws(Exception::class) fun main(args: Array) { // Set up the command line options val options = Options() diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/TwitterOAuth.kt b/src/main/kotlin/net/thauvin/erik/mobibot/TwitterOAuth.kt index a96b491..345943b 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/TwitterOAuth.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/TwitterOAuth.kt @@ -59,8 +59,8 @@ object TwitterOAuth { * * @param args The consumerKey and consumerSecret should be passed as arguments. */ - @Throws(TwitterException::class, IOException::class) @JvmStatic + @Throws(TwitterException::class, IOException::class) fun main(args: Array) { if (args.size == 2) { with(TwitterFactory.getSingleton()) { diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt b/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt index 835125d..f489194 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt @@ -182,7 +182,8 @@ object Utils { /** * Return the last item of a list of strings or empty if none. */ - fun List.lastOrEmpty() : String { + @JvmStatic + fun List.lastOrEmpty(): String { return if (this.size >= 2) { this.last() } else diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/links/LinksMgr.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/links/LinksMgr.kt index 17b06e1..07abbf5 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/links/LinksMgr.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/links/LinksMgr.kt @@ -70,16 +70,27 @@ class LinksMgr : AbstractCommand() { const val TAGS_PROP = "tags" const val TAG_MATCH = ", *| +" - /** Entries array **/ + /** + * Entries array + */ + @JvmField val entries = Entries() - /** Pinboard handler. **/ + /** + * Pinboard handler. + */ + @JvmField val pinboard = Pinboard() - /** Twitter handler. **/ + /** + * Twitter handler. + */ + @JvmField val twitter = Twitter() - /** Let the user know if the entries are too old to be modified. **/ + /** + * Let the user know if the entries are too old to be modified. + */ @JvmStatic fun isUpToDate(event: GenericMessageEvent): Boolean { if (entries.lastPubDate != today()) { 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 b18327f..c3a0b65 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 @@ -81,7 +81,6 @@ class Tell(private val serialObject: String) : AbstractCommand() { * Cleans the messages queue. */ private fun clean(): Boolean { - // if (bot.logger.isDebugEnabled) bot.logger.debug("Cleaning the messages.") return TellMessagesMgr.clean(messages, maxDays.toLong()) } diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/TellMessagesMgr.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/TellMessagesMgr.kt index 5960b63..e61b814 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/TellMessagesMgr.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/TellMessagesMgr.kt @@ -48,12 +48,14 @@ import kotlin.io.path.exists * The Tell Messages Manager. */ object TellMessagesMgr { - val logger: Logger = LoggerFactory.getLogger(TellMessagesMgr::class.java) + private val logger: Logger = LoggerFactory.getLogger(TellMessagesMgr::class.java) /** * Cleans the messages queue. */ + @JvmStatic fun clean(tellMessages: MutableList, tellMaxDays: Long): Boolean { + if (logger.isDebugEnabled) logger.debug("Cleaning the messages.") val today = LocalDateTime.now(Clock.systemUTC()) return tellMessages.removeIf { o: TellMessage -> o.queued.plusDays(tellMaxDays).isBefore(today) } } @@ -61,6 +63,7 @@ object TellMessagesMgr { /** * Loads the messages. */ + @JvmStatic fun load(file: String): List { val serialFile = Paths.get(file) if (serialFile.exists()) { @@ -84,6 +87,7 @@ object TellMessagesMgr { /** * Saves the messages. */ + @JvmStatic fun save(file: String, messages: List?) { try { BufferedOutputStream(Files.newOutputStream(Paths.get(file))).use { bos -> diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntriesUtils.kt b/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntriesUtils.kt index 4c4c29c..02cfd4d 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntriesUtils.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntriesUtils.kt @@ -42,17 +42,20 @@ object EntriesUtils { /** * Build link label based on its index. e.g: L1 */ + @JvmStatic fun buildLinkLabel(index: Int): String = Constants.LINK_CMD + (index + 1) /** * Builds an entry's comment for display on the channel. */ + @JvmStatic fun buildComment(entryIndex: Int, commentIndex: Int, comment: EntryComment): String = ("${buildLinkLabel(entryIndex)}.${commentIndex + 1}: [${comment.nick}] ${comment.comment}") /** * Builds an entry's link for display on the channel. */ + @JvmStatic @JvmOverloads fun buildLink(entryIndex: Int, entry: EntryLink, isView: Boolean = false): String { val buff = StringBuilder().append(buildLinkLabel(entryIndex)).append(": ") @@ -75,6 +78,7 @@ object EntriesUtils { /** * Build an entry's tags/categories for display on the channel. */ + @JvmStatic fun buildTags(entryIndex: Int, entry: EntryLink): String = buildLinkLabel(entryIndex) + "${Constants.TAG_CMD}: " + entry.pinboardTags.replace(",", ", ") } diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/entries/FeedsMgr.kt b/src/main/kotlin/net/thauvin/erik/mobibot/entries/FeedsMgr.kt index ccbcd46..5891720 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/entries/FeedsMgr.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/entries/FeedsMgr.kt @@ -68,6 +68,7 @@ class FeedsMgr private constructor() { /** * Loads the current feed. */ + @JvmStatic @Throws(IOException::class, FeedException::class) fun loadFeed(entries: Entries, currentFile: String = currentXml): String { entries.links.clear() @@ -113,6 +114,7 @@ class FeedsMgr private constructor() { /** * Saves the feeds. */ + @JvmStatic fun saveFeed(entries: Entries, currentFile: String = currentXml) { if (logger.isDebugEnabled) logger.debug("Saving the feeds...") if (entries.logsDir.isNotBlank()) { diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/modules/CryptoPrices.kt b/src/main/kotlin/net/thauvin/erik/mobibot/modules/CryptoPrices.kt index 9721055..35b0b86 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/CryptoPrices.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/CryptoPrices.kt @@ -83,6 +83,7 @@ class CryptoPrices : ThreadedModule() { /** * Get current market price. */ + @JvmStatic fun currentPrice(args: List): CryptoPrice { return if (args.size == 2) spotPrice(args[0], args[1]) 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 4dced28..848df2c 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/Dice.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/Dice.kt @@ -76,6 +76,7 @@ class Dice : AbstractModule() { // Dice faces private val DICE_FACES = arrayOf("", "⚀", "⚁", "⚂", "⚃", "⚄", "⚅") + @JvmStatic fun winLoseOrTie(bot: Int, player: Int): Result { return when { bot > player -> { 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 7abe820..b5c80eb 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/WorldTime.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/WorldTime.kt @@ -46,10 +46,14 @@ import java.time.temporal.ChronoField */ class WorldTime : AbstractModule() { companion object { - // Beats (Internet Time) keyword + /** + * Beats (Internet Time) keyword + */ const val BEATS_KEYWORD = ".beats" - // Supported countries + /** + * Supported countries + */ val COUNTRIES_MAP = buildMap { put("AG", "America/Antigua") put("AI", "America/Anguilla") diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/msg/Message.kt b/src/main/kotlin/net/thauvin/erik/mobibot/msg/Message.kt index 471c310..1d2e5bc 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/msg/Message.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/msg/Message.kt @@ -45,7 +45,6 @@ open class Message @JvmOverloads constructor( ) { companion object { var DEFAULT_COLOR = Constants.EMPTY - } init {