public void On( ResponseEvent e ) { }
public void On( ResponseEvent e ) { if ( e.Code != ERR.NicknameInUse && e.YourNick != "*" ) { // The check against "*" is just paranoia -- it's what AfterNET uses on 433/NicknameInUse replies if our first NICK is in use, since we don't have a nick at that point, herp derp. if ( e.Code != "001" && CurrentNickname == null ) e.Connection.Send("WHOIS "+e.YourNick); // So that's who we are! Bloody amnesia. Find out more about ourselves. CurrentNickname = e.YourNick; } var arguments = e.ArgumentData; switch ( e.Code ) { case RPL.WhoIsChannels: // WhoIsChannels = "319", // "<nick> :{[@|+]<channel><space>}" var space1 = arguments.IndexOf(' '); var nick = arguments.Substring(0,space1); var colon = arguments.IndexOf(':'); var channels = arguments.Remove(0,colon==-1?(arguments.IndexOf(' ')+1):(colon+1)).Split(new[]{' '},StringSplitOptions.RemoveEmptyEntries).Select(ch=>ch.TrimStart(':','@','+')); if ( nick == CurrentNickname ) { foreach ( var channel in channels ) GetChannelInfo(channel).Joined = true; e.Connection.Send("NAMES "+String.Join(",",channels)); } break; case RPL.NamReply: // "<channel> :[[@|+]<nick> [[@|+]<nick> [...]]]" // "("="/"*"/"@") <channel> :["@"/"+"] <nick> *(" "["@"/"+"]<nick>)" var a = arguments.Split(' '); a = a.SkipWhile(b=>!b.StartsWith("#")).ToArray(); // skip over random * and =s AfterNET likes to throw into the argument list before channel name var c1 = GetChannelInfo(a[0]); if (a[1].StartsWith(":")) a[1] = a[1].Remove(0,1); foreach ( var name in a.Skip(1) ) { if ( name.Length>0 ) switch ( name[0] ) { case '@': c1.People.Add( new ChannelInfo.Person() { Sigil="@", NUH=new NUH(){Nick=name.Substring(1)} } ); break; case '+': c1.People.Add( new ChannelInfo.Person() { Sigil="+", NUH=new NUH(){Nick=name.Substring(1)} } ); break; default: c1.People.Add( new ChannelInfo.Person() { Sigil="" , NUH=new NUH(){Nick=name.Substring(0)} } ); break; } } break; } }