Cleanup.
This commit is contained in:
parent
6644400a23
commit
48c2ad65c0
11 changed files with 29 additions and 24 deletions
|
@ -102,6 +102,11 @@ object Constants {
|
|||
*/
|
||||
const val PROPS_ARG = "properties"
|
||||
|
||||
/**
|
||||
* The tag command
|
||||
*/
|
||||
const val TAG_CMD = "T"
|
||||
|
||||
/**
|
||||
* The timer delay in minutes.
|
||||
*/
|
||||
|
|
|
@ -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 ->
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -229,7 +229,7 @@ class Tell(bot: Mobibot) : AbstractCommand(bot) {
|
|||
bot.send(
|
||||
nickname,
|
||||
"Your message ${reverseColor("[ID " + message.id + ']')} was sent to "
|
||||
+ "${bold(message.recipient)} on ${message.receptionDate.toUtcDateTime()}",
|
||||
+ "${bold(message.recipient)} on ${message.receptionDate.toUtcDateTime()}",
|
||||
true
|
||||
)
|
||||
message.isNotified = true
|
||||
|
@ -252,8 +252,8 @@ class Tell(bot: Mobibot) : AbstractCommand(bot) {
|
|||
for (message in messages) {
|
||||
bot.send(
|
||||
sender, bold(message.sender) + ARROW + bold(message.recipient)
|
||||
+ " [ID: " + message.id + ", "
|
||||
+ (if (message.isReceived) "DELIVERED" else "QUEUED") + ']',
|
||||
+ " [ID: " + message.id + ", "
|
||||
+ (if (message.isReceived) "DELIVERED" else "QUEUED") + ']',
|
||||
isPrivate
|
||||
)
|
||||
}
|
||||
|
@ -275,16 +275,16 @@ class Tell(bot: Mobibot) : AbstractCommand(bot) {
|
|||
bot.send(
|
||||
sender,
|
||||
bold(message.sender) + ARROW + bold(message.recipient)
|
||||
+ " [${message.receptionDate.toUtcDateTime()}, ID: "
|
||||
+ bold(message.id) + ", DELIVERED]",
|
||||
+ " [${message.receptionDate.toUtcDateTime()}, ID: "
|
||||
+ bold(message.id) + ", DELIVERED]",
|
||||
isPrivate
|
||||
)
|
||||
} else {
|
||||
bot.send(
|
||||
sender,
|
||||
bold(message.sender) + ARROW + bold(message.recipient)
|
||||
+ " [${message.queued.toUtcDateTime()}, ID: "
|
||||
+ bold(message.id) + ", QUEUED]",
|
||||
+ " [${message.queued.toUtcDateTime()}, ID: "
|
||||
+ bold(message.id) + ", QUEUED]",
|
||||
isPrivate
|
||||
)
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ class TellMessage internal constructor(
|
|||
|
||||
override fun toString(): String {
|
||||
return ("TellMessage{id='$id', isNotified=$isNotified, isReceived=$isReceived, message='$message', " +
|
||||
"queued=$queued, received=$receptionDate, recipient='$recipient', sender='$sender'}")
|
||||
"queued=$queued, received=$receptionDate, recipient='$recipient', sender='$sender'}")
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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(",", ", ")
|
||||
}
|
||||
|
|
|
@ -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"))
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue