Converted Tell to an actual command.
This commit is contained in:
parent
37f3c49413
commit
559634fbfe
2 changed files with 33 additions and 27 deletions
|
@ -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,7 +826,9 @@ public class Mobibot extends PircBot {
|
|||
Recap.storeRecap(sender, message, false);
|
||||
}
|
||||
|
||||
tell.send(sender, true);
|
||||
if (tell.isEnabled()) {
|
||||
tell.send(sender, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -911,7 +910,9 @@ public class Mobibot extends PircBot {
|
|||
*/
|
||||
@Override
|
||||
protected void onJoin(final String channel, final String sender, final String login, final String hostname) {
|
||||
tell.send(sender);
|
||||
if (tell.isEnabled()) {
|
||||
tell.send(sender);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -919,7 +920,9 @@ public class Mobibot extends PircBot {
|
|||
*/
|
||||
@Override
|
||||
protected void onNickChange(final String oldNick, final String login, final String hostname, final String newNick) {
|
||||
tell.send(newNick);
|
||||
if (tell.isEnabled()) {
|
||||
tell.send(newNick);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,22 +203,24 @@ public class Tell extends AbstractCommand {
|
|||
@NotNull final String args,
|
||||
final boolean isOp,
|
||||
final boolean isPrivate) {
|
||||
if (StringUtils.isBlank(args)) {
|
||||
helpResponse(bot, args, sender, isOp, isPrivate);
|
||||
} else if (args.startsWith(View.VIEW_CMD)) {
|
||||
if (bot.isOp(sender) && (View.VIEW_CMD + ' ' + TELL_ALL_KEYWORD).equals(args)) {
|
||||
viewAll(sender, isPrivate);
|
||||
if (isEnabled()) {
|
||||
if (StringUtils.isBlank(args)) {
|
||||
helpResponse(bot, args, sender, isOp, isPrivate);
|
||||
} else if (args.startsWith(View.VIEW_CMD)) {
|
||||
if (bot.isOp(sender) && (View.VIEW_CMD + ' ' + TELL_ALL_KEYWORD).equals(args)) {
|
||||
viewAll(sender, isPrivate);
|
||||
} else {
|
||||
viewMessages(sender, isPrivate);
|
||||
}
|
||||
} else if (args.startsWith(TELL_DEL_KEYWORD + ' ')) {
|
||||
deleteMessage(sender, args, isOp, isPrivate);
|
||||
} else {
|
||||
viewMessages(sender, isPrivate);
|
||||
newMessage(sender, args, isOp, isPrivate);
|
||||
}
|
||||
} else if (args.startsWith(TELL_DEL_KEYWORD + ' ')) {
|
||||
deleteMessage(sender, args, isOp, isPrivate);
|
||||
} else {
|
||||
newMessage(sender, args, isOp, isPrivate);
|
||||
}
|
||||
|
||||
if (clean()) {
|
||||
save();
|
||||
if (clean()) {
|
||||
save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue