Converted Tell to an actual command.

This commit is contained in:
Erik C. Thauvin 2020-03-31 22:30:09 -07:00
parent 37f3c49413
commit 559634fbfe
2 changed files with 33 additions and 27 deletions

View file

@ -254,17 +254,19 @@ public class Mobibot extends PircBot {
commands.add(new Users());
commands.add(new Versions());
// Tell
tell = new Tell(this, p.getProperty("tell-max-days"), p.getProperty("tell-max-size"));
if (tell.isEnabled()) {
commands.add(tell);
}
// Load the links commands
commands.add(new Comment());
commands.add(new Posting());
commands.add(new Tags());
// Get the tell command settings
tell = new Tell(this, p.getProperty("tell-max-days"), p.getProperty("tell-max-size"));
commands.add(tell);
commands.add(new UrlMgr(p.getProperty("tags", ""), p.getProperty("tags-keywords", "")));
commands.add(new View());
// Load the modules
addModule(new Calc());
addModule(new CurrencyConverter());
@ -647,11 +649,6 @@ public class Mobibot extends PircBot {
modules.stream().filter(AbstractModule::isEnabled)
.forEach(module -> commandsNames.addAll(module.getCommands()));
// Tell command
if (tell.isEnabled()) {
commandsNames.add(Tell.TELL_CMD);
}
Collections.sort(commandsNames);
Collections.sort(opsCommandsNames);
}
@ -829,8 +826,10 @@ public class Mobibot extends PircBot {
Recap.storeRecap(sender, message, false);
}
if (tell.isEnabled()) {
tell.send(sender, true);
}
}
/**
* {@inheritDoc}
@ -911,16 +910,20 @@ public class Mobibot extends PircBot {
*/
@Override
protected void onJoin(final String channel, final String sender, final String login, final String hostname) {
if (tell.isEnabled()) {
tell.send(sender);
}
}
/**
* {@inheritDoc}
*/
@Override
protected void onNickChange(final String oldNick, final String login, final String hostname, final String newNick) {
if (tell.isEnabled()) {
tell.send(newNick);
}
}
/**
* Sends a private message or notice.

View file

@ -85,6 +85,7 @@ public class Tell extends AbstractCommand {
* @param maxSize Max size.
*/
public Tell(final Mobibot bot, final String maxDays, final String maxSize) {
super();
this.bot = bot;
this.maxDays = Utils.getIntProperty(maxDays, DEFAULT_TELL_MAX_DAYS);
this.maxSize = Utils.getIntProperty(maxSize, DEFAULT_TELL_MAX_SIZE);
@ -187,12 +188,12 @@ public class Tell extends AbstractCommand {
@Override
public boolean isPublic() {
return true;
return isEnabled();
}
@Override
public boolean isVisible() {
return true;
return isEnabled();
}
@Override
@ -202,6 +203,7 @@ public class Tell extends AbstractCommand {
@NotNull final String args,
final boolean isOp,
final boolean isPrivate) {
if (isEnabled()) {
if (StringUtils.isBlank(args)) {
helpResponse(bot, args, sender, isOp, isPrivate);
} else if (args.startsWith(View.VIEW_CMD)) {
@ -220,6 +222,7 @@ public class Tell extends AbstractCommand {
save();
}
}
}
/**
* Returns <code>true</code> if enabled.