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; }
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()); }
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)); }
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()); }
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)); }
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)); }
public MessageEventArgs(IRCMessage pMessage) { msg = pMessage; }
public CancelMessageEventArgs(IRCMessage message) : base(message) { }
/// <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; } } }
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; }