This commit is contained in:
Erik C. Thauvin 2021-05-14 21:46:23 -07:00
parent 2e1c6e7732
commit 8098a4855d
10 changed files with 30 additions and 29 deletions

View file

@ -44,7 +44,6 @@ import static net.thauvin.erik.mobibot.Utils.bold;
* The War module. * The War module.
* *
* @author <a href="https://erik.thauvin.net" target="_blank">Erik C. Thauvin</a> * @author <a href="https://erik.thauvin.net" target="_blank">Erik C. Thauvin</a>
* @created 2014-04-28
* @since 1.0 * @since 1.0
*/ */
public final class War extends AbstractModule { public final class War extends AbstractModule {

View file

@ -38,9 +38,9 @@ import net.thauvin.erik.mobibot.Utils.buildCmdSyntax
import net.thauvin.erik.mobibot.Utils.colorize import net.thauvin.erik.mobibot.Utils.colorize
import net.thauvin.erik.mobibot.Utils.getIntProperty import net.thauvin.erik.mobibot.Utils.getIntProperty
import net.thauvin.erik.mobibot.Utils.helpFormat import net.thauvin.erik.mobibot.Utils.helpFormat
import net.thauvin.erik.mobibot.Utils.today
import net.thauvin.erik.mobibot.Utils.toIsoLocalDate
import net.thauvin.erik.mobibot.Utils.toDir import net.thauvin.erik.mobibot.Utils.toDir
import net.thauvin.erik.mobibot.Utils.toIsoLocalDate
import net.thauvin.erik.mobibot.Utils.today
import net.thauvin.erik.mobibot.commands.AddLog import net.thauvin.erik.mobibot.commands.AddLog
import net.thauvin.erik.mobibot.commands.ChannelFeed import net.thauvin.erik.mobibot.commands.ChannelFeed
import net.thauvin.erik.mobibot.commands.Cycle import net.thauvin.erik.mobibot.commands.Cycle

View file

@ -156,7 +156,7 @@ object Utils {
* Returns the plural form of a word, if count &gt; 1. * Returns the plural form of a word, if count &gt; 1.
*/ */
fun String.plural(count: Int, plural: String): String = this.plural(count.toLong(), plural) fun String.plural(count: Int, plural: String): String = this.plural(count.toLong(), plural)
/** /**
* Returns the plural form of a word, if count &gt; 1. * Returns the plural form of a word, if count &gt; 1.
*/ */
@ -187,7 +187,7 @@ object Utils {
* Ensures that the given location (File/URL) has a trailing slash (`/`) to indicate a directory. * Ensures that the given location (File/URL) has a trailing slash (`/`) to indicate a directory.
*/ */
@JvmStatic @JvmStatic
fun String.toDir(isUrl: Boolean = false) : String { fun String.toDir(isUrl: Boolean = false): String {
return if (isUrl) { return if (isUrl) {
if (this.last() == '/') { if (this.last() == '/') {
this this
@ -229,7 +229,7 @@ object Utils {
* Returns the specified date formatted as `yyyy-MM-dd HH:mm`. * Returns the specified date formatted as `yyyy-MM-dd HH:mm`.
*/ */
@JvmStatic @JvmStatic
fun LocalDateTime.toUtcDateTime(): String = this.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")) fun LocalDateTime.toUtcDateTime(): String = this.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))
/** /**
* Converts XML/XHTML entities to plain text. * Converts XML/XHTML entities to plain text.

View file

@ -33,8 +33,8 @@
package net.thauvin.erik.mobibot.commands package net.thauvin.erik.mobibot.commands
import net.thauvin.erik.mobibot.Mobibot import net.thauvin.erik.mobibot.Mobibot
import net.thauvin.erik.mobibot.Utils.toUtcDateTime
import net.thauvin.erik.mobibot.Utils.helpFormat import net.thauvin.erik.mobibot.Utils.helpFormat
import net.thauvin.erik.mobibot.Utils.toUtcDateTime
import java.time.Clock import java.time.Clock
import java.time.LocalDateTime import java.time.LocalDateTime

View file

@ -117,13 +117,13 @@ class Tell(bot: Mobibot) : AbstractCommand(bot) {
*/ */
override val name = "tell" override val name = "tell"
override val help = listOf( override val help = listOf(
"To send a message to someone when they join the channel:", "To send a message to someone when they join the channel:",
helpFormat("%c $name <nick> <message>"), helpFormat("%c $name <nick> <message>"),
"To view queued and sent messages:", "To view queued and sent messages:",
helpFormat("%c $name ${View.VIEW_CMD}"), helpFormat("%c $name ${View.VIEW_CMD}"),
"Messages are kept for ${bold(maxDays)}" + " day.".plural(maxDays, " days.") "Messages are kept for ${bold(maxDays)}" + " day.".plural(maxDays, " days.")
) )
override val isOp: Boolean = false override val isOp: Boolean = false
override val isPublic: Boolean = isEnabled() override val isPublic: Boolean = isEnabled()
override val isVisible: Boolean = isEnabled() override val isVisible: Boolean = isEnabled()
@ -224,7 +224,8 @@ class Tell(bot: Mobibot) : AbstractCommand(bot) {
save() save()
} }
} else if (message.sender.equals(nickname, ignoreCase = true) && message.isReceived } else if (message.sender.equals(nickname, ignoreCase = true) && message.isReceived
&& !message.isNotified) { && !message.isNotified
) {
bot.send( bot.send(
nickname, nickname,
"Your message ${reverseColor("[ID " + message.id + ']')} was sent to " "Your message ${reverseColor("[ID " + message.id + ']')} was sent to "

View file

@ -35,8 +35,8 @@ import net.thauvin.erik.mobibot.Mobibot
import net.thauvin.erik.mobibot.Utils.capitalise import net.thauvin.erik.mobibot.Utils.capitalise
import net.thauvin.erik.mobibot.Utils.encodeUrl import net.thauvin.erik.mobibot.Utils.encodeUrl
import net.thauvin.erik.mobibot.Utils.helpFormat import net.thauvin.erik.mobibot.Utils.helpFormat
import net.thauvin.erik.mobibot.Utils.urlReader
import net.thauvin.erik.mobibot.Utils.unescapeXml import net.thauvin.erik.mobibot.Utils.unescapeXml
import net.thauvin.erik.mobibot.Utils.urlReader
import net.thauvin.erik.mobibot.msg.Message import net.thauvin.erik.mobibot.msg.Message
import net.thauvin.erik.mobibot.msg.NoticeMessage import net.thauvin.erik.mobibot.msg.NoticeMessage
import org.jibble.pircbot.Colors import org.jibble.pircbot.Colors

View file

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

View file

@ -36,8 +36,8 @@ import net.aksingh.owmjapis.core.OWM
import net.aksingh.owmjapis.core.OWM.Country import net.aksingh.owmjapis.core.OWM.Country
import net.aksingh.owmjapis.model.CurrentWeather import net.aksingh.owmjapis.model.CurrentWeather
import net.thauvin.erik.mobibot.Mobibot import net.thauvin.erik.mobibot.Mobibot
import net.thauvin.erik.mobibot.Utils.capitalise
import net.thauvin.erik.mobibot.Utils.bold import net.thauvin.erik.mobibot.Utils.bold
import net.thauvin.erik.mobibot.Utils.capitalise
import net.thauvin.erik.mobibot.Utils.encodeUrl import net.thauvin.erik.mobibot.Utils.encodeUrl
import net.thauvin.erik.mobibot.Utils.helpFormat import net.thauvin.erik.mobibot.Utils.helpFormat
import net.thauvin.erik.mobibot.msg.ErrorMessage import net.thauvin.erik.mobibot.msg.ErrorMessage

View file

@ -32,7 +32,7 @@
package net.thauvin.erik.mobibot package net.thauvin.erik.mobibot
import net.thauvin.erik.mobibot.Utils.bold import net.thauvin.erik.mobibot.Utils.bold
import net.thauvin.erik.mobibot.Utils.capitalize import net.thauvin.erik.mobibot.Utils.capitalise
import net.thauvin.erik.mobibot.Utils.colorize import net.thauvin.erik.mobibot.Utils.colorize
import net.thauvin.erik.mobibot.Utils.cyan import net.thauvin.erik.mobibot.Utils.cyan
import net.thauvin.erik.mobibot.Utils.getIntProperty import net.thauvin.erik.mobibot.Utils.getIntProperty
@ -79,11 +79,10 @@ class UtilsTest {
} }
@Test @Test
fun testCapitalize() { fun testCapitalise() {
assertThat(capitalize("test")).describedAs("capitalize(test)").isEqualTo("Test") assertThat("test".capitalise()).describedAs("capitalize(test)").isEqualTo("Test")
assertThat(capitalize("Test")).describedAs("capitalize(Test)").isEqualTo("Test") assertThat("Test".capitalise()).describedAs("capitalize(Test)").isEqualTo("Test")
assertThat(capitalize(null)).describedAs("captitalize(null)").isNull() assertThat("".capitalise()).describedAs("capitalize()").isEqualTo("")
assertThat(capitalize("")).describedAs("capitalize()").isEqualTo("")
} }
@Test @Test
@ -168,8 +167,9 @@ class UtilsTest {
@Throws(IOException::class) @Throws(IOException::class)
fun testUrlReader() { fun testUrlReader() {
assertThat(urlReader(URL("https://postman-echo.com/status/200"))).describedAs("urlReader()") assertThat(urlReader(URL("https://postman-echo.com/status/200"))).describedAs("urlReader()")
.isEqualTo("{\"status\":200}" .isEqualTo(
) "{\"status\":200}"
)
} }
@Test @Test

View file

@ -1,9 +1,9 @@
#Generated by the Semver Plugin for Gradle #Generated by the Semver Plugin for Gradle
#Fri May 14 20:13:13 PDT 2021 #Fri May 14 21:44:23 PDT 2021
version.buildmeta=782 version.buildmeta=787
version.major=0 version.major=0
version.minor=8 version.minor=8
version.patch=0 version.patch=0
version.prerelease=beta version.prerelease=beta
version.project=mobibot version.project=mobibot
version.semver=0.8.0-beta+782 version.semver=0.8.0-beta+787