Package com.brewtab.irc

Examples of com.brewtab.irc.User


    public static MessageFilter prefix(final User user) {
        return new MessageFilter() {
            @Override
            public boolean check(Message message) {
                User other = User.fromPrefix(message.getPrefix());

                if (other == null) {
                    return false;
                }

                if (user == null) {
                    return true;
                }

                String nick = user.getNick();
                if (nick != null && !nick.equals(other.getNick())) {
                    return false;
                }

                String username = user.getUser();
                if (username != null && !username.equals(other.getUser())) {
                    return false;
                }

                String host = user.getHost();
                if (host != null && !host.equals(other.getHost())) {
                    return false;
                }

                return true;
            }
View Full Code Here


        @Override
        public void run() {
            initClient();

            User user = new User(nick);

            while (running) {
                final LogLine line;

                try {
View Full Code Here

        this.listeners.add(listener);
    }

    @Override
    public void onMessage(Message message) {
        User user = User.fromPrefix(message.getPrefix());

        switch (message.getType()) {
        case JOIN:
            /* Must have valid user prefix */
            if (user == null) {
                break;
            }

            /*
             * Once we've received a join message from the server we ourselves
             * have actually joined
             */
            this.joined.countDown();

            /* Add user to names list */
            if (!this.names.contains(user.getNick())) {
                this.names.add(user.getNick());
            }

            /* Call listeners */
            for (ChannelListener listener : this.listeners) {
                listener.onJoin(this, user);
            }
            break;

        case PART:
            /* Must have valid user prefix */
            if (user == null) {
                break;
            }

            /* Remove nick from names list */
            if (this.names.contains(user.getNick())) {
                this.names.remove(user.getNick());
            }

            /* Call listeners */
            for (ChannelListener listener : this.listeners) {
                listener.onPart(this, user);
            }
            break;

        case PRIVMSG:
            /* Must have valid user prefix */
            if (user == null) {
                break;
            }

            /* Call listeners */
            for (ChannelListener listener : this.listeners) {
                listener.onMessage(this, user, message.getArgs()[1]);
            }
            break;

        case QUIT:
            /* Must have valid user prefix */
            if (user == null) {
                break;
            }

            /* Remove nick from names list */
            if (this.names.contains(user.getNick())) {
                this.names.remove(user.getNick());
            }

            /* Call listeners */
            for (ChannelListener listener : this.listeners) {
                listener.onQuit(this, user);
            }
            break;

        case NICK:
            /* Must have valid user prefix */
            if (user == null) {
                break;
            }

            /* Replace nick in names list */
            if (this.names.contains(user.getNick())) {
                this.names.remove(user.getNick());
                this.names.add(message.getArgs()[0]);
            }
            break;

        default:
View Full Code Here

TOP

Related Classes of com.brewtab.irc.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.