import net.pterodactylus.irc.connection.MessageHandler;
import net.pterodactylus.irc.connection.MotdHandler;
import net.pterodactylus.irc.connection.PrefixHandler;
+import net.pterodactylus.irc.connection.SimpleCommandHandler;
import net.pterodactylus.irc.event.ChannelJoined;
import net.pterodactylus.irc.event.ChannelLeft;
import net.pterodactylus.irc.event.ChannelTopic;
new MessageHandler(eventBus, this, prefixHandler),
new CtcpHandler(eventBus, this),
new ChannelNickHandler(eventBus, this, prefixHandler),
+ 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())),
new MotdHandler(eventBus, this),
new ChannelNotJoinedHandler(eventBus, this),
new ConnectionEstablishHandler(eventBus, this),
}
/* 43x replies are for nick change errors. */
- if (command.equals("431")) {
- eventBus.post(new NoNicknameGivenReceived(this));
- } else if (command.equals("433")) {
+ if (command.equals("433")) {
if (!established.get()) {
nickname = nicknameChooser.getNickname();
connectionHandler.sendCommand("NICK", nickname);
eventBus.post(new NicknameInUseReceived(this, reply));
}
- /* client stuff. */
- } else if (command.equalsIgnoreCase("NICK")) {
- eventBus.post(new NicknameChanged(this, reply.source().get(), parameters.get(0)));
-
/* 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")) {