Cleaned up send() in commands.

This commit is contained in:
Erik C. Thauvin 2020-03-28 15:01:29 -07:00
parent abbb322b5d
commit 78260381cf
9 changed files with 15 additions and 18 deletions

View file

@ -53,7 +53,7 @@ abstract class AbstractCommand {
open fun helpResponse(bot: Mobibot, command: String, sender: String, isOp: Boolean, isPrivate: Boolean): Boolean { open fun helpResponse(bot: Mobibot, command: String, sender: String, isOp: Boolean, isPrivate: Boolean): Boolean {
if (!this.isOp || this.isOp == isOp) { if (!this.isOp || this.isOp == isOp) {
for (h in help) { for (h in help) {
bot.send(sender, String.format(h, bot.nick), isPrivate) bot.send(sender, String.format(h, bot.nick))
} }
return true return true
} }

View file

@ -83,6 +83,6 @@ class Info : AbstractCommand() {
append(']') append(']')
} }
bot.send(sender, info.toString(), isPrivate) bot.send(sender, info.toString())
} }
} }

View file

@ -56,7 +56,7 @@ class Modules : AbstractCommand() {
if (isOp) { if (isOp) {
val modulesNames = bot.modulesNames val modulesNames = bot.modulesNames
if (modulesNames.isEmpty()) { if (modulesNames.isEmpty()) {
bot.send(sender, "There are no enabled modules.", true) bot.send(sender, "There are no enabled modules.", isPrivate)
} else { } else {
bot.send(sender, Utils.bold("The enabled modules are: "), false) bot.send(sender, Utils.bold("The enabled modules are: "), false)
bot.sendCommandsList(sender, modulesNames, false ) bot.sendCommandsList(sender, modulesNames, false )

View file

@ -56,7 +56,7 @@ class Msg : AbstractCommand() {
if (isOp) { if (isOp) {
val msg = args.split(" ", limit = 2) val msg = args.split(" ", limit = 2)
if (args.length > 2) { if (args.length > 2) {
bot.send(msg[0], msg[1], true) bot.send(msg[0], msg[1], isPrivate)
} else { } else {
helpResponse(bot, command, sender, isOp, isPrivate) helpResponse(bot, command, sender, isOp, isPrivate)
} }

View file

@ -66,6 +66,6 @@ class Users : AbstractCommand() {
} }
} }
bot.send(sender, nicks.sorted().joinToString(" "), isPrivate) bot.send(sender, nicks.sorted().joinToString(" "))
} }
} }

View file

@ -88,7 +88,7 @@ public class Versions extends AbstractCommand {
final boolean isPrivate) { final boolean isPrivate) {
if (isOp) { if (isOp) {
for (final String v : versions) { for (final String v : versions) {
bot.send(sender, v, isPrivate); bot.send(sender, v);
} }
} else { } else {
bot.helpDefault(sender, isOp); bot.helpDefault(sender, isOp);

View file

@ -116,8 +116,8 @@ class Comment : AbstractCommand() {
): Boolean { ): Boolean {
if (super.helpResponse(bot, command, sender, isOp, isPrivate)) { if (super.helpResponse(bot, command, sender, isOp, isPrivate)) {
if (isOp) { if (isOp) {
bot.send(sender, Utils.bold("To change a comment's author:"), 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:?<nick>"), isPrivate) bot.send(sender, Utils.helpIndent("/msg ${bot.nick} ${Constants.LINK_CMD}1.1:?<nick>"))
} }
return true return true
} }

View file

@ -196,11 +196,10 @@ class UrlMgr(defaultTags: String, keywords: String) : AbstractCommand() {
} }
saveEntries(bot, isBackup) saveEntries(bot, isBackup)
if (Constants.NO_TITLE == entry.title) { 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( bot.send(
sender, sender,
Utils.helpIndent(Constants.LINK_CMD + (index + 1) + ":|This is the title"), Utils.helpIndent(Constants.LINK_CMD + (index + 1) + ":|This is the title")
true
) )
} }
} else { } else {

View file

@ -101,30 +101,28 @@ class View : AbstractCommand() {
if (sent > maxEntries) { if (sent > maxEntries) {
bot.send( bot.send(
sender, "To view more, try: " sender, "To view more, try: "
+ Utils.bold("${bot.nick}: $command ${i + 1} $lcArgs"), + Utils.bold("${bot.nick}: $command ${i + 1} $lcArgs")
isPrivate
) )
break break
} }
bot.send(sender, EntriesUtils.buildLink(i, entry, true), isPrivate) bot.send(sender, EntriesUtils.buildLink(i, entry, true))
sent++ sent++
} }
} else { } else {
if (sent > maxEntries) { if (sent > maxEntries) {
bot.send( bot.send(
sender, sender,
"To view more, try: " + Utils.bold("${bot.nick}: $command ${i + 1}"), "To view more, try: " + Utils.bold("${bot.nick}: $command ${i + 1}")
isPrivate
) )
break break
} }
bot.send(sender, EntriesUtils.buildLink(i, entry, true), isPrivate) bot.send(sender, EntriesUtils.buildLink(i, entry, true))
sent++ sent++
} }
i++ i++
} }
} else { } 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?")
} }
} }
} }