From 78260381cf05439b975ebeb6e463468faf3c62b4 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sat, 28 Mar 2020 15:01:29 -0700 Subject: [PATCH] Cleaned up send() in commands. --- .../thauvin/erik/mobibot/commands/AbstractCommand.kt | 2 +- .../java/net/thauvin/erik/mobibot/commands/Info.kt | 2 +- .../net/thauvin/erik/mobibot/commands/Modules.kt | 2 +- .../java/net/thauvin/erik/mobibot/commands/Msg.kt | 2 +- .../java/net/thauvin/erik/mobibot/commands/Users.kt | 2 +- .../net/thauvin/erik/mobibot/commands/Versions.java | 2 +- .../thauvin/erik/mobibot/commands/links/Comment.kt | 4 ++-- .../thauvin/erik/mobibot/commands/links/UrlMgr.kt | 5 ++--- .../net/thauvin/erik/mobibot/commands/links/View.kt | 12 +++++------- 9 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/AbstractCommand.kt b/src/main/java/net/thauvin/erik/mobibot/commands/AbstractCommand.kt index aeaac2d..9d1a0cb 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/AbstractCommand.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/AbstractCommand.kt @@ -53,7 +53,7 @@ abstract class AbstractCommand { open fun helpResponse(bot: Mobibot, command: String, sender: String, isOp: Boolean, isPrivate: Boolean): Boolean { if (!this.isOp || this.isOp == isOp) { for (h in help) { - bot.send(sender, String.format(h, bot.nick), isPrivate) + bot.send(sender, String.format(h, bot.nick)) } return true } diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Info.kt b/src/main/java/net/thauvin/erik/mobibot/commands/Info.kt index b1ad2ac..9bc4715 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Info.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Info.kt @@ -83,6 +83,6 @@ class Info : AbstractCommand() { append(']') } - bot.send(sender, info.toString(), isPrivate) + bot.send(sender, info.toString()) } } diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Modules.kt b/src/main/java/net/thauvin/erik/mobibot/commands/Modules.kt index 2bbce85..ae9492a 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Modules.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Modules.kt @@ -56,7 +56,7 @@ class Modules : AbstractCommand() { if (isOp) { val modulesNames = bot.modulesNames if (modulesNames.isEmpty()) { - bot.send(sender, "There are no enabled modules.", true) + bot.send(sender, "There are no enabled modules.", isPrivate) } else { bot.send(sender, Utils.bold("The enabled modules are: "), false) bot.sendCommandsList(sender, modulesNames, false ) diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Msg.kt b/src/main/java/net/thauvin/erik/mobibot/commands/Msg.kt index 5c01b83..8c4cc2f 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Msg.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Msg.kt @@ -56,7 +56,7 @@ class Msg : AbstractCommand() { if (isOp) { val msg = args.split(" ", limit = 2) if (args.length > 2) { - bot.send(msg[0], msg[1], true) + bot.send(msg[0], msg[1], isPrivate) } else { helpResponse(bot, command, sender, isOp, isPrivate) } diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Users.kt b/src/main/java/net/thauvin/erik/mobibot/commands/Users.kt index 1f0f735..acfed1d 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Users.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Users.kt @@ -66,6 +66,6 @@ class Users : AbstractCommand() { } } - bot.send(sender, nicks.sorted().joinToString(" "), isPrivate) + bot.send(sender, nicks.sorted().joinToString(" ")) } } diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Versions.java b/src/main/java/net/thauvin/erik/mobibot/commands/Versions.java index 064f5e9..cdc15a2 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Versions.java +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Versions.java @@ -88,7 +88,7 @@ public class Versions extends AbstractCommand { final boolean isPrivate) { if (isOp) { for (final String v : versions) { - bot.send(sender, v, isPrivate); + bot.send(sender, v); } } else { bot.helpDefault(sender, isOp); diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/links/Comment.kt b/src/main/java/net/thauvin/erik/mobibot/commands/links/Comment.kt index 9e1138f..6f8a192 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/links/Comment.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/links/Comment.kt @@ -116,8 +116,8 @@ class Comment : AbstractCommand() { ): Boolean { if (super.helpResponse(bot, command, sender, isOp, isPrivate)) { if (isOp) { - bot.send(sender, Utils.bold("To change a comment's author:"), isPrivate) - bot.send(sender, Utils.helpIndent("/msg ${bot.nick} ${Constants.LINK_CMD}1.1:?"), isPrivate) + bot.send(sender, Utils.bold("To change a comment's author:")) + bot.send(sender, Utils.helpIndent("/msg ${bot.nick} ${Constants.LINK_CMD}1.1:?")) } return true } diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/links/UrlMgr.kt b/src/main/java/net/thauvin/erik/mobibot/commands/links/UrlMgr.kt index bbd8c7a..02afc30 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/links/UrlMgr.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/links/UrlMgr.kt @@ -196,11 +196,10 @@ class UrlMgr(defaultTags: String, keywords: String) : AbstractCommand() { } saveEntries(bot, isBackup) if (Constants.NO_TITLE == entry.title) { - bot.send(sender, Utils.bold("Please specify a title, by typing:"), true) + bot.send(sender, Utils.bold("Please specify a title, by typing:")) bot.send( sender, - Utils.helpIndent(Constants.LINK_CMD + (index + 1) + ":|This is the title"), - true + Utils.helpIndent(Constants.LINK_CMD + (index + 1) + ":|This is the title") ) } } else { diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/links/View.kt b/src/main/java/net/thauvin/erik/mobibot/commands/links/View.kt index e45885d..daec0f2 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/links/View.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/links/View.kt @@ -101,30 +101,28 @@ class View : AbstractCommand() { if (sent > maxEntries) { bot.send( sender, "To view more, try: " - + Utils.bold("${bot.nick}: $command ${i + 1} $lcArgs"), - isPrivate + + Utils.bold("${bot.nick}: $command ${i + 1} $lcArgs") ) break } - bot.send(sender, EntriesUtils.buildLink(i, entry, true), isPrivate) + bot.send(sender, EntriesUtils.buildLink(i, entry, true)) sent++ } } else { if (sent > maxEntries) { bot.send( sender, - "To view more, try: " + Utils.bold("${bot.nick}: $command ${i + 1}"), - isPrivate + "To view more, try: " + Utils.bold("${bot.nick}: $command ${i + 1}") ) break } - bot.send(sender, EntriesUtils.buildLink(i, entry, true), isPrivate) + bot.send(sender, EntriesUtils.buildLink(i, entry, true)) sent++ } i++ } } else { - bot.send(sender, "There is currently nothing to view. Why don't you post something?", isPrivate) + bot.send(sender, "There is currently nothing to view. Why don't you post something?") } } }