From d11f32189e85b731441db4d5c985a423d9a31157 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 1 Aug 2021 23:23:14 -0700 Subject: [PATCH] Added separator parameter to sendList() function. --- .../kotlin/net/thauvin/erik/mobibot/Mobibot.kt | 7 ++++--- .../net/thauvin/erik/mobibot/commands/AddLog.kt | 2 +- .../net/thauvin/erik/mobibot/commands/Ignore.kt | 2 +- .../net/thauvin/erik/mobibot/commands/Info.kt | 2 +- .../net/thauvin/erik/mobibot/commands/Modules.kt | 2 +- .../net/thauvin/erik/mobibot/commands/Users.kt | 2 +- .../thauvin/erik/mobibot/commands/Versions.kt | 2 +- .../thauvin/erik/mobibot/PinboardUtilsTest.kt | 16 ++++++++-------- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt b/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt index c532b4b..6e21c00 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/Mobibot.kt @@ -256,10 +256,10 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert isPrivate ) send(sender, "The commands are:", isPrivate) - sendList(sender, addons.names, 8, isPrivate, isBold = true, isIndent = true) + sendList(sender, addons.names, 8, isPrivate = isPrivate, isBold = true, isIndent = true) if (isOp) { send(sender, "The op commands are:", isPrivate) - sendList(sender, addons.ops, 8, isPrivate, isBold = true, isIndent = true) + sendList(sender, addons.ops, 8, isPrivate = isPrivate, isBold = true, isIndent = true) } } @@ -435,6 +435,7 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert nick: String, list: List, maxPerLine: Int, + separator: String = " ", isPrivate: Boolean, isBold: Boolean = false, isIndent: Boolean = false @@ -444,7 +445,7 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert send( nick, helpFormat( - list.subList(i, list.size.coerceAtMost(i + maxPerLine)).joinToString(" ", truncated = ""), + list.subList(i, list.size.coerceAtMost(i + maxPerLine)).joinToString(separator, truncated = ""), isBold, isIndent ), diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/AddLog.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/AddLog.kt index c0c0275..f13aa4d 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/AddLog.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/AddLog.kt @@ -64,7 +64,7 @@ class AddLog(bot: Mobibot) : AbstractCommand(bot) { } } @Suppress("MagicNumber") - bot.sendList(sender, history, 4, isPrivate, isIndent = true) + bot.sendList(sender, history, 4, isPrivate = isPrivate, isIndent = true) } } } diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Ignore.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Ignore.kt index 537b19c..7ae45a2 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Ignore.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Ignore.kt @@ -140,7 +140,7 @@ class Ignore(bot: Mobibot) : AbstractCommand(bot) { if (ignored.size > 0) { bot.send(sender, "The following nicks are ignored:", isPrivate) @Suppress("MagicNumber") - bot.sendList(sender, ignored.sorted(), 8, isPrivate, isIndent = true) + bot.sendList(sender, ignored.sorted(), 8, isPrivate = isPrivate, isIndent = true) } else { bot.send(sender, "No one is currently ${bold("ignored")}.", isPrivate) } diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Info.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Info.kt index 7d2fc84..230539f 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Info.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Info.kt @@ -59,7 +59,7 @@ class Info(bot: Mobibot?) : AbstractCommand(bot!!) { isPrivate: Boolean ) { with(bot) { - sendList(sender, allVersions, 1, isPrivate) + sendList(sender, allVersions, 1, isPrivate = isPrivate) val info = StringBuilder() info.append("Uptime: ") .append(uptime(ManagementFactory.getRuntimeMXBean().uptime)) diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Modules.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Modules.kt index 2bd43c9..3bd2db1 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Modules.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Modules.kt @@ -56,7 +56,7 @@ class Modules(bot: Mobibot) : AbstractCommand(bot) { } else { send(sender, "The enabled modules are: ", isPrivate) @Suppress("MagicNumber") - sendList(sender, modulesNames, 7, isPrivate, isIndent = true) + sendList(sender, modulesNames, 7, isPrivate = isPrivate, isIndent = true) } } else { helpDefault(sender, isOp, isPrivate) diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Users.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Users.kt index de83bdf..82f5277 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Users.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Users.kt @@ -61,7 +61,7 @@ class Users(bot: Mobibot) : AbstractCommand(bot) { } @Suppress("MagicNumber") - sendList(sender, nicks.sorted(), 8, isPrivate, isIndent = true) + sendList(sender, nicks.sorted(), 8, isPrivate = isPrivate, isIndent = true) } } } diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Versions.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Versions.kt index 72acc6b..1712add 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Versions.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Versions.kt @@ -57,7 +57,7 @@ class Versions(bot: Mobibot) : AbstractCommand(bot) { isPrivate: Boolean ) { if (isOp) { - bot.sendList(sender, allVersions, 1, isPrivate) + bot.sendList(sender, allVersions, 1, isPrivate = isPrivate) } else { bot.helpDefault(sender, false, isPrivate) } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/PinboardUtilsTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/PinboardUtilsTest.kt index d9c7354..dbaf270 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/PinboardUtilsTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/PinboardUtilsTest.kt @@ -50,19 +50,19 @@ class PinboardUtilsTest : LocalProperties() { val ircServer = "irc.test.com" val entry = EntryLink(url, "Test Example", "ErikT", "", "#mobitopia", listOf("test")) - PinboardUtils.addPin(pinboard, ircServer, entry) - assertTrue(validatePin(apiToken, url = entry.link, entry.title, entry.nick, entry.channel), "addPin") + assertTrue(PinboardUtils.addPin(pinboard, ircServer, entry), "addPin") + assertTrue(validatePin(apiToken, url = entry.link, entry.title, entry.nick, entry.channel), "validate add") entry.link = "https://www.foo.com/" - PinboardUtils.updatePin(pinboard, ircServer, url, entry) - assertTrue(validatePin(apiToken, url = entry.link, ircServer), "updatePin") + assertTrue(PinboardUtils.updatePin(pinboard, ircServer, url, entry), "updatePin") + assertTrue(validatePin(apiToken, url = entry.link, ircServer), "validate update") entry.title = "Foo Title" - PinboardUtils.updatePin(pinboard, ircServer, entry.link, entry) - assertTrue(validatePin(apiToken, url = entry.link, entry.title), "update title") + assertTrue(PinboardUtils.updatePin(pinboard, ircServer, entry.link, entry), "update title") + assertTrue(validatePin(apiToken, url = entry.link, entry.title), "validate title") - PinboardUtils.deletePin(pinboard, entry) - assertFalse(validatePin(apiToken, url = entry.link), "deletePin") + assertTrue(PinboardUtils.deletePin(pinboard, entry), "daletePin") + assertFalse(validatePin(apiToken, url = entry.link), "validate delete") } @Test