From 7146bfcc60badadaa157e308e88e29d4fa873cb5 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 8 Dec 2020 01:34:02 -0800 Subject: [PATCH] Improved helpFormat() --- .../java/net/thauvin/erik/mobibot/FeedReader.kt | 2 +- .../java/net/thauvin/erik/mobibot/Mobibot.kt | 11 +++++------ src/main/java/net/thauvin/erik/mobibot/Utils.kt | 16 +++------------- .../net/thauvin/erik/mobibot/commands/Cycle.kt | 2 +- .../net/thauvin/erik/mobibot/commands/Ignore.kt | 12 ++++++------ .../net/thauvin/erik/mobibot/commands/Info.java | 2 +- .../java/net/thauvin/erik/mobibot/commands/Me.kt | 2 +- .../net/thauvin/erik/mobibot/commands/Modules.kt | 2 +- .../net/thauvin/erik/mobibot/commands/Msg.kt | 2 +- .../net/thauvin/erik/mobibot/commands/Nick.kt | 2 +- .../net/thauvin/erik/mobibot/commands/Recap.kt | 2 +- .../net/thauvin/erik/mobibot/commands/Say.kt | 2 +- .../net/thauvin/erik/mobibot/commands/Users.kt | 2 +- .../thauvin/erik/mobibot/commands/Versions.java | 2 +- .../erik/mobibot/commands/links/Comment.kt | 8 ++++---- .../erik/mobibot/commands/links/LinksMgr.kt | 2 +- .../erik/mobibot/commands/links/Posting.kt | 8 ++++---- .../thauvin/erik/mobibot/commands/links/Tags.kt | 2 +- .../thauvin/erik/mobibot/commands/links/View.kt | 2 +- .../thauvin/erik/mobibot/commands/tell/Tell.kt | 10 +++++----- .../erik/mobibot/modules/CurrencyConverter.kt | 8 ++++---- .../net/thauvin/erik/mobibot/modules/Dice.kt | 2 +- .../thauvin/erik/mobibot/modules/GoogleSearch.kt | 4 ++-- .../net/thauvin/erik/mobibot/modules/Joke.kt | 2 +- .../net/thauvin/erik/mobibot/modules/Lookup.kt | 2 +- .../net/thauvin/erik/mobibot/modules/Ping.kt | 2 +- .../erik/mobibot/modules/RockPaperScissors.kt | 2 +- .../thauvin/erik/mobibot/modules/StockQuote.kt | 2 +- .../net/thauvin/erik/mobibot/modules/Twitter.kt | 2 +- .../net/thauvin/erik/mobibot/modules/War.java | 2 +- .../net/thauvin/erik/mobibot/modules/Weather2.kt | 4 ++-- .../thauvin/erik/mobibot/modules/WorldTime.kt | 4 ++-- 32 files changed, 59 insertions(+), 70 deletions(-) diff --git a/src/main/java/net/thauvin/erik/mobibot/FeedReader.kt b/src/main/java/net/thauvin/erik/mobibot/FeedReader.kt index d57d1b4..23b124a 100644 --- a/src/main/java/net/thauvin/erik/mobibot/FeedReader.kt +++ b/src/main/java/net/thauvin/erik/mobibot/FeedReader.kt @@ -66,7 +66,7 @@ class FeedReader( var i = 0 while (i < items.size && i < maxItems) { send(sender, items[i].title, false) - send(sender, Utils.helpIndent(Utils.green(items[i].link), false), false) + send(sender, Utils.helpFormat(Utils.green(items[i].link), false), false) i++ } } diff --git a/src/main/java/net/thauvin/erik/mobibot/Mobibot.kt b/src/main/java/net/thauvin/erik/mobibot/Mobibot.kt index 16c28c0..1900992 100644 --- a/src/main/java/net/thauvin/erik/mobibot/Mobibot.kt +++ b/src/main/java/net/thauvin/erik/mobibot/Mobibot.kt @@ -38,7 +38,7 @@ import net.thauvin.erik.mobibot.Utils.colorize import net.thauvin.erik.mobibot.Utils.ensureDir import net.thauvin.erik.mobibot.Utils.getIntProperty import net.thauvin.erik.mobibot.Utils.helpFormat -import net.thauvin.erik.mobibot.Utils.helpIndent +import net.thauvin.erik.mobibot.Utils.buildCmdSyntax import net.thauvin.erik.mobibot.Utils.isoLocalDate import net.thauvin.erik.mobibot.Utils.today import net.thauvin.erik.mobibot.commands.AddLog @@ -254,7 +254,7 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert send(sender, "For more information on a specific command, type:", isPrivate) send( sender, - helpIndent(helpFormat("%c ${Constants.HELP_CMD} ", nick, isPrivate)), + helpFormat(buildCmdSyntax("%c ${Constants.HELP_CMD} ", nick, isPrivate)), isPrivate ) send(sender, "The commands are:", isPrivate) @@ -468,11 +468,10 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert while (i < list.size) { send( nick, - helpIndent( + helpFormat( list.subList(i, list.size.coerceAtMost(i + maxPerLine)).joinToString(" ", truncated = ""), - isBold - ), - isPrivate + isBold, + isIndent isPrivate ) i += maxPerLine } diff --git a/src/main/java/net/thauvin/erik/mobibot/Utils.kt b/src/main/java/net/thauvin/erik/mobibot/Utils.kt index 1aa1829..b4b91f6 100644 --- a/src/main/java/net/thauvin/erik/mobibot/Utils.kt +++ b/src/main/java/net/thauvin/erik/mobibot/Utils.kt @@ -138,22 +138,12 @@ object Utils { fun green(s: String?): String = colorize(s, Colors.DARK_GREEN) /** - * Formats a help command by replacing `%c` with the bot's pub/priv command, and `%n` with the bot's - * nick. - */ - @JvmStatic - fun helpFormat(text: String, botNick: String, isPrivate: Boolean): String { - val replace = arrayOf(if (isPrivate) "/msg $botNick" else "$botNick:", botNick) - return StringUtils.replaceEach(text, searchFlags, replace) - } - - /** - * Returns indented help string. + * Returns a formatted help string. */ @JvmStatic @JvmOverloads - fun helpIndent(help: String, isBold: Boolean = true): String { - return " " + if (isBold) bold(help) else help + fun helpFormat(help: String, isBold: Boolean = true, isIndent: Boolean = true): String { + return (if (isIndent) " " else "").plus(if (isBold) bold(help) else help) } /** diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Cycle.kt b/src/main/java/net/thauvin/erik/mobibot/commands/Cycle.kt index 525ad33..49832f2 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Cycle.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Cycle.kt @@ -38,7 +38,7 @@ import net.thauvin.erik.mobibot.Utils class Cycle(bot: Mobibot) : AbstractCommand(bot) { private val wait = 10 override val name = "cycle" - override val help = listOf("To have the bot leave the channel and come back:", Utils.helpIndent("%c $name")) + override val help = listOf("To have the bot leave the channel and come back:", Utils.helpFormat("%c $name")) override val isOp = true override val isPublic = false override val isVisible = true diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Ignore.kt b/src/main/java/net/thauvin/erik/mobibot/commands/Ignore.kt index de8d58b..10f8fe6 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Ignore.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Ignore.kt @@ -47,17 +47,17 @@ class Ignore(bot: Mobibot) : AbstractCommand(bot) { override val name = IGNORE_CMD override val help = listOf( "To ignore a link posted to the channel:", - Utils.helpIndent("https://www.foo.bar %n"), + Utils.helpFormat("https://www.foo.bar %n"), "To check your ignore status:", - Utils.helpIndent("%c $name"), + Utils.helpFormat("%c $name"), "To toggle your ignore status:", - Utils.helpIndent("%c $name $me") + Utils.helpFormat("%c $name $me") ) private val helpOp = listOf( "To ignore a link posted to the channel:", - Utils.helpIndent("https://www.foo.bar " + Utils.bold("%n"), false), + Utils.helpFormat("https://www.foo.bar " + Utils.bold("%n"), false), "To add/remove nicks from the ignored list:", - Utils.helpIndent("%c $name [ ...]") + Utils.helpFormat("%c $name [ ...]") ) override val isOp = false @@ -99,7 +99,7 @@ class Ignore(bot: Mobibot) : AbstractCommand(bot) { ): Boolean { return if (isOp) { for (h in helpOp) { - bot.send(sender, Utils.helpFormat(h, bot.nick, isPrivate), isPrivate) + bot.send(sender, Utils.buildCmdSyntax(h, bot.nick, isPrivate), isPrivate) } true } else { diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Info.java b/src/main/java/net/thauvin/erik/mobibot/commands/Info.java index e9c9975..d16bd92 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Info.java +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Info.java @@ -61,7 +61,7 @@ public class Info extends AbstractCommand { @NotNull @Override public List getHelp() { - return List.of("To view information about the bot:", Utils.helpIndent("%c " + getName())); + return List.of("To view information about the bot:", Utils.helpFormat("%c " + getName())); } @Override diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Me.kt b/src/main/java/net/thauvin/erik/mobibot/commands/Me.kt index 4b27cd7..fa0861b 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Me.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Me.kt @@ -39,7 +39,7 @@ class Me(bot: Mobibot) : AbstractCommand(bot) { override val name = "me" override val help = listOf( "To have the bot perform an action:", - Utils.helpIndent("%c $name ") + Utils.helpFormat("%c $name ") ) override val isOp = true override val isPublic = false 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 447552c..f3f3960 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Modules.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Modules.kt @@ -39,7 +39,7 @@ class Modules(bot: Mobibot) : AbstractCommand(bot) { override val name = "modules" override val help = listOf( "To view a list of enabled modules:", - Utils.helpIndent("%c $name") + Utils.helpFormat("%c $name") ) override val isOp = true override val isPublic = 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 37c50df..31693c6 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Msg.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Msg.kt @@ -39,7 +39,7 @@ class Msg(bot: Mobibot) : AbstractCommand(bot) { override val name = "msg" override val help = listOf( "To have the bot send a private message to someone:", - Utils.helpIndent("%c $name ") + Utils.helpFormat("%c $name ") ) override val isOp = true override val isPublic = true diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Nick.kt b/src/main/java/net/thauvin/erik/mobibot/commands/Nick.kt index 6d12d2f..c6c7d2c 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Nick.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Nick.kt @@ -39,7 +39,7 @@ class Nick(bot: Mobibot) : AbstractCommand(bot) { override val name = "nick" override val help = listOf( "To change the bot's nickname:", - Utils.helpIndent("%c $name ") + Utils.helpFormat("%c $name ") ) override val isOp = true override val isPublic = true diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Recap.kt b/src/main/java/net/thauvin/erik/mobibot/commands/Recap.kt index e6341f8..57477ef 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Recap.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Recap.kt @@ -41,7 +41,7 @@ class Recap(bot: Mobibot) : AbstractCommand(bot) { override val name = "recap" override val help = listOf( "To list the last 10 public channel messages:", - Utils.helpIndent("%c $name") + Utils.helpFormat("%c $name") ) override val isOp = false override val isPublic = true diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Say.kt b/src/main/java/net/thauvin/erik/mobibot/commands/Say.kt index be8d6f0..7651d9d 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Say.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Say.kt @@ -39,7 +39,7 @@ class Say(bot: Mobibot) : AbstractCommand(bot) { override val name = "say" override val help = listOf( "To have the bot say something on the channel:", - Utils.helpIndent("%c $name ") + Utils.helpFormat("%c $name ") ) override val isOp = true override val isPublic = false 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 0315560..5afdf5a 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Users.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Users.kt @@ -40,7 +40,7 @@ class Users(bot: Mobibot) : AbstractCommand(bot) { override val name = "users" override val help = listOf( "To list the users present on the channel:", - Utils.helpIndent("%c $name") + Utils.helpFormat("%c $name") ) override val isOp = false override val isPublic = true 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 4b08631..8a2f168 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Versions.java +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Versions.java @@ -61,7 +61,7 @@ public class Versions extends AbstractCommand { @NotNull @Override public List getHelp() { - return List.of("To view the versions data (bot, platform, java, etc.):", Utils.helpIndent("%c " + getName())); + return List.of("To view the versions data (bot, platform, java, etc.):", Utils.helpFormat("%c " + getName())); } @Override 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 65941cf..35b644c 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 @@ -43,12 +43,12 @@ class Comment(bot: Mobibot) : AbstractCommand(bot) { override val name = COMMAND override val help = listOf( "To add a comment:", - Utils.helpIndent("${Constants.LINK_CMD}1:This is a comment"), + Utils.helpFormat("${Constants.LINK_CMD}1:This is a comment"), "I will reply with a label, for example: ${Utils.bold(Constants.LINK_CMD)}1.1", "To edit a comment, use its label: ", - Utils.helpIndent("${Constants.LINK_CMD}1.1:This is an edited comment"), + Utils.helpFormat("${Constants.LINK_CMD}1.1:This is an edited comment"), "To delete a comment, use its label and a minus sign: ", - Utils.helpIndent("${Constants.LINK_CMD}1.1:-") + Utils.helpFormat("${Constants.LINK_CMD}1.1:-") ) override val isOp = false override val isPublic = true @@ -98,7 +98,7 @@ class Comment(bot: Mobibot) : AbstractCommand(bot) { bot.send(sender, "To change a comment's author:", isPrivate) bot.send( sender, - Utils.helpIndent("${Constants.LINK_CMD}1.1:?"), + Utils.helpFormat("${Constants.LINK_CMD}1.1:?"), isPrivate ) } diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/links/LinksMgr.kt b/src/main/java/net/thauvin/erik/mobibot/commands/links/LinksMgr.kt index a3a3861..374b9d5 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/links/LinksMgr.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/links/LinksMgr.kt @@ -144,7 +144,7 @@ class LinksMgr(bot: Mobibot) : AbstractCommand(bot) { bot.send(sender, "Please specify a title, by typing:", isPrivate) bot.send( sender, - Utils.helpIndent("${EntriesUtils.buildLinkCmd(index)}:|This is the title"), + Utils.helpFormat("${EntriesUtils.buildLinkCmd(index)}:|This is the title"), isPrivate ) } diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/links/Posting.kt b/src/main/java/net/thauvin/erik/mobibot/commands/links/Posting.kt index 474108f..5582fbb 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/links/Posting.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/links/Posting.kt @@ -44,15 +44,15 @@ class Posting(bot: Mobibot) : AbstractCommand(bot) { override val name = "posting" override val help = listOf( "Post a URL, by saying it on a line on its own:", - Utils.helpIndent(" [] ${Tags.COMMAND}: <+tag> [...]]"), + Utils.helpFormat("<url> [<title>] ${Tags.COMMAND}: <+tag> [...]]"), "I will reply with a label, for example: ${Utils.bold(Constants.LINK_CMD)}1", "To add a title, use its label and a pipe:", - Utils.helpIndent("${Constants.LINK_CMD}1:|This is the title"), + Utils.helpFormat("${Constants.LINK_CMD}1:|This is the title"), "To add a comment:", - Utils.helpIndent("${Constants.LINK_CMD}1:This is a comment"), + Utils.helpFormat("${Constants.LINK_CMD}1:This is a comment"), "I will reply with a label, for example: ${Utils.bold(Constants.LINK_CMD)}1.1", "To edit a comment, see: ", - Utils.helpIndent("%c ${Constants.HELP_CMD} ${Comment.COMMAND}") + Utils.helpFormat("%c ${Constants.HELP_CMD} ${Comment.COMMAND}") ) override val isOp = false override val isPublic = true diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/links/Tags.kt b/src/main/java/net/thauvin/erik/mobibot/commands/links/Tags.kt index 9a9a73e..e07fe21 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/links/Tags.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/links/Tags.kt @@ -43,7 +43,7 @@ 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:", - Utils.helpIndent("${Constants.LINK_CMD}1T:<+tag|-tag> [...]") + Utils.helpFormat("${Constants.LINK_CMD}1T:<+tag|-tag> [...]") ) override val isOp = false override val isPublic = true 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 dbafa4a..0ea0708 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 @@ -44,7 +44,7 @@ class View(bot: Mobibot) : AbstractCommand(bot) { override val name = VIEW_CMD override val help = listOf( "To list or search the current URL posts:", - Utils.helpIndent("%c $name [<start>] [<query>]") + Utils.helpFormat("%c $name [<start>] [<query>]") ) override val isOp = false override val isPublic = true diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/tell/Tell.kt b/src/main/java/net/thauvin/erik/mobibot/commands/tell/Tell.kt index be54085..af6a603 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/tell/Tell.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/tell/Tell.kt @@ -118,9 +118,9 @@ class Tell(bot: Mobibot) : AbstractCommand(bot) { override val help: List<String> get() = listOf( "To send a message to someone when they join the channel:", - helpIndent("%c $name <nick> <message>"), + helpFormat("%c $name <nick> <message>"), "To view queued and sent messages:", - helpIndent("%c $name ${View.VIEW_CMD}"), + helpFormat("%c $name ${View.VIEW_CMD}"), "Messages are kept for " + bold(maxDays) + plural(maxDays.toLong(), " day.", " days.") ) @@ -293,7 +293,7 @@ class Tell(bot: Mobibot) : AbstractCommand(bot) { isPrivate ) } - bot.send(sender, helpIndent(message.message), isPrivate) + bot.send(sender, helpFormat(message.message), isPrivate) } } if (!hasMessage) { @@ -302,8 +302,8 @@ class Tell(bot: Mobibot) : AbstractCommand(bot) { bot.send(sender, "To delete one or all delivered messages:", isPrivate) bot.send( sender, - helpIndent( - helpFormat( + helpFormat( + buildCmdSyntax( "%c $name $TELL_DEL_KEYWORD <id|$TELL_ALL_KEYWORD>", bot.nick, isPrivate diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.kt b/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.kt index d02e5d6..ded4a6b 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.kt +++ b/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.kt @@ -108,16 +108,16 @@ class CurrencyConverter(bot: Mobibot) : ThreadedModule(bot) { send(sender, "To convert from one currency to another:", isPrivate) send( sender, - Utils.helpIndent( - Utils.helpFormat("%c $CURRENCY_CMD 100 USD to EUR", nick, isPrivateMsgEnabled) + Utils.helpFormat( + Utils.buildCmdSyntax("%c $CURRENCY_CMD 100 USD to EUR", nick, isPrivateMsgEnabled) ), isPrivate ) send(sender, "For a listing of current rates:", isPrivate) send( sender, - Utils.helpIndent( - Utils.helpFormat("%c $CURRENCY_CMD $CURRENCY_RATES_KEYWORD", nick, isPrivateMsgEnabled) + Utils.helpFormat( + Utils.buildCmdSyntax("%c $CURRENCY_CMD $CURRENCY_RATES_KEYWORD", nick, isPrivateMsgEnabled) ), isPrivate ) diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/Dice.kt b/src/main/java/net/thauvin/erik/mobibot/modules/Dice.kt index 4f6a314..fb20e9d 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/Dice.kt +++ b/src/main/java/net/thauvin/erik/mobibot/modules/Dice.kt @@ -98,6 +98,6 @@ class Dice(bot: Mobibot) : AbstractModule(bot) { init { commands.add(DICE_CMD) help.add("To roll the dice:") - help.add(Utils.helpIndent("%c $DICE_CMD")) + help.add(Utils.helpFormat("%c $DICE_CMD")) } } diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/GoogleSearch.kt b/src/main/java/net/thauvin/erik/mobibot/modules/GoogleSearch.kt index 687ce17..bbaec32 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/GoogleSearch.kt +++ b/src/main/java/net/thauvin/erik/mobibot/modules/GoogleSearch.kt @@ -101,7 +101,7 @@ class GoogleSearch(bot: Mobibot) : ThreadedModule(bot) { for (i in 0 until ja.length()) { val j = ja.getJSONObject(i) results.add(NoticeMessage(Utils.unescapeXml(j.getString("title")))) - results.add(NoticeMessage(Utils.helpIndent(j.getString("link"), false), Colors.DARK_GREEN)) + results.add(NoticeMessage(Utils.helpFormat(j.getString("link"), false), Colors.DARK_GREEN)) } } catch (e: IOException) { throw ModuleException("searchGoogle($query)", "An IO error has occurred searching Google.", e) @@ -118,7 +118,7 @@ class GoogleSearch(bot: Mobibot) : ThreadedModule(bot) { init { commands.add(GOOGLE_CMD) help.add("To search Google:") - help.add(Utils.helpIndent("%c $GOOGLE_CMD <query>")) + help.add(Utils.helpFormat("%c $GOOGLE_CMD <query>")) initProperties(GOOGLE_API_KEY_PROP, GOOGLE_CSE_KEY_PROP) } } diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/Joke.kt b/src/main/java/net/thauvin/erik/mobibot/modules/Joke.kt index bc760b2..9743441 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/Joke.kt +++ b/src/main/java/net/thauvin/erik/mobibot/modules/Joke.kt @@ -97,6 +97,6 @@ class Joke(bot: Mobibot) : ThreadedModule(bot) { init { commands.add(JOKE_CMD) help.add("To retrieve a random joke:") - help.add(Utils.helpIndent("%c $JOKE_CMD")) + help.add(Utils.helpFormat("%c $JOKE_CMD")) } } diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/Lookup.kt b/src/main/java/net/thauvin/erik/mobibot/modules/Lookup.kt index 32557bd..71a3037 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/Lookup.kt +++ b/src/main/java/net/thauvin/erik/mobibot/modules/Lookup.kt @@ -164,6 +164,6 @@ class Lookup(bot: Mobibot) : AbstractModule(bot) { init { commands.add(LOOKUP_CMD) help.add("To perform a DNS lookup query:") - help.add(Utils.helpIndent("%c $LOOKUP_CMD <ip address or hostname>")) + help.add(Utils.helpFormat("%c $LOOKUP_CMD <ip address or hostname>")) } } diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/Ping.kt b/src/main/java/net/thauvin/erik/mobibot/modules/Ping.kt index 980ece9..470a453 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/Ping.kt +++ b/src/main/java/net/thauvin/erik/mobibot/modules/Ping.kt @@ -85,6 +85,6 @@ class Ping(bot: Mobibot) : AbstractModule(bot) { init { commands.add(PING_CMD) help.add("To ping the bot:") - help.add(Utils.helpIndent("%c $PING_CMD")) + help.add(Utils.helpFormat("%c $PING_CMD")) } } diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/RockPaperScissors.kt b/src/main/java/net/thauvin/erik/mobibot/modules/RockPaperScissors.kt index 9bcc1ad..e22496a 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/RockPaperScissors.kt +++ b/src/main/java/net/thauvin/erik/mobibot/modules/RockPaperScissors.kt @@ -51,7 +51,7 @@ class RockPaperScissors(bot: Mobibot) : AbstractModule(bot) { with(help) { add("To play Rock Paper Scissors:") add( - Utils.helpIndent( + Utils.helpFormat( "%c ${Hands.ROCK.name.toLowerCase()} | ${Hands.PAPER.name.toLowerCase()}" + " | ${Hands.SCISSORS.name.toLowerCase()}" ) diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/StockQuote.kt b/src/main/java/net/thauvin/erik/mobibot/modules/StockQuote.kt index 5e4ae34..a43eca2 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/StockQuote.kt +++ b/src/main/java/net/thauvin/erik/mobibot/modules/StockQuote.kt @@ -206,7 +206,7 @@ class StockQuote(bot: Mobibot) : ThreadedModule(bot) { init { commands.add(STOCK_CMD) help.add("To retrieve a stock quote:") - help.add(Utils.helpIndent("%c $STOCK_CMD <symbol|keywords>")) + help.add(Utils.helpFormat("%c $STOCK_CMD <symbol|keywords>")) initProperties(ALPHAVANTAGE_API_KEY_PROP) } } diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/Twitter.kt b/src/main/java/net/thauvin/erik/mobibot/modules/Twitter.kt index 9a7ac28..beb3793 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/Twitter.kt +++ b/src/main/java/net/thauvin/erik/mobibot/modules/Twitter.kt @@ -234,7 +234,7 @@ class Twitter(bot: Mobibot) : ThreadedModule(bot) { init { commands.add(TWITTER_CMD) help.add("To post to Twitter:") - help.add(Utils.helpIndent("%c $TWITTER_CMD <message>")) + help.add(Utils.helpFormat("%c $TWITTER_CMD <message>")) properties[AUTOPOST_PROP] = "false" initProperties(CONSUMER_KEY_PROP, CONSUMER_SECRET_PROP, HANDLE_PROP, TOKEN_PROP, TOKEN_SECRET_PROP) } diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/War.java b/src/main/java/net/thauvin/erik/mobibot/modules/War.java index fe43ef5..b239e87 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/War.java +++ b/src/main/java/net/thauvin/erik/mobibot/modules/War.java @@ -65,7 +65,7 @@ public final class War extends AbstractModule { commands.add(WAR_CMD); help.add("To play war:"); - help.add(Utils.helpIndent("%c " + WAR_CMD)); + help.add(Utils.helpFormat("%c " + WAR_CMD)); } /** diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/Weather2.kt b/src/main/java/net/thauvin/erik/mobibot/modules/Weather2.kt index ab2e385..a6133b4 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/Weather2.kt +++ b/src/main/java/net/thauvin/erik/mobibot/modules/Weather2.kt @@ -191,9 +191,9 @@ class Weather2(bot: Mobibot) : ThreadedModule(bot) { init { commands.add(WEATHER_CMD) help.add("To display weather information:") - help.add(Utils.helpIndent("%c $WEATHER_CMD <city> [, <country code>]")) + help.add(Utils.helpFormat("%c $WEATHER_CMD <city> [, <country code>]")) help.add("For example:") - help.add(Utils.helpIndent("%c $WEATHER_CMD paris, fr")) + help.add(Utils.helpFormat("%c $WEATHER_CMD paris, fr")) help.add("The default ISO 3166 country code is ${Utils.bold("US")}. Zip codes supported in most countries.") initProperties(OWM_API_KEY_PROP) } diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/WorldTime.kt b/src/main/java/net/thauvin/erik/mobibot/modules/WorldTime.kt index 3338439..7695b0b 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/WorldTime.kt +++ b/src/main/java/net/thauvin/erik/mobibot/modules/WorldTime.kt @@ -211,9 +211,9 @@ class WorldTime(bot: Mobibot) : AbstractModule(bot) { init { help.add("To display a country's current date/time:") - help.add(Utils.helpIndent("%c $TIME_CMD") + " [<country code>]") + help.add(Utils.helpFormat("%c $TIME_CMD") + " [<country code>]") help.add("For a listing of the supported countries:") - help.add(Utils.helpIndent("%c $TIME_CMD")) + help.add(Utils.helpFormat("%c $TIME_CMD")) commands.add(TIME_CMD) } }