Improved sendList()
This commit is contained in:
parent
7146bfcc60
commit
e01de36909
11 changed files with 16 additions and 22 deletions
|
@ -258,10 +258,10 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert
|
|||
isPrivate
|
||||
)
|
||||
send(sender, "The commands are:", isPrivate)
|
||||
sendList(sender, addons.names, 8, isPrivate, true)
|
||||
sendList(sender, addons.names, 8, isPrivate, isBold = true, isIndent = true)
|
||||
if (isOp) {
|
||||
send(sender, "The op commands are:", isPrivate)
|
||||
sendList(sender, addons.ops, 8, isPrivate, true)
|
||||
sendList(sender, addons.ops, 8, isPrivate, isBold = true, isIndent = true)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -462,10 +462,8 @@ class Mobibot(nickname: String, channel: String, logsDirPath: String, p: Propert
|
|||
list: List<String>,
|
||||
maxPerLine: Int,
|
||||
isPrivate: Boolean,
|
||||
isBold: Boolean
|
||||
) {
|
||||
var i = 0
|
||||
while (i < list.size) {
|
||||
isBold: Boolean = false,
|
||||
isIndent: Boolean = false while (i < list.size) {
|
||||
send(
|
||||
nick,
|
||||
helpFormat(
|
||||
|
|
|
@ -56,7 +56,7 @@ abstract class AbstractCommand(val bot: Mobibot) {
|
|||
open fun helpResponse(command: String, sender: String, isOp: Boolean, isPrivate: Boolean): Boolean {
|
||||
if (!this.isOp || this.isOp == isOp) {
|
||||
for (h in help) {
|
||||
bot.send(sender, Utils.helpFormat(h, bot.nick, isPrivate), isPrivate)
|
||||
bot.send(sender, Utils.buildCmdSyntax(h, bot.nick, isPrivate), isPrivate)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ class AddLog(bot: Mobibot) : AbstractCommand(bot) {
|
|||
return
|
||||
}
|
||||
}
|
||||
bot.sendList(sender, history, 4, isPrivate, false)
|
||||
bot.sendList(sender, history, 4, isPrivate, isIndent = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ class Ignore(bot: Mobibot) : AbstractCommand(bot) {
|
|||
|
||||
if (ignored.size > 0) {
|
||||
bot.send(sender, "The following nicks are ignored:", isPrivate)
|
||||
bot.sendList(sender, ignored.toList(), 8, isPrivate, true)
|
||||
bot.sendList(sender, ignored.sorted(), 8, isPrivate, isIndent = true)
|
||||
} else {
|
||||
bot.send(sender, "No one is currently ${Utils.bold("ignored")}.", isPrivate)
|
||||
}
|
||||
|
|
|
@ -85,9 +85,7 @@ public class Info extends AbstractCommand {
|
|||
@NotNull final String args,
|
||||
final boolean isOp,
|
||||
final boolean isPrivate) {
|
||||
for (final String v : version) {
|
||||
getBot().send(sender, v, isPrivate);
|
||||
}
|
||||
getBot().sendList(sender, allVersions, 1, isPrivate, false, false);
|
||||
|
||||
final StringBuilder info = new StringBuilder("Uptime: ");
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class Modules(bot: Mobibot) : AbstractCommand(bot) {
|
|||
send(sender, "There are no enabled modules.", isPrivate)
|
||||
} else {
|
||||
send(sender, "The enabled modules are: ", isPrivate)
|
||||
sendList(sender, modulesNames, 7, isPrivate, false)
|
||||
sendList(sender, modulesNames, 7, isPrivate, isIndent = true)
|
||||
}
|
||||
} else {
|
||||
helpDefault(sender, isOp, isPrivate)
|
||||
|
|
|
@ -64,6 +64,6 @@ class Users(bot: Mobibot) : AbstractCommand(bot) {
|
|||
}
|
||||
}
|
||||
|
||||
bot.sendList(sender, nicks.sorted(), 8, isPrivate, false)
|
||||
bot.sendList(sender, nicks.sorted(), 8, isPrivate, isIndent = true)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
import java.util.List;
|
||||
|
||||
public class Versions extends AbstractCommand {
|
||||
private final List<String> verList =
|
||||
private final List<String> allVersions =
|
||||
List.of("Version: " + ReleaseInfo.VERSION + " (" + Utils.isoLocalDate(ReleaseInfo.BUILDDATE) + ')',
|
||||
"Platform: " + System.getProperty("os.name") + ' ' + System.getProperty("os.version")
|
||||
+ " (" + System.getProperty("os.arch") + ')',
|
||||
|
@ -86,9 +86,7 @@ public class Versions extends AbstractCommand {
|
|||
final boolean isOp,
|
||||
final boolean isPrivate) {
|
||||
if (isOp) {
|
||||
for (final String v : verList) {
|
||||
getBot().send(sender, v, isPrivate);
|
||||
}
|
||||
getBot().sendList(sender, allVersions, 1, isPrivate, false, false);
|
||||
} else {
|
||||
getBot().helpDefault(sender, false, isPrivate);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ abstract class AbstractModule(val bot: Mobibot) {
|
|||
*/
|
||||
open fun helpResponse(sender: String, isPrivate: Boolean) {
|
||||
for (h in help) {
|
||||
bot.send(sender, Utils.helpFormat(h, bot.nick, isPrivateMsgEnabled && isPrivate), isPrivate)
|
||||
bot.send(sender, Utils.buildCmdSyntax(h, bot.nick, isPrivateMsgEnabled && isPrivate), isPrivate)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ class CurrencyConverter(bot: Mobibot) : ThreadedModule(bot) {
|
|||
}
|
||||
} else if (args.contains(CURRENCY_RATES_KEYWORD)) {
|
||||
send(sender, "The currency rates for ${Utils.bold(pubDate)} are:", isPrivate)
|
||||
sendList(sender, currencyRates(), 3, isPrivate, false)
|
||||
sendList(sender, currencyRates(), 3, isPrivate, isIndent = true)
|
||||
} else {
|
||||
helpResponse(sender, isPrivate)
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ class CurrencyConverter(bot: Mobibot) : ThreadedModule(bot) {
|
|||
isPrivate
|
||||
)
|
||||
send(sender, "The supported currencies are: ", isPrivate)
|
||||
sendList(sender, ArrayList(EXCHANGE_RATES.keys), 11, isPrivate, false)
|
||||
sendList(sender, ArrayList(EXCHANGE_RATES.keys), 11, isPrivate, isIndent = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ class WorldTime(bot: Mobibot) : AbstractModule(bot) {
|
|||
with(bot) {
|
||||
if (args.isEmpty()) {
|
||||
send(sender, "The supported countries/zones are: ", isPrivate)
|
||||
sendList(sender, ArrayList(COUNTRIES_MAP.keys), 17, isPrivate = false, isBold = false)
|
||||
sendList(sender, ArrayList(COUNTRIES_MAP.keys), 17, isPrivate = false)
|
||||
} else {
|
||||
val msg = worldTime(args)
|
||||
if (isPrivate) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue