Beispiel #1
0
 internal QuitEventArgs(IrcMessageData data, string who, string quitmessage)
     : base(data)
 {
     _Who = who;
     _QuitMessage = quitmessage;
 }
Beispiel #2
0
 internal TopicEventArgs(IrcMessageData data, string channel, string topic)
     : base(data)
 {
     _Channel = channel;
     _Topic = topic;
 }
Beispiel #3
0
        /// <summary>
        /// Event handler for welcome reply messages
        /// </summary>
        /// <remark>
        /// Upon success, the client will receive an RPL_WELCOME (for users) or
        /// RPL_YOURESERVICE (for services) message indicating that the
        /// connection is now registered and known the to the entire IRC network.
        /// The reply message MUST contain the full client identifier upon which
        /// it was registered.
        /// </remark>
        /// <param name="ircdata">Message data containing reply information</param>
        private void _Event_RPL_WELCOME(IrcMessageData ircdata)
        {
            // updating our nickname, that we got (maybe cutted...)
            _Nickname = ircdata.RawMessageArray[2];

            if (OnRegistered != null) {
                OnRegistered(this, EventArgs.Empty);
            }
        }
Beispiel #4
0
 internal AwayEventArgs(IrcMessageData data, string who, string awaymessage)
     : base(data)
 {
     _Who = who;
     _AwayMessage = awaymessage;
 }
Beispiel #5
0
 internal NickChangeEventArgs(IrcMessageData data, string oldnick, string newnick) : base(data)
 {
     _OldNickname = oldnick;
     _NewNickname = newnick;
 }
Beispiel #6
0
 internal CtcpEventArgs(IrcMessageData data, string ctcpcmd, string ctcpparam) : base(data)
 {
     _CtcpCommand   = ctcpcmd;
     _CtcpParameter = ctcpparam;
 }
Beispiel #7
0
 /// <summary>
 /// Event handler for error messages
 /// </summary>
 /// <param name="ircdata">Message data containing error information</param>
 private void _Event_ERR(IrcMessageData ircdata)
 {
     if (OnErrorMessage != null) {
         OnErrorMessage(this, new IrcEventArgs(ircdata));
     }
 }
Beispiel #8
0
 internal PartEventArgs(IrcMessageData data, string channel, string who, string partmessage) : base(data)
 {
     _Channel     = channel;
     _Who         = who;
     _PartMessage = partmessage;
 }
