From abbb322b5d74ac43fba153ce2291c4cb49da737b Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sat, 28 Mar 2020 15:00:56 -0700 Subject: [PATCH] Added setCommandsList method. --- .../net/thauvin/erik/mobibot/Mobibot.java | 27 ++++++++++++------- .../thauvin/erik/mobibot/commands/Modules.kt | 4 +-- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java index f68e272..db20fd4 100644 --- a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java +++ b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java @@ -650,16 +650,10 @@ public class Mobibot extends PircBot { Collections.sort(opsCommandsNames); } - // Print 6 commands per line - final int chunk = 6; - for (int i = 0; i < commandsNames.size(); i += chunk) { - send(sender, Utils.helpIndent( - String.join(" ", commandsNames.subList(i, Math.min(commandsNames.size(), i + chunk))))); - } - + sendCommandsList(sender, commandsNames, false); if (isOp) { - send(sender, Utils.bold("The op commands are:")); - send(sender, Utils.helpIndent(String.join(" ", opsCommandsNames))); + send(sender, Utils.bold("The op commands are:"), false); + sendCommandsList(sender, opsCommandsNames, false); } } @@ -1015,6 +1009,20 @@ public class Mobibot extends PircBot { send(who, Utils.colorize(message, color), false); } + /** + * Send a formatted commands/modules, etc. list. + * + * @param nick The nick to send the list to. + * @param list The list to format. + */ + public final void sendCommandsList(final String nick, final List list, final boolean isPrivate) { + final int chunk = 8; // 8 commands per line. + for (int i = 0; i < list.size(); i += chunk) { + send(nick, Utils.helpIndent( + String.join(" ", list.subList(i, Math.min(list.size(), i + chunk)))), isPrivate); + } + } + /** * Sets the backlogs URL. * @@ -1152,6 +1160,7 @@ public class Mobibot extends PircBot { twitterEntries.remove(index); } + /** * Post all the links on twitter on shutdown. */ 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 de494a4..2bbce85 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Modules.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Modules.kt @@ -58,8 +58,8 @@ class Modules : AbstractCommand() { if (modulesNames.isEmpty()) { bot.send(sender, "There are no enabled modules.", true) } else { - bot.send(sender, Utils.bold("The enabled modules are: ")) - bot.send(sender, Utils.helpIndent(modulesNames.joinToString(", "))) + bot.send(sender, Utils.bold("The enabled modules are: "), false) + bot.sendCommandsList(sender, modulesNames, false ) } } else { bot.helpDefault(sender, isOp)