This commit is contained in:
Erik C. Thauvin 2021-12-05 22:53:29 -08:00
parent db6f322ce5
commit fd39c25c7d
13 changed files with 38 additions and 22 deletions

View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>

View file

@ -242,8 +242,8 @@ class Mobibot(nickname: String, val channel: String, logsDirPath: String, p: Pro
} }
companion object { companion object {
@Throws(Exception::class)
@JvmStatic @JvmStatic
@Throws(Exception::class)
fun main(args: Array<String>) { fun main(args: Array<String>) {
// Set up the command line options // Set up the command line options
val options = Options() val options = Options()

View file

@ -59,8 +59,8 @@ object TwitterOAuth {
* *
* @param args The consumerKey and consumerSecret should be passed as arguments. * @param args The consumerKey and consumerSecret should be passed as arguments.
*/ */
@Throws(TwitterException::class, IOException::class)
@JvmStatic @JvmStatic
@Throws(TwitterException::class, IOException::class)
fun main(args: Array<String>) { fun main(args: Array<String>) {
if (args.size == 2) { if (args.size == 2) {
with(TwitterFactory.getSingleton()) { with(TwitterFactory.getSingleton()) {

View file

@ -182,7 +182,8 @@ object Utils {
/** /**
* Return the last item of a list of strings or empty if none. * Return the last item of a list of strings or empty if none.
*/ */
fun List<String>.lastOrEmpty() : String { @JvmStatic
fun List<String>.lastOrEmpty(): String {
return if (this.size >= 2) { return if (this.size >= 2) {
this.last() this.last()
} else } else

View file

@ -70,16 +70,27 @@ class LinksMgr : AbstractCommand() {
const val TAGS_PROP = "tags" const val TAGS_PROP = "tags"
const val TAG_MATCH = ", *| +" const val TAG_MATCH = ", *| +"
/** Entries array **/ /**
* Entries array
*/
@JvmField
val entries = Entries() val entries = Entries()
/** Pinboard handler. **/ /**
* Pinboard handler.
*/
@JvmField
val pinboard = Pinboard() val pinboard = Pinboard()
/** Twitter handler. **/ /**
* Twitter handler.
*/
@JvmField
val twitter = Twitter() 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 @JvmStatic
fun isUpToDate(event: GenericMessageEvent): Boolean { fun isUpToDate(event: GenericMessageEvent): Boolean {
if (entries.lastPubDate != today()) { if (entries.lastPubDate != today()) {

View file

@ -81,7 +81,6 @@ class Tell(private val serialObject: String) : AbstractCommand() {
* Cleans the messages queue. * Cleans the messages queue.
*/ */
private fun clean(): Boolean { private fun clean(): Boolean {
// if (bot.logger.isDebugEnabled) bot.logger.debug("Cleaning the messages.")
return TellMessagesMgr.clean(messages, maxDays.toLong()) return TellMessagesMgr.clean(messages, maxDays.toLong())
} }

View file

@ -48,12 +48,14 @@ import kotlin.io.path.exists
* The Tell Messages Manager. * The Tell Messages Manager.
*/ */
object TellMessagesMgr { object TellMessagesMgr {
val logger: Logger = LoggerFactory.getLogger(TellMessagesMgr::class.java) private val logger: Logger = LoggerFactory.getLogger(TellMessagesMgr::class.java)
/** /**
* Cleans the messages queue. * Cleans the messages queue.
*/ */
@JvmStatic
fun clean(tellMessages: MutableList<TellMessage>, tellMaxDays: Long): Boolean { fun clean(tellMessages: MutableList<TellMessage>, tellMaxDays: Long): Boolean {
if (logger.isDebugEnabled) logger.debug("Cleaning the messages.")
val today = LocalDateTime.now(Clock.systemUTC()) val today = LocalDateTime.now(Clock.systemUTC())
return tellMessages.removeIf { o: TellMessage -> o.queued.plusDays(tellMaxDays).isBefore(today) } return tellMessages.removeIf { o: TellMessage -> o.queued.plusDays(tellMaxDays).isBefore(today) }
} }
@ -61,6 +63,7 @@ object TellMessagesMgr {
/** /**
* Loads the messages. * Loads the messages.
*/ */
@JvmStatic
fun load(file: String): List<TellMessage> { fun load(file: String): List<TellMessage> {
val serialFile = Paths.get(file) val serialFile = Paths.get(file)
if (serialFile.exists()) { if (serialFile.exists()) {
@ -84,6 +87,7 @@ object TellMessagesMgr {
/** /**
* Saves the messages. * Saves the messages.
*/ */
@JvmStatic
fun save(file: String, messages: List<TellMessage?>?) { fun save(file: String, messages: List<TellMessage?>?) {
try { try {
BufferedOutputStream(Files.newOutputStream(Paths.get(file))).use { bos -> BufferedOutputStream(Files.newOutputStream(Paths.get(file))).use { bos ->

View file

@ -42,17 +42,20 @@ object EntriesUtils {
/** /**
* Build link label based on its index. e.g: L1 * Build link label based on its index. e.g: L1
*/ */
@JvmStatic
fun buildLinkLabel(index: Int): String = Constants.LINK_CMD + (index + 1) fun buildLinkLabel(index: Int): String = Constants.LINK_CMD + (index + 1)
/** /**
* Builds an entry's comment for display on the channel. * Builds an entry's comment for display on the channel.
*/ */
@JvmStatic
fun buildComment(entryIndex: Int, commentIndex: Int, comment: EntryComment): String = fun buildComment(entryIndex: Int, commentIndex: Int, comment: EntryComment): String =
("${buildLinkLabel(entryIndex)}.${commentIndex + 1}: [${comment.nick}] ${comment.comment}") ("${buildLinkLabel(entryIndex)}.${commentIndex + 1}: [${comment.nick}] ${comment.comment}")
/** /**
* Builds an entry's link for display on the channel. * Builds an entry's link for display on the channel.
*/ */
@JvmStatic
@JvmOverloads @JvmOverloads
fun buildLink(entryIndex: Int, entry: EntryLink, isView: Boolean = false): String { fun buildLink(entryIndex: Int, entry: EntryLink, isView: Boolean = false): String {
val buff = StringBuilder().append(buildLinkLabel(entryIndex)).append(": ") val buff = StringBuilder().append(buildLinkLabel(entryIndex)).append(": ")
@ -75,6 +78,7 @@ object EntriesUtils {
/** /**
* Build an entry's tags/categories for display on the channel. * Build an entry's tags/categories for display on the channel.
*/ */
@JvmStatic
fun buildTags(entryIndex: Int, entry: EntryLink): String = fun buildTags(entryIndex: Int, entry: EntryLink): String =
buildLinkLabel(entryIndex) + "${Constants.TAG_CMD}: " + entry.pinboardTags.replace(",", ", ") buildLinkLabel(entryIndex) + "${Constants.TAG_CMD}: " + entry.pinboardTags.replace(",", ", ")
} }

View file

@ -68,6 +68,7 @@ class FeedsMgr private constructor() {
/** /**
* Loads the current feed. * Loads the current feed.
*/ */
@JvmStatic
@Throws(IOException::class, FeedException::class) @Throws(IOException::class, FeedException::class)
fun loadFeed(entries: Entries, currentFile: String = currentXml): String { fun loadFeed(entries: Entries, currentFile: String = currentXml): String {
entries.links.clear() entries.links.clear()
@ -113,6 +114,7 @@ class FeedsMgr private constructor() {
/** /**
* Saves the feeds. * Saves the feeds.
*/ */
@JvmStatic
fun saveFeed(entries: Entries, currentFile: String = currentXml) { fun saveFeed(entries: Entries, currentFile: String = currentXml) {
if (logger.isDebugEnabled) logger.debug("Saving the feeds...") if (logger.isDebugEnabled) logger.debug("Saving the feeds...")
if (entries.logsDir.isNotBlank()) { if (entries.logsDir.isNotBlank()) {

View file

@ -83,6 +83,7 @@ class CryptoPrices : ThreadedModule() {
/** /**
* Get current market price. * Get current market price.
*/ */
@JvmStatic
fun currentPrice(args: List<String>): CryptoPrice { fun currentPrice(args: List<String>): CryptoPrice {
return if (args.size == 2) return if (args.size == 2)
spotPrice(args[0], args[1]) spotPrice(args[0], args[1])

View file

@ -76,6 +76,7 @@ class Dice : AbstractModule() {
// Dice faces // Dice faces
private val DICE_FACES = arrayOf("", "", "", "", "", "", "") private val DICE_FACES = arrayOf("", "", "", "", "", "", "")
@JvmStatic
fun winLoseOrTie(bot: Int, player: Int): Result { fun winLoseOrTie(bot: Int, player: Int): Result {
return when { return when {
bot > player -> { bot > player -> {

View file

@ -46,10 +46,14 @@ import java.time.temporal.ChronoField
*/ */
class WorldTime : AbstractModule() { class WorldTime : AbstractModule() {
companion object { companion object {
// Beats (Internet Time) keyword /**
* Beats (Internet Time) keyword
*/
const val BEATS_KEYWORD = ".beats" const val BEATS_KEYWORD = ".beats"
// Supported countries /**
* Supported countries
*/
val COUNTRIES_MAP = buildMap<String, String> { val COUNTRIES_MAP = buildMap<String, String> {
put("AG", "America/Antigua") put("AG", "America/Antigua")
put("AI", "America/Anguilla") put("AI", "America/Anguilla")

View file

@ -45,7 +45,6 @@ open class Message @JvmOverloads constructor(
) { ) {
companion object { companion object {
var DEFAULT_COLOR = Constants.EMPTY var DEFAULT_COLOR = Constants.EMPTY
} }
init { init {