Beispiel #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ircdata">Message data containing channel mode information</param>
        /// <param name="mode">Channel mode</param>
        /// <param name="parameter">List of supplied paramaters</param>
        private void _InterpretChannelMode(IrcMessageData ircdata, string mode, string parameter)
        {
            string[] parameters = parameter.Split(new char[] {' '});
            bool add       = false;
            bool remove    = false;
            int modelength = mode.Length;
            string temp;
            Channel channel = null;
            if (ActiveChannelSyncing) {
                channel = GetChannel(ircdata.Channel);
            }
            IEnumerator parametersEnumerator = parameters.GetEnumerator();
            // bring the enumerator to the 1. element
            parametersEnumerator.MoveNext();
            for (int i = 0; i < modelength; i++) {
                switch(mode[i]) {
                    case '-':
                        add = false;
                        remove = true;
                    break;
                    case '+':
                        add = true;
                        remove = false;
                    break;
                    case 'o':
                        temp = (string)parametersEnumerator.Current;
                        parametersEnumerator.MoveNext();

                        if (add) {
                            if (ActiveChannelSyncing) {
                                // sanity check
                                if (GetChannelUser(ircdata.Channel, temp) != null) {
                                    // update the op list
                                    try {
                                        channel.UnsafeOps.Add(temp, GetIrcUser(temp));
            #if LOG4NET
                                        Logger.ChannelSyncing.Debug("added op: "+temp+" to: "+ircdata.Channel);
            #endif
                                    } catch (ArgumentException) {
            #if LOG4NET
                                        Logger.ChannelSyncing.Debug("duplicate op: "+temp+" in: "+ircdata.Channel+" not added");
            #endif
                                    }

                                    // update the user op status
                                    ChannelUser cuser = GetChannelUser(ircdata.Channel, temp);
                                    cuser.IsOp = true;
            #if LOG4NET
                                    Logger.ChannelSyncing.Debug("set op status: " + temp + " for: "+ircdata.Channel);
            #endif
                                } else {
            #if LOG4NET
                                    Logger.ChannelSyncing.Error("_InterpretChannelMode(): GetChannelUser(" + ircdata.Channel + "," + temp + ") returned null! Ignoring...");
            #endif
                                }
                            }

                            if (OnOp != null) {
                                OnOp(this, new OpEventArgs(ircdata, ircdata.Channel, ircdata.Nick, temp));
                            }
                        }
                        if (remove) {
                            if (ActiveChannelSyncing) {
                                // sanity check
                                if (GetChannelUser(ircdata.Channel, temp) != null) {
                                    // update the op list
                                    channel.UnsafeOps.Remove(temp);
            #if LOG4NET
                                    Logger.ChannelSyncing.Debug("removed op: "+temp+" from: "+ircdata.Channel);
            #endif
                                    // update the user op status
                                    ChannelUser cuser = GetChannelUser(ircdata.Channel, temp);
                                    cuser.IsOp = false;
            #if LOG4NET
                                    Logger.ChannelSyncing.Debug("unset op status: " + temp + " for: "+ircdata.Channel);
            #endif
                                } else {
            #if LOG4NET
                                    Logger.ChannelSyncing.Error("_InterpretChannelMode(): GetChannelUser(" + ircdata.Channel + "," + temp + ") returned null! Ignoring...");
            #endif
                                }
                            }

                            if (OnDeop != null) {
                                OnDeop(this, new DeopEventArgs(ircdata, ircdata.Channel, ircdata.Nick, temp));
                            }
                        }
                    break;
                    case 'h':
                        if (SupportNonRfc) {
                            temp = (string)parametersEnumerator.Current;
                            parametersEnumerator.MoveNext();

                            if (add) {
                                if (ActiveChannelSyncing) {
                                    // sanity check
                                    if (GetChannelUser(ircdata.Channel, temp) != null) {
                                        // update the halfop list
                                        try {
                                            ((NonRfcChannel)channel).UnsafeHalfops.Add(temp, GetIrcUser(temp));
            #if LOG4NET
                                            Logger.ChannelSyncing.Debug("added halfop: "+temp+" to: "+ircdata.Channel);
            #endif
                                        } catch (ArgumentException) {
            #if LOG4NET
                                            Logger.ChannelSyncing.Debug("duplicate halfop: "+temp+" in: "+ircdata.Channel+" not added");
            #endif
                                        }

                                        // update the user halfop status
                                        NonRfcChannelUser cuser = (NonRfcChannelUser)GetChannelUser(ircdata.Channel, temp);
                                        cuser.IsHalfop = true;
            #if LOG4NET
                                        Logger.ChannelSyncing.Debug("set halfop status: " + temp + " for: "+ircdata.Channel);
            #endif
                                    } else {
            #if LOG4NET
                                        Logger.ChannelSyncing.Error("_InterpretChannelMode(): GetChannelUser(" + ircdata.Channel + "," + temp + ") returned null! Ignoring...");
            #endif
                                    }
                                }

                                if (OnHalfop != null) {
                                    OnHalfop(this, new HalfopEventArgs(ircdata, ircdata.Channel, ircdata.Nick, temp));
                                }
                            }
                            if (remove) {
                                if (ActiveChannelSyncing) {
                                    // sanity check
                                    if (GetChannelUser(ircdata.Channel, temp) != null) {
                                        // update the halfop list
                                        ((NonRfcChannel)channel).UnsafeHalfops.Remove(temp);
            #if LOG4NET
                                        Logger.ChannelSyncing.Debug("removed halfop: "+temp+" from: "+ircdata.Channel);
            #endif
                                        // update the user halfop status
                                        NonRfcChannelUser cuser = (NonRfcChannelUser)GetChannelUser(ircdata.Channel, temp);
                                        cuser.IsHalfop = false;
            #if LOG4NET
                                        Logger.ChannelSyncing.Debug("unset halfop status: " + temp + " for: "+ircdata.Channel);
            #endif
                                    } else {
            #if LOG4NET
                                        Logger.ChannelSyncing.Error("_InterpretChannelMode(): GetChannelUser(" + ircdata.Channel + "," + temp + ") returned null! Ignoring...");
            #endif
                                    }
                                }

                                if (OnDehalfop != null) {
                                    OnDehalfop(this, new DehalfopEventArgs(ircdata, ircdata.Channel, ircdata.Nick, temp));
                                }
                            }
                        }
                    break;
                    case 'v':
                        temp = (string)parametersEnumerator.Current;
                        parametersEnumerator.MoveNext();

                        if (add) {
                            if (ActiveChannelSyncing) {
                                // sanity check
                                if (GetChannelUser(ircdata.Channel, temp) != null) {
                                    // update the voice list
                                    try {
                                        channel.UnsafeVoices.Add(temp, GetIrcUser(temp));
            #if LOG4NET
                                        Logger.ChannelSyncing.Debug("added voice: "+temp+" to: "+ircdata.Channel);
            #endif
                                    } catch (ArgumentException) {
            #if LOG4NET
                                        Logger.ChannelSyncing.Debug("duplicate voice: "+temp+" in: "+ircdata.Channel+" not added");
            #endif
                                    }

                                    // update the user voice status
                                    ChannelUser cuser = GetChannelUser(ircdata.Channel, temp);
                                    cuser.IsVoice = true;
            #if LOG4NET
                                    Logger.ChannelSyncing.Debug("set voice status: " + temp + " for: "+ircdata.Channel);
            #endif
                                } else {
            #if LOG4NET
                                    Logger.ChannelSyncing.Error("_InterpretChannelMode(): GetChannelUser(" + ircdata.Channel + "," + temp + ") returned null! Ignoring...");
            #endif
                                }
                            }

                            if (OnVoice != null) {
                                OnVoice(this, new VoiceEventArgs(ircdata, ircdata.Channel, ircdata.Nick, temp));
                            }
                        }
                        if (remove) {
                            if (ActiveChannelSyncing) {
                                // sanity check
                                if (GetChannelUser(ircdata.Channel, temp) != null) {
                                    // update the voice list
                                    channel.UnsafeVoices.Remove(temp);
            #if LOG4NET
                                    Logger.ChannelSyncing.Debug("removed voice: "+temp+" from: "+ircdata.Channel);
            #endif
                                    // update the user voice status
                                    ChannelUser cuser = GetChannelUser(ircdata.Channel, temp);
                                    cuser.IsVoice = false;
            #if LOG4NET
                                    Logger.ChannelSyncing.Debug("unset voice status: " + temp + " for: "+ircdata.Channel);
            #endif
                                } else {
            #if LOG4NET
                                    Logger.ChannelSyncing.Error("_InterpretChannelMode(): GetChannelUser(" + ircdata.Channel + "," + temp + ") returned null! Ignoring...");
            #endif
                                }
                            }

                            if (OnDevoice != null) {
                                OnDevoice(this, new DevoiceEventArgs(ircdata, ircdata.Channel, ircdata.Nick, temp));
                            }
                        }
                    break;
                    case 'b':
                        temp = (string)parametersEnumerator.Current;
                        parametersEnumerator.MoveNext();
                        if (add) {
                            if (ActiveChannelSyncing) {
                                try {
                                    channel.Bans.Add(temp);
            #if LOG4NET
                                    Logger.ChannelSyncing.Debug("added ban: "+temp+" to: "+ircdata.Channel);
            #endif
                                } catch (ArgumentException) {
            #if LOG4NET
                                    Logger.ChannelSyncing.Debug("duplicate ban: "+temp+" in: "+ircdata.Channel+" not added");
            #endif
                                }
                            }
                            if (OnBan != null) {
                               OnBan(this, new BanEventArgs(ircdata, ircdata.Channel, ircdata.Nick, temp));
                            }
                        }
                        if (remove) {
                            if (ActiveChannelSyncing) {
                                channel.Bans.Remove(temp);
            #if LOG4NET
                                Logger.ChannelSyncing.Debug("removed ban: "+temp+" from: "+ircdata.Channel);
            #endif
                            }
                            if (OnUnban != null) {
                                OnUnban(this, new UnbanEventArgs(ircdata, ircdata.Channel, ircdata.Nick, temp));
                            }
                        }
                    break;
                    case 'l':
                        temp = (string)parametersEnumerator.Current;
                        parametersEnumerator.MoveNext();
                        if (add) {
                            if (ActiveChannelSyncing) {
                                try {
                                    channel.UserLimit = int.Parse(temp);
            #if LOG4NET
                                    Logger.ChannelSyncing.Debug("stored user limit for: "+ircdata.Channel);
            #endif
                                } catch (FormatException) {
            #if LOG4NET
                                    Logger.ChannelSyncing.Error("could not parse user limit: "+temp+" channel: "+ircdata.Channel);
            #endif
                                }
                            }
                        }
                        if (remove) {
                            if (ActiveChannelSyncing) {
                                channel.UserLimit = 0;
            #if LOG4NET
                                Logger.ChannelSyncing.Debug("removed user limit for: "+ircdata.Channel);
            #endif
                            }
                        }
                    break;
                        case 'k':
                            temp = (string)parametersEnumerator.Current;
                            parametersEnumerator.MoveNext();
                            if (add) {
                                if (ActiveChannelSyncing) {
                                    channel.Key = temp;
            #if LOG4NET
                                    Logger.ChannelSyncing.Debug("stored channel key for: "+ircdata.Channel);
            #endif
                                }
                            }
                            if (remove) {
                                if (ActiveChannelSyncing) {
                                    channel.Key = "";
            #if LOG4NET
                                    Logger.ChannelSyncing.Debug("removed channel key for: "+ircdata.Channel);
            #endif
                                }
                            }
                        break;
                        default:
                            if (add) {
                                if (ActiveChannelSyncing) {
                                    channel.Mode += mode[i];
            #if LOG4NET
                                    Logger.ChannelSyncing.Debug("added channel mode ("+mode[i]+") for: "+ircdata.Channel);
            #endif
                                }
                            }
                            if (remove) {
                                if (ActiveChannelSyncing) {
                                    channel.Mode = channel.Mode.Replace(mode[i], new char());
            #if LOG4NET
                                    Logger.ChannelSyncing.Debug("removed channel mode ("+mode[i]+") for: "+ircdata.Channel);
            #endif
                                }
                            }
                        break;
                    }
                }
        }
