/// <summary> /// Event handler for PONG messages /// </summary> /// <param name="ircdata">Message data containing pong information</param> private void _Event_PONG(IrcMessageData ircdata) { if (OnPong != null) { OnPong(this, new PongEventArgs(ircdata, ircdata.Irc.Lag)); } }
/// <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)); } }
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; }
/// <summary> /// Event handler for mesage of the day reply messages /// </summary> /// <param name="ircdata">Message data containing mesage of the day information</param> private void _Event_RPL_MOTD(IrcMessageData ircdata) { if (!_MotdReceived) { _Motd.Add(ircdata.Message); } if (OnMotd != null) { OnMotd(this, new MotdEventArgs(ircdata, ircdata.Message)); } }
// TODO, need to sync with the banlist! private void _Event_RPL_BANLIST(IrcMessageData ircdata) { }
/// <summary> /// Event handler for away messages /// </summary> /// <param name="ircdata">Message data containing away reply information</param> private void _Event_RPL_AWAY(IrcMessageData ircdata) { string who = ircdata.RawMessageArray[3]; string awaymessage = ircdata.Message; if (ActiveChannelSyncing) { IrcUser ircuser = GetIrcUser(who); if (ircuser != null) { #if LOG4NET Logger.ChannelSyncing.Debug("setting away flag for user: "+who); #endif ircuser.IsAway = true; } } if (OnAway != null) { OnAway(this, new AwayEventArgs(ircdata, who, awaymessage)); } }
/// <summary> /// Event handler for nowaway messages /// </summary> /// <param name="ircdata">Message data containing nowaway reply information</param> private void _Event_RPL_NOWAWAY(IrcMessageData ircdata) { _IsAway = true; if (OnNowAway != null) { OnNowAway(this, new IrcEventArgs(ircdata)); } }
/// <summary> /// Event handler for private messages /// </summary> /// <param name="ircdata">Message data containing private message information</param> private void _Event_PRIVMSG(IrcMessageData ircdata) { if (ircdata.Type == ReceiveType.CtcpRequest) { if (ircdata.Message.StartsWith("\x1"+"PING")) { if (ircdata.Message.Length > 7) { SendMessage(SendType.CtcpReply, ircdata.Nick, "PING "+ircdata.Message.Substring(6, (ircdata.Message.Length-7))); } else { SendMessage(SendType.CtcpReply, ircdata.Nick, "PING"); } } else if (ircdata.Message.StartsWith("\x1"+"VERSION")) { string versionstring; if (_CtcpVersion == null) { versionstring = VersionString; } else { versionstring = _CtcpVersion; } SendMessage(SendType.CtcpReply, ircdata.Nick, "VERSION "+versionstring); } else if (ircdata.Message.StartsWith("\x1"+"CLIENTINFO")) { SendMessage(SendType.CtcpReply, ircdata.Nick, "CLIENTINFO PING VERSION CLIENTINFO"); } } switch (ircdata.Type) { case ReceiveType.ChannelMessage: if (OnChannelMessage != null) { OnChannelMessage(this, new IrcEventArgs(ircdata)); } break; case ReceiveType.ChannelAction: if (OnChannelAction != null) { string action = ircdata.Message.Substring(7, ircdata.Message.Length-8); OnChannelAction(this, new ActionEventArgs(ircdata, action)); } break; case ReceiveType.QueryMessage: if (OnQueryMessage != null) { OnQueryMessage(this, new IrcEventArgs(ircdata)); } break; case ReceiveType.QueryAction: if (OnQueryAction != null) { string action = ircdata.Message.Substring(7, ircdata.Message.Length-8); OnQueryAction(this, new ActionEventArgs(ircdata, action)); } break; case ReceiveType.CtcpRequest: if (OnCtcpRequest != null) { int space_pos = ircdata.Message.IndexOf(' '); string cmd = ""; string param = ""; if (space_pos != -1) { cmd = ircdata.Message.Substring(1, space_pos - 1); param = ircdata.Message.Substring(space_pos + 1, ircdata.Message.Length - space_pos - 2); } else { cmd = ircdata.Message.Substring(1, ircdata.Message.Length - 2); } OnCtcpRequest(this, new CtcpEventArgs(ircdata, cmd, param)); } break; } }
/// <summary> /// Event handler for notice messages /// </summary> /// <param name="ircdata">Message data containing notice information</param> private void _Event_NOTICE(IrcMessageData ircdata) { switch (ircdata.Type) { case ReceiveType.ChannelNotice: if (OnChannelNotice != null) { OnChannelNotice(this, new IrcEventArgs(ircdata)); } break; case ReceiveType.QueryNotice: if (OnQueryNotice != null) { OnQueryNotice(this, new IrcEventArgs(ircdata)); } break; case ReceiveType.CtcpReply: if (OnCtcpReply != null) { int space_pos = ircdata.Message.IndexOf(' '); string cmd = ""; string param = ""; if (space_pos != -1) { cmd = ircdata.Message.Substring(1, space_pos - 1); param = ircdata.Message.Substring(space_pos + 1, ircdata.Message.Length - space_pos - 2); } else { cmd = ircdata.Message.Substring(1, ircdata.Message.Length - 2); } OnCtcpReply(this, new CtcpEventArgs(ircdata, cmd, param)); } break; } }
/// <summary> /// Event handler for kick messages /// </summary> /// <param name="ircdata">Message data containing kick information</param> private void _Event_KICK(IrcMessageData ircdata) { string channelname = ircdata.Channel; string who = ircdata.Nick; string whom = ircdata.RawMessageArray[3]; string reason = ircdata.Message; bool isme = IsMe(whom); if (isme) { _JoinedChannels.Remove(channelname); } if (ActiveChannelSyncing) { if (isme) { Channel channel = GetChannel(channelname); _Channels.Remove(channelname); if (_AutoRejoinOnKick) { RfcJoin(channel.Name, channel.Key); } } else { _RemoveChannelUser(channelname, whom); _RemoveIrcUser(whom); } } else { if (isme && AutoRejoinOnKick) { RfcJoin(channelname); } } if (OnKick != null) { OnKick(this, new KickEventArgs(ircdata, channelname, who, whom, reason)); } }
/// <summary> /// Event handler for quit messages /// </summary> /// <param name="ircdata">Message data containing quit information</param> private void _Event_QUIT(IrcMessageData ircdata) { string who = ircdata.Nick; string reason = ircdata.Message; // no need to handle if we quit, disconnect event will take care if (ActiveChannelSyncing) { // sanity checks, freshirc is very broken about RFC IrcUser user = GetIrcUser(who); if (user != null) { string[] joined_channels = user.JoinedChannels; if (joined_channels != null) { foreach (string channel in joined_channels) { _RemoveChannelUser(channel, who); } _RemoveIrcUser(who); #if LOG4NET } else { Logger.ChannelSyncing.Error("user.JoinedChannels (for: '"+who+"') returned null in _Event_QUIT! Ignoring..."); #endif } #if LOG4NET } else { Logger.ChannelSyncing.Error("GetIrcUser("+who+") returned null in _Event_QUIT! Ignoring..."); #endif } } if (OnQuit != null) { OnQuit(this, new QuitEventArgs(ircdata, who, reason)); } }
/// <summary> /// Event handler for part messages /// </summary> /// <param name="ircdata">Message data containing part information</param> private void _Event_PART(IrcMessageData ircdata) { string who = ircdata.Nick; string channel = ircdata.Channel; string partmessage = ircdata.Message; if (IsMe(who)) { _JoinedChannels.Remove(channel); } if (ActiveChannelSyncing) { if (IsMe(who)) { #if LOG4NET Logger.ChannelSyncing.Debug("parting channel: "+channel); #endif _Channels.Remove(channel); } else { #if LOG4NET Logger.ChannelSyncing.Debug(who+" parts channel: "+channel); #endif _RemoveChannelUser(channel, who); _RemoveIrcUser(who); } } if (OnPart != null) { OnPart(this, new PartEventArgs(ircdata, channel, who, partmessage)); } }
/// <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)); } }
/// <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)); } }
/// <summary> /// Event handler for name reply messages /// </summary> /// <param name="ircdata">Message data containing name reply information</param> private void _Event_RPL_NAMREPLY(IrcMessageData ircdata) { string channelname = ircdata.Channel; string[] userlist = ircdata.MessageArray; if (ActiveChannelSyncing && IsJoined(channelname)) { string nickname; bool op; bool halfop; bool voice; foreach (string user in userlist) { if (user.Length <= 0) { continue; } op = false; halfop = false; voice = false; switch (user[0]) { case '@': op = true; nickname = user.Substring(1); break; case '+': voice = true; nickname = user.Substring(1); break; // RFC VIOLATION // some IRC network do this and break our channel sync... case '&': nickname = user.Substring(1); break; case '%': halfop = true; nickname = user.Substring(1); break; case '~': nickname = user.Substring(1); break; default: nickname = user; break; } IrcUser ircuser = GetIrcUser(nickname); ChannelUser channeluser = GetChannelUser(channelname, nickname); if (ircuser == null) { #if LOG4NET Logger.ChannelSyncing.Debug("creating IrcUser: "******" because he doesn't exist yet"); #endif ircuser = new IrcUser(nickname, this); _IrcUsers.Add(nickname, ircuser); } if (channeluser == null) { #if LOG4NET Logger.ChannelSyncing.Debug("creating ChannelUser: "******" for Channel: "+channelname+" because he doesn't exist yet"); #endif if (SupportNonRfc) { channeluser = new NonRfcChannelUser(channelname, ircuser); } else { channeluser = new ChannelUser(channelname, ircuser); } Channel channel = GetChannel(channelname); channel.UnsafeUsers.Add(nickname, channeluser); if (op) { channel.UnsafeOps.Add(nickname, channeluser); #if LOG4NET Logger.ChannelSyncing.Debug("added op: "+nickname+" to: "+channelname); #endif } if (SupportNonRfc && halfop) { ((NonRfcChannel)channel).UnsafeHalfops.Add(nickname, channeluser); #if LOG4NET Logger.ChannelSyncing.Debug("added halfop: "+nickname+" to: "+channelname); #endif } if (voice) { channel.UnsafeVoices.Add(nickname, channeluser); #if LOG4NET Logger.ChannelSyncing.Debug("added voice: "+nickname+" to: "+channelname); #endif } } channeluser.IsOp = op; channeluser.IsVoice = voice; if (SupportNonRfc) { ((NonRfcChannelUser)channeluser).IsHalfop = halfop; } } } if (OnNames != null) { OnNames(this, new NamesEventArgs(ircdata, channelname, userlist)); } }
/// <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)); } }
/// <summary> /// Event handler for end of names reply messages /// </summary> /// <param name="ircdata">Message data containing end of names reply information</param> private void _Event_RPL_ENDOFNAMES(IrcMessageData ircdata) { string channelname = ircdata.RawMessageArray[3]; if (ActiveChannelSyncing && IsJoined(channelname)) { #if LOG4NET Logger.ChannelSyncing.Debug("passive synced: "+channelname); #endif if (OnChannelPassiveSynced != null) { OnChannelPassiveSynced(this, new IrcEventArgs(ircdata)); } } }
/// <summary> /// Event handler for nickname messages /// </summary> /// <param name="ircdata">Message data containing nickname information</param> private void _Event_NICK(IrcMessageData ircdata) { string oldnickname = ircdata.Nick; string newnickname = ircdata.Message; if (IsMe(ircdata.Nick)) { // nickname change is your own _Nickname = newnickname; } if (ActiveChannelSyncing) { IrcUser ircuser = GetIrcUser(oldnickname); // if we don't have any info about him, don't update him! // (only queries or ourself in no channels) if (ircuser != null) { string[] joinedchannels = ircuser.JoinedChannels; // update his nickname ircuser.Nick = newnickname; // remove the old entry // remove first to avoid duplication, Foo -> foo _IrcUsers.Remove(oldnickname); // add him as new entry and new nickname as key _IrcUsers.Add(newnickname, ircuser); #if LOG4NET Logger.ChannelSyncing.Debug("updated nickname of: "+oldnickname+" to: "+newnickname); #endif // now the same for all channels he is joined Channel channel; ChannelUser channeluser; foreach (string channelname in joinedchannels) { channel = GetChannel(channelname); channeluser = GetChannelUser(channelname, oldnickname); // remove first to avoid duplication, Foo -> foo channel.UnsafeUsers.Remove(oldnickname); channel.UnsafeUsers.Add(newnickname, channeluser); if (channeluser.IsOp) { channel.UnsafeOps.Remove(oldnickname); channel.UnsafeOps.Add(newnickname, channeluser); } if (SupportNonRfc && ((NonRfcChannelUser)channeluser).IsHalfop) { NonRfcChannel nchannel = (NonRfcChannel)channel; nchannel.UnsafeHalfops.Remove(oldnickname); nchannel.UnsafeHalfops.Add(newnickname, channeluser); } if (channeluser.IsVoice) { channel.UnsafeVoices.Remove(oldnickname); channel.UnsafeVoices.Add(newnickname, channeluser); } } } } if (OnNickChange != null) { OnNickChange(this, new NickChangeEventArgs(ircdata, oldnickname, newnickname)); } }
/// <summary> /// Event handler for unaway messages /// </summary> /// <param name="ircdata">Message data containing unaway reply information</param> private void _Event_RPL_UNAWAY(IrcMessageData ircdata) { _IsAway = false; if (OnUnAway != null) { OnUnAway(this, new IrcEventArgs(ircdata)); } }
/// <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)); } }
/// <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)); } }
/// <summary> /// Event handler for mode messages /// </summary> /// <param name="ircdata">Message data containing mode information</param> private void _Event_MODE(IrcMessageData ircdata) { if (IsMe(ircdata.RawMessageArray[2])) { // my user mode changed _Usermode = ircdata.RawMessageArray[3].Substring(1); } else { // channel mode changed string mode = ircdata.RawMessageArray[3]; string parameter = String.Join(" ", ircdata.RawMessageArray, 4, ircdata.RawMessageArray.Length-4); _InterpretChannelMode(ircdata, mode, parameter); } if ((ircdata.Type == ReceiveType.UserModeChange) && (OnUserModeChange != null)) { OnUserModeChange(this, new IrcEventArgs(ircdata)); } if ((ircdata.Type == ReceiveType.ChannelModeChange) && (OnChannelModeChange != null)) { OnChannelModeChange(this, new IrcEventArgs(ircdata)); } if (OnModeChange != null) { OnModeChange(this, new IrcEventArgs(ircdata)); } }
/// <summary> /// Event handler for end of mesage of the day reply messages /// </summary> /// <param name="ircdata">Message data containing end of mesage of the day information</param> private void _Event_RPL_ENDOFMOTD(IrcMessageData ircdata) { _MotdReceived = true; }
/// <summary> /// Event handler for channel mode reply messages /// </summary> /// <param name="ircdata">Message data containing reply information</param> private void _Event_RPL_CHANNELMODEIS(IrcMessageData ircdata) { if (ActiveChannelSyncing && IsJoined(ircdata.Channel)) { string mode = ircdata.RawMessageArray[4]; string parameter = String.Join(" ", ircdata.RawMessageArray, 5, ircdata.RawMessageArray.Length-5); _InterpretChannelMode(ircdata, mode, parameter); } }
private void _Event_RPL_ENDOFBANLIST(IrcMessageData ircdata) { string channelname = ircdata.Channel; if (ActiveChannelSyncing && IsJoined(channelname)) { Channel channel = GetChannel(channelname); channel.ActiveSyncStop = DateTime.Now; #if LOG4NET Logger.ChannelSyncing.Debug("active synced: "+channelname+ " (in "+channel.ActiveSyncTime.TotalSeconds+" sec)"); #endif if (OnChannelActiveSynced != null) { OnChannelActiveSynced(this, new IrcEventArgs(ircdata)); } } }
/// <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); } }
/// <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); }
/// <summary> /// Event handler for topic reply messages == null /// </summary> /// <param name="ircdata">Message data containing topic information</param> private void _Event_RPL_NOTOPIC(IrcMessageData ircdata) { string channel = ircdata.Channel; if (ActiveChannelSyncing && IsJoined(channel)) { GetChannel(channel).Topic = ""; #if LOG4NET Logger.ChannelSyncing.Debug("stored empty topic for channel: "+channel); #endif } if (OnTopic != null) { OnTopic(this, new TopicEventArgs(ircdata, channel, "")); } }
internal IrcEventArgs(IrcMessageData data) { _Data = data; }
// <internal messagehandler> /// <summary> /// Event handler for ping messages /// </summary> /// <param name="ircdata">Message data containing ping information</param> private void _Event_PING(IrcMessageData ircdata) { string server = ircdata.RawMessageArray[1].Substring(1); #if LOG4NET Logger.Connection.Debug("Ping? Pong!"); #endif RfcPong(server, Priority.Critical); if (OnPing != null) { OnPing(this, new PingEventArgs(ircdata, server)); } }