Example #1
0
 public UserStatusChangeEventArgs(IRCUser pUser, IRCMessage pMsg, bool pJoined, bool pLeft, bool pKicked, bool pQuit)
 {
     newUser = pUser;
     message = pMsg;
     joined = pJoined;
     left = pLeft;
     kicked = pKicked;
     quit = pQuit;
 }
Example #2
0
        private void UserQuit(IRCNode pUserNode, IRCMessage pMessage)
        {
            // Get user from user-table
            IRCUser user = (IRCUser)users[pUserNode.Nickname.ToLower()];

            // trigger event if necessary
            if (UserStatusChanged != null)
                UserStatusChanged(this, new UserStatusChangeEventArgs(user, pMessage, false, false, false, true));

            // remove user from channel
            users.Remove(pUserNode.Nickname.ToLower());
        }
Example #3
0
        private void UserVoice(string pNickName, bool pVoiced, IRCMessage pMessage)
        {
            if (!IsUserInChannel(pNickName))
                return;

            // Get user from user-table
            IRCUser user = (IRCUser)users[pNickName.ToLower()];

            // update
            user.HasVoice = pVoiced;

            // trigger event if necessary
            if (UserStatusChanged != null)
                UserStatusChanged(this, new UserStatusChangeEventArgs(user, pMessage, false, false, false, false));
        }
Example #4
0
        private void UserKicked(IRCUser pUser, IRCMessage pMessage)
        {
            if (!IsUserInChannel(pUser.Nickname))
                return;

            // trigger event if necessary
            if (users.ContainsValue(pUser.Nickname.ToLower()))
            {
                if (UserStatusChanged != null)
                    UserStatusChanged(this, new UserStatusChangeEventArgs(pUser, pMessage, false, false, true, false));
            }

            // remove user from channel
            users.Remove(pUser.Nickname.ToLower());
        }
Example #5
0
        private void UserNickChange(string pOldNickName, string pNewNickName, IRCMessage pMessage)
        {
            if (!IsUserInChannel(pOldNickName))
                return;

            // Get user from user-table
            IRCUser user = (IRCUser)users[pOldNickName.ToLower()];

            // update
            user.Nickname = pNewNickName;
            users.Remove(pOldNickName.ToLower());
            users.Add(pNewNickName.ToLower(), user);

            // trigger event if necessary
            if (UserStatusChanged != null)
                UserStatusChanged(this, new UserStatusChangeEventArgs(user, pMessage, false, false, false, false));
        }
Example #6
0
        private void UserJoined(IRCNode pUserNode, IRCMessage pMessage)
        {
            // check if we joined ourselves
            if (pUserNode.Nickname.ToLower() == connection.Nickname.ToLower())
                return;

            // check if already in channel-user-list
            if (IsUserInChannel(pUserNode.Nickname))
                return;

            // add as new user in channel
            IRCUser newUser = new IRCUser(this, pUserNode);
            users.Add(pUserNode.Nickname, newUser);
            if (UserStatusChanged != null)  // trigger event if necessary
                UserStatusChanged(this, new UserStatusChangeEventArgs(newUser, pMessage, true, false, false, false));
        }
Example #7
0
 public MessageEventArgs(IRCMessage pMessage)
 {
     msg = pMessage;
 }
Example #8
0
 public CancelMessageEventArgs(IRCMessage message)
     : base(message)
 {
 }
Example #9
0
        /// <summary>
        /// Processes the given message, depending on who sent it and the
        /// contents
        /// </summary>
        /// <param name="pMsg">The incoming/outgoing message.</param>
        private void HandleMessage(IRCMessage pMsg)
        {
            if (pMsg.IsSenderLocal) // check the sender
            {
                if (SentMessage != null)
                {
                    SentMessage(this, new MessageEventArgs(pMsg));
                }
            }
            else
            {
                if (GotMessage != null)
                {
                    GotMessage(this, new MessageEventArgs(pMsg));
                }
            }

            switch (pMsg.MessageTypeID.ToUpper())
            {
                case IRCConstants.MSG_PING: //Server ping , respond to remain alive
                    {
                        SendMessage("PONG :" + pMsg.Body);
                        Debug.WriteLine(pMsg.Body, "Server Ping ponged");
                        break;
                    }

                case IRCConstants.MSG_NICK: //Nick change command from user
                    {
                        if (pMsg.IsSenderLocal)
                        {
                            if (pMsg.Body != "")
                                NicknameChanged(pMsg.Body);
                            else if (pMsg.Parameters.Count > 0)
                                NicknameChanged(pMsg.Parameters[0].ToString());
                        }
                        break;
                    }

                case IRCConstants.MSG_433: //Nickname is in use, try sending other nicks
                    {
                        Debug.WriteLine(pMsg.Body, "Nickname in use!");
                        if (!loggedIn)
                        {   // TODO: fix!
                            /*
                            if (_Nicks.Count > 0)
                            {
                                SendCommand("NICK " + _Nicks[0].ToString());
                                _Nicks.RemoveAt(0);
                            }
                            else
                            {
                                NicknameChanged("*");
                            }
                             * */
                        }
                        break;
                    }

                case IRCConstants.MSG_001: //Login success
                    {
                        loggedIn = true;
                        Debug.WriteLine(socket.RemoteHost, "Logged In to IRC Server.");
                        break;
                    }
            }
        }
Example #10
0
        public static IRCMessage Parse(string pRawMessage)
        {
            IRCMessage msg = new IRCMessage();

            // parse
            msg.rawText = pRawMessage;
            msg.body = GetBody(pRawMessage);
            msg.header = GetHeader(pRawMessage);
            msg.messageType = GetMessageType(msg.Header);
            msg.parameters = GetParameters(msg.Header);
            msg.sender = GetSender(msg.Header);
            msg.senderNode = msg.sender == "" ? null : new IRCNode(msg.sender);

            if (msg.Sender == "")   // no sender
                msg.messageType = msg.Header;

            return msg;
        }