Beispiel #10
0
        public IrcMessageData MessageParser(string rawline)
        {
            string         line;
            string[]       linear;
            string         messagecode;
            string         from;
            string         nick = null;
            string         ident = null;
            string         host = null;
            string         channel = null;
            string         message = null;
            ReceiveType    type;
            ReplyCode      replycode;
            int            exclamationpos;
            int            atpos;
            int            colonpos;

            if (rawline[0] == ':') {
                line = rawline.Substring(1);
            } else {
                line = rawline;
            }

            linear = line.Split(new char[] {' '});

            // conform to RFC 2812
            from = linear[0];
            messagecode = linear[1];
            exclamationpos = from.IndexOf("!");
            atpos = from.IndexOf("@");
            colonpos = line.IndexOf(" :");
            if (colonpos != -1) {
                // we want the exact position of ":" not beginning from the space
                colonpos += 1;
            }
            if (exclamationpos != -1) {
                nick = from.Substring(0, exclamationpos);
            }
            if ((atpos != -1) &&
                (exclamationpos != -1)) {
                ident = from.Substring(exclamationpos+1, (atpos - exclamationpos)-1);
            }
            if (atpos != -1) {
                host = from.Substring(atpos+1);
            }

            try {
                replycode = (ReplyCode)int.Parse(messagecode);
            } catch (FormatException) {
                replycode = ReplyCode.Null;
            }
            type = _GetMessageType(rawline);
            if (colonpos != -1) {
                message = line.Substring(colonpos+1);
            }

            switch (type) {
                case ReceiveType.Join:
                case ReceiveType.Kick:
                case ReceiveType.Part:
                case ReceiveType.TopicChange:
                case ReceiveType.ChannelModeChange:
                case ReceiveType.ChannelMessage:
                case ReceiveType.ChannelAction:
                case ReceiveType.ChannelNotice:
                    channel = linear[2];
                break;
                case ReceiveType.Who:
                case ReceiveType.Topic:
                case ReceiveType.Invite:
                case ReceiveType.BanList:
                case ReceiveType.ChannelMode:
                    channel = linear[3];
                break;
                case ReceiveType.Name:
                    channel = linear[4];
                break;
            }

            if ((channel != null) &&
                (channel[0] == ':')) {
                    channel = channel.Substring(1);
            }

            IrcMessageData data;
            data = new IrcMessageData(this, from, nick, ident, host, channel, message, rawline, type, replycode);
            #if LOG4NET
            Logger.MessageParser.Debug("IrcMessageData "+
                                       "nick: '"+data.Nick+"' "+
                                       "ident: '"+data.Ident+"' "+
                                       "host: '"+data.Host+"' "+
                                       "type: '"+data.Type.ToString()+"' "+
                                       "from: '"+data.From+"' "+
                                       "channel: '"+data.Channel+"' "+
                                       "message: '"+data.Message+"' "
                                       );
            #endif
            return data;
        }
