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 {
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
}

View file

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

View file

@ -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 )

View file

@ -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)
}

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) {
if (isOp) {
for (final String v : versions) {
bot.send(sender, v, isPrivate);
bot.send(sender, v);
}
} else {
bot.helpDefault(sender, isOp);

View file

@ -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:?<nick>"), 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>"))
}
return true
}

View file

@ -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 {

View file

@ -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?")
}
}
}