X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Firc%2FConnection.java;h=a14c7390846616d59fe48d74d3dd17d87a1425ac;hb=a5a04bea966d1e8b718ae47cd7f913f1d877e486;hp=30344be9b2c831023ce74edf1a2b8e7e0446d0fd;hpb=1aa7f843043b8723a02b4bbd88eb21ae8b7db881;p=xudocci.git diff --git a/src/main/java/net/pterodactylus/irc/Connection.java b/src/main/java/net/pterodactylus/irc/Connection.java index 30344be..a14c739 100644 --- a/src/main/java/net/pterodactylus/irc/Connection.java +++ b/src/main/java/net/pterodactylus/irc/Connection.java @@ -369,12 +369,29 @@ public class Connection extends AbstractExecutionThreadService implements Servic new MessageHandler(eventBus, this, prefixHandler), new CtcpHandler(eventBus, this), new ChannelNickHandler(eventBus, this, prefixHandler), - new SimpleCommandHandler() - .addCommand("431", (s, p) -> eventBus.post( - new NoNicknameGivenReceived(this))) - .addCommand("NICK", (s, p) -> eventBus.post( - new NicknameChanged(this, s.get(), - p.get(0)))), + new SimpleCommandHandler(eventBus) + .addCommand("431", + (s, p) -> new NoNicknameGivenReceived( + this)) + .addCommand("NICK", + (s, p) -> new NicknameChanged(this, + s.get(), p.get(0))) + .addCommand("JOIN", + (s, p) -> new ChannelJoined(this, + p.get(0), s.get())) + .addCommand("332", + (s, p) -> new ChannelTopic(this, p.get(1), + p.get(2))) + .addCommand("PART", + (s, p) -> new ChannelLeft(this, p.get(0), + s.get(), getOptional(p, 1))) + .addCommand("QUIT", + (s, p) -> new ClientQuit(this, s.get(), + p.get(0))) + .addCommand("KICK", + (s, p) -> new KickedFromChannel(this, + p.get(0), s.get(), p.get(1), + getOptional(p, 2))), new MotdHandler(eventBus, this), new ChannelNotJoinedHandler(eventBus, this), new ConnectionEstablishHandler(eventBus, this), @@ -404,25 +421,11 @@ public class Connection extends AbstractExecutionThreadService implements Servic eventBus.post(new NicknameInUseReceived(this, reply)); } - /* channel stuff. */ - } else if (command.equalsIgnoreCase("JOIN")) { - eventBus.post(new ChannelJoined(this, parameters.get(0), reply.source().get())); - } else if (command.equals("331")) { - /* no topic is set. */ - } else if (command.equals("332")) { - eventBus.post(new ChannelTopic(this, parameters.get(1), parameters.get(2))); - } else if (command.equalsIgnoreCase("PART")) { - eventBus.post(new ChannelLeft(this, parameters.get(0), reply.source().get(), getOptional(parameters, 1))); - } else if (command.equalsIgnoreCase("QUIT")) { - eventBus.post(new ClientQuit(this, reply.source().get(), parameters.get(0))); /* basic connection housekeeping. */ } else if (command.equalsIgnoreCase("PING")) { connectionHandler.sendCommand("PONG", getOptional(parameters, 0), getOptional(parameters, 1)); - } else if (command.equalsIgnoreCase("KICK")) { - eventBus.post(new KickedFromChannel(this, parameters.get(0), reply.source().get(), parameters.get(1), getOptional(parameters, 2))); - /* okay, everything else. */ } else { eventBus.post(new UnknownReplyReceived(this, reply));