From a3fb82f62375a86c959ab6a84995fb142bca7162 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 11 Apr 2013 22:11:36 +0200 Subject: [PATCH] Show received messages on the console. --- .../net/pterodactylus/xdcc/ui/stdin/CommandReader.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java b/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java index 29c77ec..74b365a 100644 --- a/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java +++ b/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java @@ -27,10 +27,12 @@ import java.util.List; import java.util.Set; import net.pterodactylus.irc.DccReceiver; +import net.pterodactylus.irc.util.MessageCleaner; import net.pterodactylus.xdcc.core.Core; 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.Download; import net.pterodactylus.xdcc.data.Pack; @@ -207,6 +209,21 @@ public class CommandReader extends AbstractExecutionThreadService { } } + /** + * Displays the received message on the console. + * + * @param messageReceived + * The message received event + */ + @Subscribe + public void messageReceived(MessageReceived messageReceived) { + try { + writeLine(String.format("Message from %s: %s", messageReceived.source(), MessageCleaner.getDefaultInstance().clean(messageReceived.message()))); + } catch (IOException e) { + /* ignore. */ + } + } + // // PRIVATE METHODS // -- 2.7.4