This commit is contained in:
Erik C. Thauvin 2021-05-18 23:48:25 -07:00
parent 6644400a23
commit 48c2ad65c0
11 changed files with 29 additions and 24 deletions

View file

@ -102,6 +102,11 @@ object Constants {
*/
const val PROPS_ARG = "properties"
/**
* The tag command
*/
const val TAG_CMD = "T"
/**
* The timer delay in minutes.
*/

View file

@ -34,10 +34,10 @@ package net.thauvin.erik.mobibot
import com.rometools.rome.io.FeedException
import com.rometools.rome.io.SyndFeedInput
import com.rometools.rome.io.XmlReader
import net.thauvin.erik.mobibot.msg.Message
import net.thauvin.erik.mobibot.msg.PublicMessage
import net.thauvin.erik.mobibot.Utils.green
import net.thauvin.erik.mobibot.Utils.helpFormat
import net.thauvin.erik.mobibot.msg.Message
import net.thauvin.erik.mobibot.msg.PublicMessage
import java.io.IOException
import java.net.URL
@ -62,10 +62,10 @@ class FeedReader(
send(sender, it)
}
} catch (e: FeedException) {
if (logger.isDebugEnabled) logger.debug("Unabled to parse the feed at ${url}", e)
if (logger.isDebugEnabled) logger.debug("Unabled to parse the feed at $url", e)
send(sender, "An error has occured while parsing the feed: ${e.message}", false)
} catch (e: IOException) {
if (logger.isDebugEnabled) logger.debug("Unable to fetch the feed at ${url}", e)
if (logger.isDebugEnabled) logger.debug("Unable to fetch the feed at $url", e)
send(sender, "An error has occurred while fetching the feed: ${e.message}", false)
}
}
@ -74,7 +74,7 @@ class FeedReader(
companion object {
@JvmStatic
@Throws(FeedException::class, IOException::class)
fun readFeed(url: String, maxItems: Int = 5) : List<Message> {
fun readFeed(url: String, maxItems: Int = 5): List<Message> {
val messages = mutableListOf<Message>()
val input = SyndFeedInput()
XmlReader(URL(url)).use { reader ->

View file

@ -33,7 +33,6 @@
package net.thauvin.erik.mobibot.commands
import net.thauvin.erik.mobibot.Mobibot
import net.thauvin.erik.mobibot.Utils.helpFormat
class Die(bot: Mobibot) : AbstractCommand(bot) {
override val name = "die"

View file

@ -33,7 +33,6 @@
package net.thauvin.erik.mobibot.commands
import net.thauvin.erik.mobibot.Mobibot
import net.thauvin.erik.mobibot.Utils.helpFormat
class Kill(bot: Mobibot) : AbstractCommand(bot) {
override val name = "kill"

View file

@ -42,8 +42,8 @@ import net.thauvin.erik.mobibot.entries.EntryLink
class Tags(bot: Mobibot) : AbstractCommand(bot) {
override val name = COMMAND
override val help = listOf(
"To categorize or tag a URL, use its label and a T:",
helpFormat("${Constants.LINK_CMD}1T:<+tag|-tag> [...]")
"To categorize or tag a URL, use its label and a ${Constants.TAG_CMD}:",
helpFormat("${Constants.LINK_CMD}1${Constants.TAG_CMD}:<+tag|-tag> [...]")
)
override val isOp = false
override val isPublic = true
@ -60,7 +60,7 @@ class Tags(bot: Mobibot) : AbstractCommand(bot) {
isOp: Boolean,
isPrivate: Boolean
) {
val cmds = args.substring(1).split("T:", limit = 2)
val cmds = args.substring(1).split("${Constants.TAG_CMD}:", limit = 2)
val index = cmds[0].toInt() - 1
if (index < LinksMgr.entries.size) {
@ -86,6 +86,6 @@ class Tags(bot: Mobibot) : AbstractCommand(bot) {
}
override fun matches(message: String): Boolean {
return message.matches("^${Constants.LINK_CMD}[0-9]+T:.*".toRegex())
return message.matches("^${Constants.LINK_CMD}[0-9]+${Constants.TAG_CMD}:.*".toRegex())
}
}

View file

@ -248,7 +248,8 @@ object EntriesMgr {
} catch (e: FeedException) {
if (bot.logger.isWarnEnabled) bot.logger.warn("Unable to generate the entries feed.", e)
} catch (e: IOException) {
if (bot.logger.isWarnEnabled) bot.logger.warn("Unable to generate the entries feed.", e)
if (bot.logger.isWarnEnabled)
bot.logger.warn("An IO error occurred while generating the entries feed.", e)
}
} else {
if (bot.logger.isWarnEnabled) {

View file

@ -76,5 +76,5 @@ object EntriesUtils {
* Build an entry's tags/categories for display on the channel.
*/
fun buildTags(entryIndex: Int, entry: EntryLink): String =
buildLinkCmd(entryIndex) + "T: " + entry.pinboardTags.replace(",", ", ")
buildLinkCmd(entryIndex) + "${Constants.TAG_CMD}: " + entry.pinboardTags.replace(",", ", ")
}

View file

@ -175,7 +175,8 @@ class StockQuote(bot: Mobibot) : ThreadedModule(bot) {
add(NoticeMessage(" High: " + unescapeXml(quote.getString("03. high"))))
add(NoticeMessage(" Low: " + unescapeXml(quote.getString("04. low"))))
add(NoticeMessage(" Volume: " + unescapeXml(quote.getString("06. volume"))))
add(NoticeMessage(
add(
NoticeMessage(
" Latest: " + unescapeXml(quote.getString("07. latest trading day"))
)
)