Beispiel #11
0
        private void _HandleEvents(IrcMessageData ircdata)
        {
            if (OnRawMessage != null) {
                OnRawMessage(this, new IrcEventArgs(ircdata));
            }

            string code;
            // special IRC messages
            code = ircdata.RawMessageArray[0];
            switch (code) {
                case "PING":
                    _Event_PING(ircdata);
                break;
                case "ERROR":
                    _Event_ERROR(ircdata);
                break;
            }

            code = ircdata.RawMessageArray[1];
            switch (code) {
                case "PRIVMSG":
                    _Event_PRIVMSG(ircdata);
                break;
                case "NOTICE":
                    _Event_NOTICE(ircdata);
                break;
                case "JOIN":
                    _Event_JOIN(ircdata);
                break;
                case "PART":
                    _Event_PART(ircdata);
                break;
                case "KICK":
                    _Event_KICK(ircdata);
                break;
                case "QUIT":
                    _Event_QUIT(ircdata);
                break;
                case "TOPIC":
                    _Event_TOPIC(ircdata);
                break;
                case "NICK":
                    _Event_NICK(ircdata);
                break;
                case "INVITE":
                    _Event_INVITE(ircdata);
                break;
                case "MODE":
                    _Event_MODE(ircdata);
                break;
                case "PONG":
                    _Event_PONG(ircdata);
                break;
            }

            if (ircdata.ReplyCode != ReplyCode.Null) {
                switch (ircdata.ReplyCode) {
                    case ReplyCode.Welcome:
                        _Event_RPL_WELCOME(ircdata);
                    break;
                    case ReplyCode.Topic:
                        _Event_RPL_TOPIC(ircdata);
                    break;
                    case ReplyCode.NoTopic:
                        _Event_RPL_NOTOPIC(ircdata);
                    break;
                    case ReplyCode.NamesReply:
                        _Event_RPL_NAMREPLY(ircdata);
                    break;
                    case ReplyCode.EndOfNames:
                        _Event_RPL_ENDOFNAMES(ircdata);
                    break;
                    case ReplyCode.WhoReply:
                        _Event_RPL_WHOREPLY(ircdata);
                    break;
                    case ReplyCode.ChannelModeIs:
                        _Event_RPL_CHANNELMODEIS(ircdata);
                    break;
                    case ReplyCode.BanList:
                        _Event_RPL_BANLIST(ircdata);
                    break;
                    case ReplyCode.EndOfBanList:
                        _Event_RPL_ENDOFBANLIST(ircdata);
                    break;
                    case ReplyCode.Motd:
                        _Event_RPL_MOTD(ircdata);
                    break;
                    case ReplyCode.EndOfMotd:
                        _Event_RPL_ENDOFMOTD(ircdata);
                    break;
                    case ReplyCode.Away:
                        _Event_RPL_AWAY(ircdata);
                    break;
                    case ReplyCode.UnAway:
                        _Event_RPL_UNAWAY(ircdata);
                    break;
                    case ReplyCode.NowAway:
                        _Event_RPL_NOWAWAY(ircdata);
                    break;
                    case ReplyCode.ErrorNicknameInUse:
                        _Event_ERR_NICKNAMEINUSE(ircdata);
                    break;
                }
            }

            if (ircdata.Type == ReceiveType.ErrorMessage) {
                _Event_ERR(ircdata);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Event handler for topic messages
        /// </summary>
        /// <param name="ircdata">Message data containing topic information</param>
        private void _Event_TOPIC(IrcMessageData ircdata)
        {
            string who = ircdata.Nick;
            string channel = ircdata.Channel;
            string newtopic = ircdata.Message;

            if (ActiveChannelSyncing &&
                IsJoined(channel)) {
                GetChannel(channel).Topic = newtopic;
            #if LOG4NET
                Logger.ChannelSyncing.Debug("stored topic for channel: "+channel);
            #endif
            }

            if (OnTopicChange != null) {
                OnTopicChange(this, new TopicChangeEventArgs(ircdata, channel, who, newtopic));
            }
        }
Beispiel #13
0
        /// <summary>
        /// Event handler for who reply messages
        /// </summary>
        /// <param name="ircdata">Message data containing who reply information</param>
        private void _Event_RPL_WHOREPLY(IrcMessageData ircdata)
        {
            string channel  = ircdata.Channel;
            string ident    = ircdata.RawMessageArray[4];
            string host     = ircdata.RawMessageArray[5];
            string server   = ircdata.RawMessageArray[6];
            string nick     = ircdata.RawMessageArray[7];
            string usermode = ircdata.RawMessageArray[8];
            string realname = ircdata.Message.Substring(2);
            int    hopcount = 0;
            string temp     = ircdata.RawMessageArray[9].Substring(1);
            try {
                hopcount = int.Parse(temp);
            } catch (FormatException) {
            #if LOG4NET
                Logger.MessageParser.Warn("couldn't parse (as int): '"+temp+"'");
            #endif
            }

            bool op = false;
            bool voice = false;
            bool ircop = false;
            bool away = false;
            int usermodelength = usermode.Length;
            for (int i = 0; i < usermodelength; i++) {
                switch (usermode[i]) {
                    case 'H':
                        away = false;
                    break;
                    case 'G':
                        away = true;
                    break;
                    case '@':
                        op = true;
                    break;
                    case '+':
                        voice = true;
                    break;
                    case '*':
                        ircop = true;
                    break;
                }
            }

            if (ActiveChannelSyncing &&
                IsJoined(channel)) {
                // checking the irc and channel user I only do for sanity!
                // according to RFC they must be known to us already via RPL_NAMREPLY
                // psyBNC is not very correct with this... maybe other bouncers too
                IrcUser ircuser  = GetIrcUser(nick);
                ChannelUser channeluser = GetChannelUser(channel, nick);
            #if LOG4NET
                if (ircuser == null) {
                    Logger.ChannelSyncing.Error("GetIrcUser("+nick+") returned null in _Event_WHOREPLY! Ignoring...");
                }
            #endif

            #if LOG4NET
                if (channeluser == null) {
                    Logger.ChannelSyncing.Error("GetChannelUser("+nick+") returned null in _Event_WHOREPLY! Ignoring...");
                }
            #endif

                if (ircuser != null) {
            #if LOG4NET
                    Logger.ChannelSyncing.Debug("updating userinfo (from whoreply) for user: "******" channel: "+channel);
            #endif

                    ircuser.Ident    = ident;
                    ircuser.Host     = host;
                    ircuser.Server   = server;
                    ircuser.Nick     = nick;
                    ircuser.HopCount = hopcount;
                    ircuser.Realname = realname;
                    ircuser.IsAway   = away;
                    ircuser.IsIrcOp  = ircop;

                    switch (channel[0]) {
                        case '#':
                        case '!':
                        case '&':
                        case '+':
                            // this channel may not be where we are joined!
                            // see RFC 1459 and RFC 2812, it must return a channelname
                            // we use this channel info when possible...
                            if (channeluser != null) {
                                channeluser.IsOp    = op;
                                channeluser.IsVoice = voice;
                            }
                        break;
                    }
                }
            }

            if (OnWho != null) {
                OnWho(this, new WhoEventArgs(ircdata, channel, nick, ident, host, realname, away, op, voice, ircop, server, hopcount));
            }
        }
Beispiel #14
0
 internal PingEventArgs(IrcMessageData data, string pingdata) : base(data)
 {
     _PingData = pingdata;
 }
Beispiel #15
0
        /// <summary>
        /// Event handler for error messages
        /// </summary>
        /// <param name="ircdata">Message data containing error information</param>
        private void _Event_ERROR(IrcMessageData ircdata)
        {
            string message = ircdata.Message;
            #if LOG4NET
            Logger.Connection.Info("received ERROR from IRC server");
            #endif

            if (OnError != null) {
                OnError(this, new ErrorEventArgs(ircdata, message));
            }
        }
Beispiel #16
0
 internal NamesEventArgs(IrcMessageData data, string channel, string[] userlist) : base(data)
 {
     _Channel  = channel;
     _UserList = userlist;
 }
Beispiel #17
0
        /// <summary>
        /// Event handler for nickname in use error messages
        /// </summary>
        /// <param name="ircdata">Message data containing nickname in use error information</param>
        private void _Event_ERR_NICKNAMEINUSE(IrcMessageData ircdata)
        {
            #if LOG4NET
            Logger.Connection.Warn("nickname collision detected, changing nickname");
            #endif
            if (!AutoNickHandling) {
                return;
            }

            string nickname;
            // if a nicklist has been given loop through the nicknames
            // if the upper limit of this list has been reached and still no nickname has registered
            // then generate a random nick
            if (_CurrentNickname == NicknameList.Length-1) {
                Random rand = new Random();
                int number = rand.Next(999);
                if (Nickname.Length > 5) {
                    nickname = Nickname.Substring(0, 5)+number;
                } else {
                    nickname = Nickname.Substring(0, Nickname.Length-1)+number;
                }
            } else {
                nickname = _NextNickname();
            }
            // change the nickname
            RfcNick(nickname, Priority.Critical);
        }
Beispiel #18
0
 internal ActionEventArgs(IrcMessageData data, string actionmsg) : base(data, "ACTION", actionmsg)
 {
     _ActionMessage = actionmsg;
 }
Beispiel #19
0
        /// <summary>
        /// Event handler for invite messages
        /// </summary>
        /// <param name="ircdata">Message data containing invite information</param>
        private void _Event_INVITE(IrcMessageData ircdata)
        {
            string channel = ircdata.Channel;
            string inviter = ircdata.Nick;

            if (AutoJoinOnInvite) {
                if (channel.Trim() != "0") {
                    RfcJoin(channel);
                }
            }

            if (OnInvite != null) {
                OnInvite(this, new InviteEventArgs(ircdata, channel, inviter));
            }
        }
Beispiel #20
0
 internal TopicChangeEventArgs(IrcMessageData data, string channel, string who, string newtopic) : base(data)
 {
     _Channel  = channel;
     _Who      = who;
     _NewTopic = newtopic;
 }
Beispiel #21
0
        /// <summary>
        /// Event handler for join messages
        /// </summary>
        /// <param name="ircdata">Message data containing join information</param>
        private void _Event_JOIN(IrcMessageData ircdata)
        {
            string who = ircdata.Nick;
            string channelname = ircdata.Channel;

            if (IsMe(who)) {
                _JoinedChannels.Add(channelname);
            }

            if (ActiveChannelSyncing) {
                Channel channel;
                if (IsMe(who)) {
                    // we joined the channel
            #if LOG4NET
                    Logger.ChannelSyncing.Debug("joining channel: "+channelname);
            #endif
                    if (SupportNonRfc) {
                        channel = new NonRfcChannel(channelname);
                    } else {
                        channel = new Channel(channelname);
                    }
                    _Channels.Add(channelname, channel);
                    // request channel mode
                    RfcMode(channelname);
                    // request wholist
                    RfcWho(channelname);
                    // request banlist
                    Ban(channelname);
                } else {
                    // someone else joined the channel
                    // request the who data
                    RfcWho(who);
                }

            #if LOG4NET
                Logger.ChannelSyncing.Debug(who+" joins channel: "+channelname);
            #endif
                channel = GetChannel(channelname);
                IrcUser ircuser = GetIrcUser(who);

                if (ircuser == null) {
                    ircuser = new IrcUser(who, this);
                    ircuser.Ident = ircdata.Ident;
                    ircuser.Host  = ircdata.Host;
                    _IrcUsers.Add(who, ircuser);
                }

                ChannelUser channeluser;
                if (SupportNonRfc) {
                    channeluser = new NonRfcChannelUser(channelname, ircuser);
                } else {
                    channeluser = new ChannelUser(channelname, ircuser);
                }
                channel.UnsafeUsers.Add(who, channeluser);
            }

            if (OnJoin != null) {
                OnJoin(this, new JoinEventArgs(ircdata, channelname, who));
            }
        }
Beispiel #22
0
 internal ErrorEventArgs(IrcMessageData data, string errormsg) : base(data)
 {
     _ErrorMessage = errormsg;
 }
Beispiel #23
0
 internal WhoEventArgs(IrcMessageData data, string channel, string nick, string ident, string host, string realname, bool away, bool op, bool voice, bool ircop, string server, int hopcount)
     : base(data)
 {
     _Channel = channel;
     _Nick = nick;
     _Ident = ident;
     _Host = host;
     _Realname = realname;
     _IsAway = away;
     _IsOp = op;
     _IsVoice = voice;
     _IsIrcOp = ircop;
     _Server = server;
     _HopCount = hopcount;
 }
Beispiel #24
0
 internal PingEventArgs(IrcMessageData data, string pingdata)
     : base(data)
 {
     _PingData = pingdata;
 }
Beispiel #25
0
 internal BanEventArgs(IrcMessageData data, string channel, string who, string hostmask)
     : base(data)
 {
     _Channel = channel;
     _Who = who;
     _Hostmask = hostmask;
 }
Beispiel #26
0
 internal PongEventArgs(IrcMessageData data, TimeSpan lag)
     : base(data)
 {
     _Lag = lag;
 }
Beispiel #27
0
 internal CtcpEventArgs(IrcMessageData data, string ctcpcmd, string ctcpparam)
     : base(data)
 {
     _CtcpCommand = ctcpcmd;
     _CtcpParameter = ctcpparam;
 }
Beispiel #28
0
 internal TopicChangeEventArgs(IrcMessageData data, string channel, string who, string newtopic)
     : base(data)
 {
     _Channel = channel;
     _Who = who;
     _NewTopic = newtopic;
 }
Beispiel #29
0
 internal ErrorEventArgs(IrcMessageData data, string errormsg)
     : base(data)
 {
     _ErrorMessage = errormsg;
 }
Beispiel #30
0
 internal MotdEventArgs(IrcMessageData data, string motdmsg) : base(data)
 {
     _MotdMessage = motdmsg;
 }
Beispiel #31
0
 internal JoinEventArgs(IrcMessageData data, string channel, string who)
     : base(data)
 {
     _Channel = channel;
     _Who = who;
 }
Beispiel #32
0
 internal PongEventArgs(IrcMessageData data, TimeSpan lag) : base(data)
 {
     _Lag = lag;
 }
Beispiel #33
0
 internal ActionEventArgs(IrcMessageData data, string actionmsg)
     : base(data, "ACTION", actionmsg)
 {
     _ActionMessage = actionmsg;
 }
Beispiel #34
0
 internal InviteEventArgs(IrcMessageData data, string channel, string who) : base(data)
 {
     _Channel = channel;
     _Who     = who;
 }
Beispiel #35
0
 internal KickEventArgs(IrcMessageData data, string channel, string who, string whom, string kickreason)
     : base(data)
 {
     _Channel = channel;
     _Who = who;
     _Whom = whom;
     _KickReason = kickreason;
 }
Beispiel #36
0
 internal QuitEventArgs(IrcMessageData data, string who, string quitmessage) : base(data)
 {
     _Who         = who;
     _QuitMessage = quitmessage;
 }
Beispiel #37
0
 internal MotdEventArgs(IrcMessageData data, string motdmsg)
     : base(data)
 {
     _MotdMessage = motdmsg;
 }
Beispiel #38
0
 internal AwayEventArgs(IrcMessageData data, string who, string awaymessage) : base(data)
 {
     _Who         = who;
     _AwayMessage = awaymessage;
 }
Beispiel #39
0
 internal NamesEventArgs(IrcMessageData data, string channel, string[] userlist)
     : base(data)
 {
     _Channel = channel;
     _UserList = userlist;
 }
Beispiel #40
0
 internal TopicEventArgs(IrcMessageData data, string channel, string topic) : base(data)
 {
     _Channel = channel;
     _Topic   = topic;
 }
Beispiel #41
0
 internal NickChangeEventArgs(IrcMessageData data, string oldnick, string newnick)
     : base(data)
 {
     _OldNickname = oldnick;
     _NewNickname = newnick;
 }
Beispiel #42
0
 internal UnbanEventArgs(IrcMessageData data, string channel, string who, string hostmask) : base(data)
 {
     _Channel  = channel;
     _Who      = who;
     _Hostmask = hostmask;
 }
Beispiel #43
0
 internal OpEventArgs(IrcMessageData data, string channel, string who, string whom)
     : base(data)
 {
     _Channel = channel;
     _Who = who;
     _Whom = whom;
 }
Beispiel #44
0
 internal DevoiceEventArgs(IrcMessageData data, string channel, string who, string whom) : base(data)
 {
     _Channel = channel;
     _Who     = who;
     _Whom    = whom;
 }
Beispiel #45
0
 internal PartEventArgs(IrcMessageData data, string channel, string who, string partmessage)
     : base(data)
 {
     _Channel = channel;
     _Who = who;
     _PartMessage = partmessage;
 }
Beispiel #46
0
 internal IrcEventArgs(IrcMessageData data)
 {
     _Data = data;
 }
Beispiel #47
0
 internal IrcEventArgs(IrcMessageData data)
 {
     _Data = data;
 }