package commands; import java.util.ArrayList; import java.util.Date; import java.util.List; import polly.logging.MSG; import polly.logging.MyPlugin; import core.PollyLoggingManager; import core.filters.DateLogFilter; import core.filters.LogFilter; import de.skuzzle.polly.sdk.MyPolly; import de.skuzzle.polly.sdk.Signature; import de.skuzzle.polly.sdk.User; import de.skuzzle.polly.sdk.exceptions.CommandException; import de.skuzzle.polly.sdk.exceptions.DatabaseException; import de.skuzzle.polly.sdk.exceptions.DuplicatedSignatureException; import de.skuzzle.polly.sdk.exceptions.InsufficientRightsException; import entities.LogEntry; public class ReplayCommand extends AbstractLogCommand { public ReplayCommand(MyPolly polly, PollyLoggingManager logManager) throws DuplicatedSignatureException { super(polly, "replay", logManager); //$NON-NLS-1$ this.createSignature(MSG.replaySig0Desc, MyPlugin.REPLAY_PERMISSION); this.setHelpText(MSG.replayHelp); this.setRegisteredOnly(); } @Override protected boolean executeOnBoth(User executer, String channel, Signature signature) throws CommandException, InsufficientRightsException { try { if (this.match(signature, 0)) { List<LogEntry> logs = new ArrayList<LogEntry>(); for (String chan : this.getMyPolly().irc().getChannels()) { if (this.getMyPolly().irc().isOnChannel(chan, executer.getCurrentNickName())) { logs.addAll(this.logManager.preFilterChannel(chan)); } } LogFilter dateFilter = new DateLogFilter( new Date(executer.getLastIdleTime())); logs = this.logManager.postFilter(logs, dateFilter); this.logManager.outputLogResults(this.getMyPolly(), executer, logs, executer.getCurrentNickName()); } } catch (DatabaseException e) { throw new CommandException(e); } return false; } }