import javax.net.SocketFactory;
import net.pterodactylus.irc.event.ChannelJoined;
+import net.pterodactylus.irc.event.ChannelMessageReceived;
import net.pterodactylus.irc.event.ChannelNicknames;
import net.pterodactylus.irc.event.ChannelNotJoined;
import net.pterodactylus.irc.event.ChannelNotJoined.Reason;
import net.pterodactylus.irc.event.MotdReceived;
import net.pterodactylus.irc.event.NicknameInUseReceived;
import net.pterodactylus.irc.event.NoNicknameGivenReceived;
+import net.pterodactylus.irc.event.PrivateMessageReceived;
import net.pterodactylus.irc.event.UnknownReplyReceived;
import net.pterodactylus.irc.util.RandomNickname;
/* server modes. */
Map<String, String> nickPrefixes = Maps.newHashMap();
+ Set<Character> channelTypes = Sets.newHashSet();
while (connected) {
Reply reply = connectionHandler.readReply();
String command = reply.command();
List<String> parameters = reply.parameters();
+ /* most common events. */
+ if (command.equalsIgnoreCase("PRIVMSG")) {
+ String recipient = parameters.get(0);
+ if (!channelTypes.contains(recipient.charAt(0))) {
+ eventBus.post(new PrivateMessageReceived(this, reply.source().get(), parameters.get(1)));
+ } else {
+ eventBus.post(new ChannelMessageReceived(this, recipient, reply.source().get(), parameters.get(1)));
+ }
+
/* replies 001-004 don’t hold information but they have to be sent on a successful connection. */
- if (command.equals("001")) {
+ } else if (command.equals("001")) {
connectionStatus |= 0x01;
} else if (command.equals("002")) {
connectionStatus |= 0x02;
nickPrefixes.put(String.valueOf(modeSymbol), String.valueOf(modeCharacter));
}
}
+ } else if (parameter.startsWith("CHANTYPES=")) {
+ for (int typeIndex = 10; typeIndex < parameter.length(); ++typeIndex) {
+ channelTypes.add(parameter.charAt(typeIndex));
+ }
}
}