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 Users());
|
||||||
commands.add(new Versions());
|
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
|
// Load the links commands
|
||||||
commands.add(new Comment());
|
commands.add(new Comment());
|
||||||
commands.add(new Posting());
|
commands.add(new Posting());
|
||||||
commands.add(new Tags());
|
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 UrlMgr(p.getProperty("tags", ""), p.getProperty("tags-keywords", "")));
|
||||||
commands.add(new View());
|
commands.add(new View());
|
||||||
|
|
||||||
|
|
||||||
// Load the modules
|
// Load the modules
|
||||||
addModule(new Calc());
|
addModule(new Calc());
|
||||||
addModule(new CurrencyConverter());
|
addModule(new CurrencyConverter());
|
||||||
|
@ -647,11 +649,6 @@ public class Mobibot extends PircBot {
|
||||||
modules.stream().filter(AbstractModule::isEnabled)
|
modules.stream().filter(AbstractModule::isEnabled)
|
||||||
.forEach(module -> commandsNames.addAll(module.getCommands()));
|
.forEach(module -> commandsNames.addAll(module.getCommands()));
|
||||||
|
|
||||||
// Tell command
|
|
||||||
if (tell.isEnabled()) {
|
|
||||||
commandsNames.add(Tell.TELL_CMD);
|
|
||||||
}
|
|
||||||
|
|
||||||
Collections.sort(commandsNames);
|
Collections.sort(commandsNames);
|
||||||
Collections.sort(opsCommandsNames);
|
Collections.sort(opsCommandsNames);
|
||||||
}
|
}
|
||||||
|
@ -829,7 +826,9 @@ public class Mobibot extends PircBot {
|
||||||
Recap.storeRecap(sender, message, false);
|
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
|
@Override
|
||||||
protected void onJoin(final String channel, final String sender, final String login, final String hostname) {
|
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
|
@Override
|
||||||
protected void onNickChange(final String oldNick, final String login, final String hostname, final String newNick) {
|
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.
|
* @param maxSize Max size.
|
||||||
*/
|
*/
|
||||||
public Tell(final Mobibot bot, final String maxDays, final String maxSize) {
|
public Tell(final Mobibot bot, final String maxDays, final String maxSize) {
|
||||||
|
super();
|
||||||
this.bot = bot;
|
this.bot = bot;
|
||||||
this.maxDays = Utils.getIntProperty(maxDays, DEFAULT_TELL_MAX_DAYS);
|
this.maxDays = Utils.getIntProperty(maxDays, DEFAULT_TELL_MAX_DAYS);
|
||||||
this.maxSize = Utils.getIntProperty(maxSize, DEFAULT_TELL_MAX_SIZE);
|
this.maxSize = Utils.getIntProperty(maxSize, DEFAULT_TELL_MAX_SIZE);
|
||||||
|
@ -187,12 +188,12 @@ public class Tell extends AbstractCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPublic() {
|
public boolean isPublic() {
|
||||||
return true;
|
return isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
return true;
|
return isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -202,22 +203,24 @@ public class Tell extends AbstractCommand {
|
||||||
@NotNull final String args,
|
@NotNull final String args,
|
||||||
final boolean isOp,
|
final boolean isOp,
|
||||||
final boolean isPrivate) {
|
final boolean isPrivate) {
|
||||||
if (StringUtils.isBlank(args)) {
|
if (isEnabled()) {
|
||||||
helpResponse(bot, args, sender, isOp, isPrivate);
|
if (StringUtils.isBlank(args)) {
|
||||||
} else if (args.startsWith(View.VIEW_CMD)) {
|
helpResponse(bot, args, sender, isOp, isPrivate);
|
||||||
if (bot.isOp(sender) && (View.VIEW_CMD + ' ' + TELL_ALL_KEYWORD).equals(args)) {
|
} else if (args.startsWith(View.VIEW_CMD)) {
|
||||||
viewAll(sender, isPrivate);
|
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 {
|
} 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()) {
|
if (clean()) {
|
||||||
save();
|
save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue