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 {
@Throws(Exception::class)
@JvmStatic
@Throws(Exception::class)
fun main(args: Array<String>) {
// Set up the command line options
val options = Options()

View file

@ -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<String>) {
if (args.size == 2) {
with(TwitterFactory.getSingleton()) {

View file

@ -182,7 +182,8 @@ object Utils {
/**
* 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) {
this.last()
} else

View file

@ -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()) {

View file

@ -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())
}

View file

@ -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<TellMessage>, 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<TellMessage> {
val serialFile = Paths.get(file)
if (serialFile.exists()) {
@ -84,6 +87,7 @@ object TellMessagesMgr {
/**
* Saves the messages.
*/
@JvmStatic
fun save(file: String, messages: List<TellMessage?>?) {
try {
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
*/
@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(",", ", ")
}

View file

@ -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()) {

View file

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

View file

@ -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 -> {

View file

@ -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<String, String> {
put("AG", "America/Antigua")
put("AI", "America/Anguilla")

View file

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