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
|
isPrivate
|
||||||
)
|
)
|
||||||
send(sender, "The commands are:", 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) {
|
if (isOp) {
|
||||||
send(sender, "The op commands are:", isPrivate)
|
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>,
|
list: List<String>,
|
||||||
maxPerLine: Int,
|
maxPerLine: Int,
|
||||||
isPrivate: Boolean,
|
isPrivate: Boolean,
|
||||||
isBold: Boolean
|
isBold: Boolean = false,
|
||||||
) {
|
isIndent: Boolean = false while (i < list.size) {
|
||||||
var i = 0
|
|
||||||
while (i < list.size) {
|
|
||||||
send(
|
send(
|
||||||
nick,
|
nick,
|
||||||
helpFormat(
|
helpFormat(
|
||||||
|
|
|
@ -56,7 +56,7 @@ abstract class AbstractCommand(val bot: Mobibot) {
|
||||||
open fun helpResponse(command: String, sender: String, isOp: Boolean, isPrivate: Boolean): Boolean {
|
open fun helpResponse(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, Utils.helpFormat(h, bot.nick, isPrivate), isPrivate)
|
bot.send(sender, Utils.buildCmdSyntax(h, bot.nick, isPrivate), isPrivate)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ class AddLog(bot: Mobibot) : AbstractCommand(bot) {
|
||||||
return
|
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) {
|
if (ignored.size > 0) {
|
||||||
bot.send(sender, "The following nicks are ignored:", isPrivate)
|
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 {
|
} else {
|
||||||
bot.send(sender, "No one is currently ${Utils.bold("ignored")}.", isPrivate)
|
bot.send(sender, "No one is currently ${Utils.bold("ignored")}.", isPrivate)
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,9 +85,7 @@ public class Info extends AbstractCommand {
|
||||||
@NotNull final String args,
|
@NotNull final String args,
|
||||||
final boolean isOp,
|
final boolean isOp,
|
||||||
final boolean isPrivate) {
|
final boolean isPrivate) {
|
||||||
for (final String v : version) {
|
getBot().sendList(sender, allVersions, 1, isPrivate, false, false);
|
||||||
getBot().send(sender, v, isPrivate);
|
|
||||||
}
|
|
||||||
|
|
||||||
final StringBuilder info = new StringBuilder("Uptime: ");
|
final StringBuilder info = new StringBuilder("Uptime: ");
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ class Modules(bot: Mobibot) : AbstractCommand(bot) {
|
||||||
send(sender, "There are no enabled modules.", isPrivate)
|
send(sender, "There are no enabled modules.", isPrivate)
|
||||||
} else {
|
} else {
|
||||||
send(sender, "The enabled modules are: ", isPrivate)
|
send(sender, "The enabled modules are: ", isPrivate)
|
||||||
sendList(sender, modulesNames, 7, isPrivate, false)
|
sendList(sender, modulesNames, 7, isPrivate, isIndent = true)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
helpDefault(sender, isOp, isPrivate)
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
public class Versions extends AbstractCommand {
|
public class Versions extends AbstractCommand {
|
||||||
private final List<String> verList =
|
private final List<String> allVersions =
|
||||||
List.of("Version: " + ReleaseInfo.VERSION + " (" + Utils.isoLocalDate(ReleaseInfo.BUILDDATE) + ')',
|
List.of("Version: " + ReleaseInfo.VERSION + " (" + Utils.isoLocalDate(ReleaseInfo.BUILDDATE) + ')',
|
||||||
"Platform: " + System.getProperty("os.name") + ' ' + System.getProperty("os.version")
|
"Platform: " + System.getProperty("os.name") + ' ' + System.getProperty("os.version")
|
||||||
+ " (" + System.getProperty("os.arch") + ')',
|
+ " (" + System.getProperty("os.arch") + ')',
|
||||||
|
@ -86,9 +86,7 @@ public class Versions extends AbstractCommand {
|
||||||
final boolean isOp,
|
final boolean isOp,
|
||||||
final boolean isPrivate) {
|
final boolean isPrivate) {
|
||||||
if (isOp) {
|
if (isOp) {
|
||||||
for (final String v : verList) {
|
getBot().sendList(sender, allVersions, 1, isPrivate, false, false);
|
||||||
getBot().send(sender, v, isPrivate);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
getBot().helpDefault(sender, false, isPrivate);
|
getBot().helpDefault(sender, false, isPrivate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ abstract class AbstractModule(val bot: Mobibot) {
|
||||||
*/
|
*/
|
||||||
open fun helpResponse(sender: String, isPrivate: Boolean) {
|
open fun helpResponse(sender: String, isPrivate: Boolean) {
|
||||||
for (h in help) {
|
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)) {
|
} else if (args.contains(CURRENCY_RATES_KEYWORD)) {
|
||||||
send(sender, "The currency rates for ${Utils.bold(pubDate)} are:", isPrivate)
|
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 {
|
} else {
|
||||||
helpResponse(sender, isPrivate)
|
helpResponse(sender, isPrivate)
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ class CurrencyConverter(bot: Mobibot) : ThreadedModule(bot) {
|
||||||
isPrivate
|
isPrivate
|
||||||
)
|
)
|
||||||
send(sender, "The supported currencies are: ", 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) {
|
with(bot) {
|
||||||
if (args.isEmpty()) {
|
if (args.isEmpty()) {
|
||||||
send(sender, "The supported countries/zones are: ", isPrivate)
|
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 {
|
} else {
|
||||||
val msg = worldTime(args)
|
val msg = worldTime(args)
|
||||||
if (isPrivate) {
|
if (isPrivate) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue