import net.pterodactylus.irc.event.DccDownloadFailed;
import net.pterodactylus.irc.event.DccDownloadFinished;
import net.pterodactylus.irc.event.DccSendReceived;
+import net.pterodactylus.irc.event.PrivateMessageReceived;
import net.pterodactylus.irc.util.MessageCleaner;
import net.pterodactylus.irc.util.RandomNickname;
import net.pterodactylus.xdcc.core.event.BotAdded;
import net.pterodactylus.xdcc.core.event.DownloadFailed;
import net.pterodactylus.xdcc.core.event.DownloadFinished;
import net.pterodactylus.xdcc.core.event.DownloadStarted;
+import net.pterodactylus.xdcc.core.event.MessageReceived;
import net.pterodactylus.xdcc.data.Bot;
import net.pterodactylus.xdcc.data.Channel;
import net.pterodactylus.xdcc.data.Download;
}
/**
+ * Forward all private messages to every console.
+ *
+ * @param privateMessageReceived
+ * The private message recevied event
+ */
+ @Subscribe
+ public void privateMessageReceived(PrivateMessageReceived privateMessageReceived) {
+ eventBus.post(new MessageReceived(privateMessageReceived.source(), privateMessageReceived.message()));
+ }
+
+ /**
* Starts a DCC download.
*
* @param dccSendReceived
try {
download.outputStream().close();
File file = new File(download.filename());
- file.renameTo(new File(finalDirectory, download.filename()));
+ file.renameTo(new File(finalDirectory, download.pack().name()));
eventBus.post(new DownloadFinished(download));
+ dccReceivers.remove(dccDownloadFinished.dccReceiver());
+ downloads.remove(download);
} catch (IOException ioe1) {
/* TODO - handle all the errors. */
logger.log(Level.WARNING, String.format("Could not move file %s to directory %s.", download.filename(), finalDirectory), ioe1);
try {
Closeables.close(download.outputStream(), true);
eventBus.post(new DownloadFailed(download));
+ dccReceivers.remove(dccDownloadFailed.dccReceiver());
+ downloads.remove(download);
} catch (IOException ioe1) {
/* swallow silently. */
}
*/
public Optional<Channel> getChannel(Network network, String channelName) {
for (Channel channel : channels) {
- if (channel.network().equals(network) && (channel.name().equals(channelName))) {
+ if (channel.network().equals(network) && (channel.name().equalsIgnoreCase(channelName))) {
return Optional.of(channel);
}
}