- * This is a type of mode change and is also passed to the onMode - * method in the PircBot class. - * - * @param channel The channel in which the mode change took place. - * @param sourceNick The nick of the user that performed the mode change. - * @param sourceLogin The login of the user that performed the mode change. - * @param sourceHostname The host name of the user that performed the mode - * change. - * @param recipient The nick of the user that got 'de-opp-ed'. - */ - @Override - protected void onDeop(String channel, - String sourceNick, - String sourceLogin, - String sourceHostname, - String recipient) + + public String getNick() { - if (logger.isTraceEnabled()) - logger.trace("DEOP on " + channel + ": Received from " + sourceNick - + " " + sourceLogin + "@" + sourceHostname + "on " + recipient); - - ChatRoomIrcImpl chatRoom = ircMUCOpSet.getChatRoom(channel); - - if (chatRoom == null || !chatRoom.isJoined()) - return; - - ChatRoomMember sourceMember = chatRoom.getChatRoomMember(sourceNick); - - if (sourceMember == null) - return; - - chatRoom.fireMemberRoleEvent(sourceMember, ChatRoomMemberRole.GUEST); + //TODO Implement this. + return ""; } - - /** - * Called when a user (possibly us) gets voice status removed. - *
- * This is a type of mode change and is also passed to the onMode - * method in the PircBot class. - * - * @param channel The channel in which the mode change took place. - * @param sourceNick The nick of the user that performed the mode change. - * @param sourceLogin The login of the user that performed the mode change. - * @param sourceHostname The host name of the user that performed the mode - * change. - * @param recipient The nick of the user that got 'de-voiced'. - */ - @Override - protected void onDeVoice(String channel, String sourceNick, - String sourceLogin, String sourceHostname, String recipient) + + public void setUserNickname(String nick) { - if (logger.isDebugEnabled()) - logger.debug("DEVOICE on " + channel + ": Received from " - + sourceNick + " " + sourceLogin + "@" + sourceHostname + "on " - + recipient); - - ChatRoomIrcImpl chatRoom = ircMUCOpSet.getChatRoom(channel); - - if (chatRoom == null || !chatRoom.isJoined()) - return; - - ChatRoomMember sourceMember = chatRoom.getChatRoomMember(sourceNick); - - if (sourceMember == null) - return; - - chatRoom.fireMemberRoleEvent( sourceMember, - ChatRoomMemberRole.SILENT_MEMBER); + //TODO Implement this. } - - /** - * Called when we are invited to a channel by a user. - * - * @param targetNick The nick of the user being invited - should be us! - * @param sourceNick The nick of the user that sent the invitation. - * @param sourceLogin The login of the user that sent the invitation. - * @param sourceHostname The host name of the user that sent the invitation. - * @param channel The channel that we're being invited to. - */ - @Override - protected void onInvite(String targetNick, - String sourceNick, - String sourceLogin, - String sourceHostname, - String channel) + + public void setSubject(ChatRoomIrcImpl chatroom, String subject) { - if (logger.isTraceEnabled()) - logger.trace("INVITE on " + channel + ": Received from " - + sourceNick + " " + sourceLogin + "@" + sourceHostname); - - ChatRoom targetChatRoom = ircMUCOpSet.findRoom(channel); - - ircMUCOpSet.fireInvitationEvent(targetChatRoom, - sourceNick, - "", - null); + //TODO Implement this. } - - /** - * This method is called whenever someone (possibly us) joins a channel - * which we are on. - * - * @param channel The channel which somebody joined. - * @param sender The nick of the user who joined the channel. - * @param login The login of the user who joined the channel. - * @param hostname The host name of the user who joined the channel. - */ - @Override - protected void onJoin( String channel, - String sender, - String login, - String hostname) + + public boolean isJoined(ChatRoomIrcImpl chatroom) { - if (logger.isTraceEnabled()) - logger.trace("JOIN on " + channel + ": Received from " + sender - + " " + login + "@" + hostname); - - ChatRoomIrcImpl chatRoom - = (ChatRoomIrcImpl) ircMUCOpSet.findRoom(channel); - - if(joinTimeoutTimers.containsKey(chatRoom)) - { - Timer timer = joinTimeoutTimers.get(chatRoom); - - timer.cancel(); - joinTimeoutTimers.remove(chatRoom); - } - - if(chatRoom.getUserNickname().equals(sender)) - { - ircMUCOpSet.fireLocalUserPresenceEvent( - chatRoom, - LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOINED, - ""); - } - else - { - ChatRoomMemberIrcImpl member = new ChatRoomMemberIrcImpl( - parentProvider, - chatRoom, - sender, - ChatRoomMemberRole.GUEST); - - chatRoom.addChatRoomMember(sender, member); - - //we don't specify a reason - chatRoom.fireMemberPresenceEvent( - member, - null, - ChatRoomMemberPresenceChangeEvent.MEMBER_JOINED, - null); - } + //TODO Implement this. + return false; } - - /** - * This method is called whenever someone (possibly us) is kicked from - * any of the channels that we are in. - * - * @param channel The channel from which the recipient was kicked. - * @param kickerNick The nick of the user who performed the kick. - * @param kickerLogin The login of the user who performed the kick. - * @param kickerHostname The host name of the user who performed the kick. - * @param recipientNick The unfortunate recipient of the kick. - * @param reason The reason given by the user who performed the kick. - */ - @Override - protected void onKick( String channel, - String kickerNick, - String kickerLogin, - String kickerHostname, - String recipientNick, - String reason) - { - if (logger.isTraceEnabled()) - logger.trace("KICK on " + channel - + ": Received from " + kickerNick - + " " + kickerLogin + "@" + kickerHostname); - - ChatRoomIrcImpl chatRoom = ircMUCOpSet.getChatRoom(channel); - - if (chatRoom == null || !chatRoom.isJoined()) - return; - - if(chatRoom.getUserNickname().equals(kickerNick)) - { - notifyChatRoomOperation(0); - } - - if(chatRoom.getUserNickname().equals(recipientNick)) - ircMUCOpSet.fireLocalUserPresenceEvent( - chatRoom, - LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_KICKED, - reason); - else - { - ChatRoomMember member - = chatRoom.getChatRoomMember(recipientNick); - - ChatRoomMember actorMember - = chatRoom.getChatRoomMember(kickerNick); - - chatRoom.removeChatRoomMember(recipientNick); - - chatRoom.fireMemberPresenceEvent( - member, - actorMember, - ChatRoomMemberPresenceChangeEvent.MEMBER_KICKED, - reason); - } - } - - /** - * This method is called whenever someone (possibly us) changes nick on any - * of the channels that we are on. - * - * @param oldNick The old nick. - * @param login The login of the user. - * @param hostname The host name of the user. - * @param newNick The new nick. - */ - @Override - protected void onNickChange(String oldNick, - String login, - String hostname, - String newNick) - { - if (logger.isTraceEnabled()) - logger.trace("NICK changed: from " + oldNick + " changed to " - + newNick); - - this.notifyChatRoomOperation(0); - - for (ChatRoom chatRoom : ircMUCOpSet.getCurrentlyJoinedChatRooms()) - { - ChatRoomIrcImpl chatRoomIrcImpl = (ChatRoomIrcImpl) chatRoom; - - if (chatRoom.getUserNickname().equals(oldNick)) - { - chatRoomIrcImpl.setNickName(newNick); - return; - } - - ChatRoomMember member = chatRoomIrcImpl.getChatRoomMember(oldNick); - - if (member == null) - continue; - - ChatRoomMemberPropertyChangeEvent evt - = new ChatRoomMemberPropertyChangeEvent( - member, - chatRoom, - ChatRoomMemberPropertyChangeEvent.MEMBER_NICKNAME, - oldNick, - newNick); - - chatRoomIrcImpl.fireMemberPropertyChangeEvent(evt); - } - } - - /** - * This method is called whenever we receive a notice. - * - * @param sourceNick The nick of the user that sent the notice. - * @param sourceLogin The login of the user that sent the notice. - * @param sourceHostname The host name of the user that sent the notice. - * @param target The target of the notice, be it our nick or a channel name. - * @param notice The notice message. - */ - @Override - protected void onNotice(String sourceNick, - String sourceLogin, - String sourceHostname, - String target, - String notice) - { - if (logger.isTraceEnabled()) - logger.trace("NOTICE on " + target + ": Received from " - + sourceNick + " " + sourceLogin + "@" + sourceHostname - + " the message: " + notice); - - MessageIrcImpl message - = new MessageIrcImpl( notice, - MessageIrcImpl.DEFAULT_MIME_TYPE, - MessageIrcImpl.DEFAULT_MIME_ENCODING, - null); - - ChatRoomIrcImpl chatRoom = ircMUCOpSet.getChatRoom(target); - - ChatRoomMember sourceMember = null; - - if(chatRoom == null || !chatRoom.isJoined()) - { - chatRoom = ircMUCOpSet.findSystemRoom(); - - sourceMember = ircMUCOpSet.findSystemMember(); - } - else - { - sourceMember = chatRoom.getChatRoomMember(sourceNick); - } - - if (sourceMember == null) - return; - - chatRoom.fireMessageReceivedEvent( - message, - sourceMember, - new Date(), - ChatRoomMessageReceivedEvent.ACTION_MESSAGE_RECEIVED); - } - - /** - * Called when a user (possibly us) gets granted operator status for a - * channel. - *
- * This is a type of mode change and is also passed to the onMode - * method in the PircBot class. - * - * @param channel The channel in which the mode change took place. - * @param sourceNick The nick of the user that performed the mode change. - * @param sourceLogin The login of the user that performed the mode change. - * @param sourceHostname The host name of the user that performed the mode - * change. - * @param recipient The nick of the user that got 'opp-ed'. - */ - @Override - protected void onOp(String channel, - String sourceNick, - String sourceLogin, - String sourceHostname, - String recipient) - { - if (logger.isDebugEnabled()) - logger.debug("MODE OP on " + channel + ": from " + sourceNick + " " - + sourceLogin + "@" + sourceHostname + " on " + recipient); - - ChatRoomIrcImpl chatRoom = ircMUCOpSet.getChatRoom(channel); - - if (chatRoom == null || !chatRoom.isJoined()) - return; - - ChatRoomMember sourceMember = chatRoom.getChatRoomMember(sourceNick); - - if (sourceMember == null) - return; - - chatRoom.fireMemberRoleEvent( sourceMember, - ChatRoomMemberRole.ADMINISTRATOR); - } - - /** - * This method is called whenever someone (possibly us) leaves a channel - * which we are on. - * - * @param channel The channel which somebody parted from. - * @param sender The nick of the user who parted from the channel. - * @param login The login of the user who parted from the channel. - * @param hostname The host name of the user who parted from the channel. - */ - @Override - protected void onPart( String channel, - String sender, - String login, - String hostname) - { - if (logger.isDebugEnabled()) - logger.debug("LEAVE on " + channel + ": Received from " + sender - + " " + login + "@" + hostname); - - ChatRoomIrcImpl chatRoom - = (ChatRoomIrcImpl) ircMUCOpSet.findRoom(channel); - - if(chatRoom.getUserNickname().equals(sender)) - { - ircMUCOpSet.fireLocalUserPresenceEvent( - chatRoom, - LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_LEFT, - ""); - - for (ChatRoomMember member : chatRoom.getMembers()) - chatRoom.fireMemberPresenceEvent( - member, - null, - ChatRoomMemberPresenceChangeEvent.MEMBER_LEFT, - "Local user has left the chat room."); - - // Delete the list of members - chatRoom.clearChatRoomMemberList(); - } - else - { - ChatRoomMember member = chatRoom.getChatRoomMember(sender); - - if (member == null) - return; - - chatRoom.removeChatRoomMember(sender); - - //we don't specify a reason - chatRoom.fireMemberPresenceEvent( - member, - null, - ChatRoomMemberPresenceChangeEvent.MEMBER_LEFT, - null); - } - } - - /** - * This method is called whenever someone (possibly us) quits from the - * server. We will only observe this if the user was in one of the - * channels to which we are connected. - * - * @param sourceNick The nick of the user that quit from the server. - * @param sourceLogin The login of the user that quit from the server. - * @param sourceHostname The host name of the user that quit from the server. - * @param reason The reason given for quitting the server. - */ - @Override - protected void onQuit( String sourceNick, - String sourceLogin, - String sourceHostname, - String reason) - { - if (logger.isDebugEnabled()) - logger.debug("QUIT : Received from " + sourceNick + " " - + sourceLogin + "@" + sourceHostname); - - for (ChatRoom chatRoom : ircMUCOpSet.getCurrentlyJoinedChatRooms()) - { - ChatRoomIrcImpl chatRoomIrcImpl = (ChatRoomIrcImpl) chatRoom; - - if(chatRoom.getUserNickname().equals(sourceNick)) - ircMUCOpSet.fireLocalUserPresenceEvent( - chatRoom, - LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_DROPPED, - reason); - else - { - ChatRoomMember member - = chatRoomIrcImpl.getChatRoomMember(sourceNick); - - if (member == null) - return; - - chatRoomIrcImpl.removeChatRoomMember(sourceNick); - - chatRoomIrcImpl.fireMemberPresenceEvent( - member, - null, - ChatRoomMemberPresenceChangeEvent.MEMBER_QUIT, - reason); - } - } - } - - /** - * Called when a host mask ban is removed from a channel. - *
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- * @param hostmask
- */
- @Override
- protected void onRemoveChannelBan( String channel,
- String sourceNick,
- String sourceLogin,
- String sourceHostname,
- String hostmask)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- ChatRoom chatRoom = ircMUCOpSet.getChatRoom(channel);
-
- if (chatRoom == null)
- return;
-
- //TODO: Implement IrcStack.onRemoveChannelBan.
- }
-
- /**
- * Called when a channel key is removed.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- * @param key The key that was in use before the channel key was removed.
- */
- @Override
- protected void onRemoveChannelKey( String channel,
- String sourceNick,
- String sourceLogin,
- String sourceHostname,
- String key)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- //TODO: Implement IrcStack.onRemoveChannelKey().
- }
-
- /**
- * Called when the user limit is removed for a channel.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- */
- @Override
- protected void onRemoveChannelLimit(String channel, String sourceNick,
- String sourceLogin, String sourceHostname)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- ChatRoom chatRoom = ircMUCOpSet.getChatRoom(channel);
-
- if (chatRoom == null)
- return;
-
- //TODO: Implement IrcStack.onRemoveChannelLimit().
- }
-
- /**
- * Called when a channel has 'invite only' removed.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- */
- @Override
- protected void onRemoveInviteOnly( String channel,
- String sourceNick,
- String sourceLogin,
- String sourceHostname)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- // TODO: Implement IrcStack.onRemoveInviteOnly().
- }
-
- /**
- * Called when a channel has moderated mode removed.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- */
- @Override
- protected void onRemoveModerated( String channel,
- String sourceNick,
- String sourceLogin,
- String sourceHostname)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- // TODO: Implement IrcStack.onRemoveModerated().
- }
-
- /**
- * Called when a channel is set to allow messages from any user, even
- * if they are not actually in the channel.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- */
- @Override
- protected void onRemoveNoExternalMessages( String channel,
- String sourceNick,
- String sourceLogin,
- String sourceHostname)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- // TODO: Implement IrcStack.onRemoveNoExternalMessages().
- }
-
- /**
- * Called when a channel is marked as not being in private mode.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- */
- @Override
- protected void onRemovePrivate( String channel,
- String sourceNick,
- String sourceLogin,
- String sourceHostname)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- // TODO: Implement IrcStack.onRemovePrivate().
- }
-
- /**
- * Called when a channel has 'secret' mode removed.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- */
- @Override
- protected void onRemoveSecret( String channel,
- String sourceNick,
- String sourceLogin,
- String sourceHostname)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- // TODO: Implement IrcStack.onRemoveSecret().
- }
-
- /**
- * Called when topic protection is removed for a channel.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- */
- @Override
- protected void onRemoveTopicProtection(String channel, String sourceNick,
- String sourceLogin, String sourceHostname)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- // TODO: Implement IrcStack.onRemoveSecret().
- }
-
- /**
- *
- * @param code The three-digit numerical code for the response.
- * @param response The full response from the IRC server.
- *
- * @see ReplyConstants
- */
- @Override
- protected void onServerResponse (int code, String response)
- {
- if (code == ERR_NOSUCHCHANNEL)
- {
- logger.error("No such channel:" + code
- + ": Response :" + response);
-
- this.notifyChatRoomOperation(ERR_NOSUCHCHANNEL);
- }
- else if (code == ERR_BADCHANMASK)
- {
- logger.error("Bad channel mask :" + code
- + ": Response :" + response);
-
- this.notifyChatRoomOperation(ERR_BADCHANMASK);
- }
- else if (code == ERR_BADCHANNELKEY)
- {
- logger.error("Bad channel key :" + code
- + ": Response :" + response);
-
- this.notifyChatRoomOperation(ERR_BADCHANNELKEY);
- }
- else if (code == ERR_BANNEDFROMCHAN)
- {
- logger.error("Banned from channel :" + code
- + ": Response :" + response);
-
- this.notifyChatRoomOperation(ERR_BANNEDFROMCHAN);
- }
- else if (code == ERR_CHANNELISFULL)
- {
- logger.error("Channel is full :" + code
- + ": Response :" + response);
-
- this.notifyChatRoomOperation(ERR_CHANNELISFULL);
- }
- else if (code == ERR_CHANOPRIVSNEEDED)
- {
- logger.error("Channel operator privilages needed :" + code
- + ": Response :" + response);
-
- this.notifyChatRoomOperation(ERR_CHANOPRIVSNEEDED);
- }
- else if (code == ERR_ERRONEUSNICKNAME)
- {
- logger.error("ERR_ERRONEUSNICKNAME :" + code
- + ": Response :" + response);
-
- this.notifyChatRoomOperation(ERR_ERRONEUSNICKNAME);
- }
- else if (code == ERR_INVITEONLYCHAN)
- {
- logger.error("Invite only channel :" + code
- + ": Response :" + response);
-
- this.notifyChatRoomOperation(ERR_INVITEONLYCHAN);
- }
- else if (code == ERR_NEEDMOREPARAMS)
- {
- logger.error("Need more params :" + code
- + ": Response :" + response);
-
- this.notifyChatRoomOperation(ERR_NEEDMOREPARAMS);
- }
- else if (code == ERR_NICKCOLLISION)
- {
- logger.error("Nick collision :" + code
- + ": Response :" + response);
-
- this.notifyChatRoomOperation(ERR_NICKCOLLISION);
- }
- else if (code == ERR_NICKNAMEINUSE)
- {
- logger.error("Nickname in use :" + code
- + ": Response :" + response);
-
- this.notifyChatRoomOperation(ERR_NICKNAMEINUSE);
- }
- else if (code == ERR_NONICKNAMEGIVEN)
- {
- logger.error("No nickname given :" + code
- + ": Response :" + response);
-
- this.notifyChatRoomOperation(ERR_NONICKNAMEGIVEN);
- }
- else if (code == ERR_NOTONCHANNEL)
- {
- logger.error("Not on channel :" + code
- + ": Response :" + response);
-
- this.notifyChatRoomOperation(ERR_NOTONCHANNEL);
- }
- else if (code == ERR_TOOMANYCHANNELS)
- {
- logger.error("Too many channels :" + code
- + ": Response :" + response);
-
- this.notifyChatRoomOperation(ERR_TOOMANYCHANNELS);
- }
- // reply responses
- else if (code == RPL_WHOISUSER)
- {
- StringTokenizer tokenizer = new StringTokenizer(response);
- tokenizer.nextToken();
-
- String nickname = tokenizer.nextToken();
- String login = tokenizer.nextToken();
- String hostname = tokenizer.nextToken();
-
- UserInfo userInfo = new UserInfo(nickname, login, hostname);
-
- this.userInfoTable.put(nickname, userInfo);
- }
- else if (code == RPL_WHOISSERVER)
- {
- StringTokenizer tokenizer = new StringTokenizer(response);
- tokenizer.nextToken();
- String userNickName = tokenizer.nextToken();
-
- int end = response.indexOf(':');
- String serverInfo = response.substring(end + 1);
-
- if (userInfoTable.containsKey(userNickName))
- {
- userInfoTable.get(userNickName).setServerInfo(serverInfo);
- }
- }
- else if (code == RPL_WHOISOPERATOR)
- {
- StringTokenizer tokenizer = new StringTokenizer(response);
- tokenizer.nextToken();
- String userNickName = tokenizer.nextToken();
-
- if (userInfoTable.containsKey(userNickName))
- {
- userInfoTable.get(userNickName).setIrcOp(true);
- }
- }
- else if (code == RPL_WHOISIDLE)
- {
- StringTokenizer tokenizer = new StringTokenizer(response);
- tokenizer.nextToken();
- String userNickName = tokenizer.nextToken();
- long idle = Long.parseLong(tokenizer.nextToken());
-
- if (userInfoTable.containsKey(userNickName))
- {
- userInfoTable.get(userNickName).setIdle(idle);
- }
- }
- else if (code == RPL_WHOISCHANNELS)
- {
- StringTokenizer tokenizer = new StringTokenizer(response);
- tokenizer.nextToken();
- String userNickName = tokenizer.nextToken();
-
- if (userInfoTable.containsKey(userNickName))
- {
- userInfoTable.get(userNickName).clearJoinedChatRoom();
-
- while(tokenizer.hasMoreTokens())
- {
- String channel = tokenizer.nextToken();
-
- if(channel.startsWith(":"))
- channel = channel.substring(1);
-
- userInfoTable.get(userNickName).addJoinedChatRoom(channel);
- }
- }
- }
- else if (code == RPL_ENDOFWHOIS)
- {
- StringTokenizer tokenizer = new StringTokenizer(response);
- tokenizer.nextToken();
- String userNickName = tokenizer.nextToken();
-
- if (userInfoTable.containsKey(userNickName))
- {
- UserInfo userInfo = userInfoTable.get(userNickName);
-
- this.onWhoIs(userInfo);
- }
- }
- else if (code == RPL_ENDOFMOTD)
- {
- this.isInitialized = true;
-
- ChatRoom[] joinCacheCopy
- = joinCache.toArray(new ChatRoom[joinCache.size()]);
-
- joinCache.clear();
-
- for (ChatRoom joinCacheElement : joinCacheCopy)
- {
- this.join(joinCacheElement);
- }
- }
- else if (code != RPL_LISTSTART
- && code != RPL_LIST
- && code != RPL_LISTEND
- && code != RPL_ENDOFNAMES)
- {
- if (logger.isTraceEnabled())
- logger.trace(
- "Server response: Code : "
- + code
- + " Response : "
- + response);
-
- int delimiterIndex = response.indexOf(':');
-
- if(delimiterIndex != -1 && delimiterIndex < response.length() - 1)
- response = response.substring(delimiterIndex + 1);
-
- MessageIrcImpl message
- = new MessageIrcImpl(
- response,
- MessageIrcImpl.DEFAULT_MIME_TYPE,
- MessageIrcImpl.DEFAULT_MIME_ENCODING,
- null);
-
- ChatRoomIrcImpl serverRoom = ircMUCOpSet.findSystemRoom();
-
- ChatRoomMember serverMember = ircMUCOpSet.findSystemMember();
-
- serverRoom.fireMessageReceivedEvent(
- message,
- serverMember,
- new Date(),
- ChatRoomMessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED);
- }
- }
-
- /**
- * Called when a user (possibly us) gets banned from a channel. Being
- * banned from a channel prevents any user with a matching host mask from
- * joining the channel. For this reason, most bans are usually directly
- * followed by the user being kicked .
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- * @param hostmask The host mask of the user that has been banned.
- */
- @Override
- protected void onSetChannelBan( String channel,
- String sourceNick,
- String sourceLogin,
- String sourceHostname,
- String hostmask)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- // TODO: Implement IrcStack.onSetChannelBan().
- }
-
- /**
- * Called when a channel key is set. When the channel key has been set,
- * other users may only join that channel if they know the key. Channel
- * keys are sometimes referred to as passwords.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- * @param key The new key for the channel.
- */
- @Override
- protected void onSetChannelKey(String channel, String sourceNick,
- String sourceLogin, String sourceHostname, String key)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- // TODO: Implement IrcStack.onSetChannelKey().
- }
-
- /**
- * Called when a user limit is set for a channel. The number of users in
- * the channel cannot exceed this limit.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- * @param limit The maximum number of users that may be in this channel at
- * the same time.
- */
- @Override
- protected void onSetChannelLimit( String channel,
- String sourceNick,
- String sourceLogin,
- String sourceHostname,
- int limit)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- // TODO: Implement IrcStack.onSetChannelLimit().
- }
-
- /**
- * Called when a channel is set to 'invite only' mode. A user may only
- * join the channel if they are invited by someone who is already in the
- * channel.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- */
- @Override
- protected void onSetInviteOnly( String channel,
- String sourceNick,
- String sourceLogin,
- String sourceHostname)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- // TODO: Implement IrcStack.onSetChannelLimit().
- }
-
- /**
- * Called when a channel is set to 'moderated' mode. If a channel is
- * moderated, then only users who have been 'voiced' or 'opp-ed' may speak
- * or change their nicks.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- */
- @Override
- protected void onSetModerated( String channel,
- String sourceNick,
- String sourceLogin,
- String sourceHostname)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- // TODO: Implement IrcStack.onSetModerated().
- }
-
- /**
- * Called when a channel is set to only allow messages from users that
- * are in the channel.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode
- * change.
- */
- @Override
- protected void onSetNoExternalMessages( String channel,
- String sourceNick,
- String sourceLogin,
- String sourceHostname)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- // TODO: Implement IrcStack.onSetNoExternalMessages().
- }
-
- /**
- * Called when a channel is marked as being in private mode.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- */
- @Override
- protected void onSetPrivate(String channel, String sourceNick,
- String sourceLogin, String sourceHostname)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- // TODO: Implement IrcStack.onSetPrivate().
- }
-
- /**
- * Called when a channel is set to be in 'secret' mode. Such channels
- * typically do not appear on a server's channel listing.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- */
- @Override
- protected void onSetSecret(String channel, String sourceNick,
- String sourceLogin, String sourceHostname)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- //TODO: Implement IrcStack.onSetPrivate().
- }
-
- /**
- * Called when topic protection is enabled for a channel. Topic protection
- * means that only operators in a channel may change the topic.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- */
- @Override
- protected void onSetTopicProtection(String channel, String sourceNick,
- String sourceLogin, String sourceHostname)
- {
- if (logger.isDebugEnabled())
- logger.debug("MODE on " + channel + ": Received from " + sourceNick
- + " " + sourceLogin + "@" + sourceHostname);
-
- //TODO: Implement IrcStack.onSetPrivate().
- }
-
- /**
- * This method is called whenever a user sets the topic, or when
- * PircBot joins a new channel and discovers its topic.
- *
- * @param channel The channel that the topic belongs to.
- * @param topic The topic for the channel.
- * @param setBy The nick of the user that set the topic.
- * @param date When the topic was set (milliseconds since the epoch).
- * @param changed True if the topic has just been changed, false if
- * the topic was already there.
- *
- */
- @Override
- protected void onTopic( String channel,
- String topic,
- String setBy,
- long date,
- boolean changed)
- {
- if (logger.isTraceEnabled())
- logger.trace("TOPIC on " + channel + ": " + topic + " setBy: "
- + setBy + " on: " + date);
-
- this.notifyChatRoomOperation(0);
-
- ChatRoomIrcImpl chatRoom = ircMUCOpSet.getChatRoom(channel);
-
- ChatRoomPropertyChangeEvent evt
- = new ChatRoomPropertyChangeEvent(
- chatRoom,
- ChatRoomPropertyChangeEvent.CHAT_ROOM_SUBJECT,
- chatRoom.getSubject(),
- topic);
-
- // After creating the event with the old and new value of the subject
- // we could change the subject property of the chat room.
- chatRoom.setSubjectFromServer(topic);
-
- chatRoom.firePropertyChangeEvent(evt);
- }
-
- /**
- * This method is called whenever we receive a line from the server that
- * the PircBot has not been programmed to recognize.
- *
- * @param line The raw line that was received from the server.
- */
- @Override
- protected void onUnknown(String line)
- {
- if (logger.isTraceEnabled())
- logger.trace("Unknown message received from the server : " + line);
- }
-
- /**
- * This method is called when we receive a user list from the server
- * after joining a channel.
- *
- * @param channel The name of the channel.
- * @param users An array of User objects belonging to this channel.
- *
- * @see User
- */
- @Override
- protected void onUserList(String channel, User[] users)
- {
- if (logger.isDebugEnabled())
- logger.debug("NAMES on " + channel);
-
- ChatRoomIrcImpl chatRoom = ircMUCOpSet.getChatRoom(channel);
-
- chatRoom.clearChatRoomMemberList();
-
- for (User user : users)
- {
- String userPrefix = user.getPrefix();
- ChatRoomMemberRole newMemberRole;
-
- if (userPrefix.contains("@"))
- newMemberRole = ChatRoomMemberRole.ADMINISTRATOR;
- else if (userPrefix.contains("%"))
- newMemberRole = ChatRoomMemberRole.MODERATOR;
- else if (userPrefix.contains("+"))
- newMemberRole = ChatRoomMemberRole.MEMBER;
- else
- newMemberRole = ChatRoomMemberRole.GUEST;
-
- ChatRoomMemberIrcImpl newMember
- = new ChatRoomMemberIrcImpl(parentProvider,
- chatRoom,
- user.getNick(),
- newMemberRole);
-
- chatRoom.addChatRoomMember(user.getNick(), newMember);
-
- chatRoom.fireMemberPresenceEvent(
- newMember,
- null,
- ChatRoomMemberPresenceChangeEvent.MEMBER_JOINED,
- ChatRoomMemberPresenceChangeEvent.REASON_USER_LIST);
- }
- }
-
- /**
- * Called when a user (possibly us) gets voice status granted in a channel.
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The host name of the user that performed the mode
- * change.
- * @param recipient The nick of the user that got 'voiced'.
- */
- @Override
- protected void onVoice(String channel, String sourceNick,
- String sourceLogin, String sourceHostname, String recipient)
- {
- if (logger.isDebugEnabled())
- logger.debug("VOICE on " + channel + ": Received from "
- + sourceNick + " " + sourceLogin + "@" + sourceHostname + "on "
- + recipient);
-
- ChatRoomIrcImpl chatRoom = ircMUCOpSet.getChatRoom(channel);
-
- if (chatRoom == null || !chatRoom.isJoined())
- return;
-
- ChatRoomMember sourceMember = chatRoom.getChatRoomMember(sourceNick);
-
- if (sourceMember == null)
- return;
-
- chatRoom.fireMemberRoleEvent( sourceMember,
- ChatRoomMemberRole.GUEST);
- }
-
- /**
- * Returns the list of chat rooms on this server.
- *
- * @return the list of chat rooms on this server
- */
+
public List