Show received messages on the console.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 11 Apr 2013 20:11:36 +0000 (22:11 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 11 Apr 2013 20:11:36 +0000 (22:11 +0200)
src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java

index 29c77ec..74b365a 100644 (file)
@@ -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
        //