private void OnNick(object sender, TokenEventArgs e) { if (NoColon(e.tokens[0]).Substring(0, nickname.Length).Equals(nickname)) { ChangeNick(e.tokens[2]); WriteLineA("main", $"<span class=\"info\">* Your nickname is now {nickname}</span>"); } }
private void OnPrivMsg(object sender, TokenEventArgs e) { string channelName = NoColon(e.tokens[2]).Remove(0, 1); // rem # if (windows.Contains(channelName)) { WriteLineA(channelName, $"<span class=\"chat_nick\"><{NoColon(e.tokens[0]).Split('!')[0]}></span> {NoColon(string.Join(" ", e.tokens.Skip(3).ToArray()))}"); canvas.BeginInvoke(new InvokeDelegate1(ChannelListNotify), channelName); } }
private void OnDefault(object sender, TokenEventArgs e) { if (!new List <string>() { "470", "333", "328", "366" }.Contains(e.tokens[1]) && e.tokens.Length > 2) { WriteLineA("main", $"-<span class=\"notice_nick\">Server</span>- {FormatString(e.tokens)}"); } }
private void OnQuit(object sender, TokenEventArgs e) { string nick = NoColon(e.tokens[0]).Split('!')[0]; string reason = ""; if (e.tokens[2] != null) { reason = NoColon(string.Join(" ", e.tokens.Skip(2).ToArray())); } canvas.BeginInvoke(new InvokeDelegate(QuittingUser), nick, reason); }
private void OnMode(object sender, TokenEventArgs e) { if (e.tokens[2].Equals(nickname)) { WriteLineA("main", $"<span class=\"info\">* {nickname} sets usermode {NoColon(e.tokens[3])}</span>"); } else { WriteLineA(e.tokens[2].Remove(0, 1), $"<span class=\"info\">* {NoColon(e.tokens[0]).Split('!')[0]} sets mode {string.Join(" ", e.tokens.Skip(3).ToArray())} for #{e.tokens[2].Remove(0, 1)}</span>"); } }
private void OnUser(object sender, TokenEventArgs e) { string channelName = e.tokens[4].Remove(0, 1); if (windows.Contains(channelName)) { e.tokens[5] = NoColon(e.tokens[5]); foreach (string u in e.tokens.Skip(5).Where(x => !string.IsNullOrEmpty(x)).ToArray()) { canvas.BeginInvoke(new InvokeDelegate(AddUserToList), channelName, u); } } }
private void OnPart(object sender, TokenEventArgs e) { string nick = NoColon(e.tokens[0]).Split('!')[0]; string win = e.tokens[2].Remove(0, 1); if (nick.Equals(nickname)) { WriteLineA(win, $"<span class=\"info\">* You have left #{win}</span>"); } else { canvas.BeginInvoke(new InvokeDelegate(OtherUserParted), nick, win); } }
private void OnJoin(object sender, TokenEventArgs e) { string channelName = NoColon(e.tokens[2]).Remove(0, 1); // rem # if (NoColon(e.tokens[0]).Substring(0, nickname.Length).Equals(nickname)) { windows.Add(channelName); canvas.BeginInvoke(new InvokeDelegate1(MakeWindow), channelName); WriteLineA(channelName, $"<span class=\"info\">* You have joined #{channelName}</span>"); } else if (windows.Contains(channelName)) { string nick = NoColon(e.tokens[0]).Split('!')[0]; WriteLineA(channelName, $"<span class=\"info\">* {nick} has joined #{channelName}</span>"); canvas.BeginInvoke(new InvokeDelegate(AddUserToList), channelName, nick); } }
// Events private void OnNotice(object sender, TokenEventArgs e) { WriteLineA("main", $"-<span class=\"notice_nick\">{e.tokens[0].Substring(1)}</span>- {FormatString(e.tokens)}"); }
private void OnTopic(object sender, TokenEventArgs e) { topics.Add(e.tokens[3].Remove(0, 1), NoColon(string.Join(" ", e.tokens.Skip(4).ToArray()))); }
protected virtual void RaiseTopicEvent(TokenEventArgs e) { TopicEvent?.Invoke(this, e); }
protected virtual void RaiseUserEvent(TokenEventArgs e) { UserEvent?.Invoke(this, e); }
protected virtual void RaiseDefaultEvent(TokenEventArgs e) { DefaultEvent?.Invoke(this, e); }
protected virtual void RaiseJoinEvent(TokenEventArgs e) { JoinEvent?.Invoke(this, e); }
protected virtual void RaisePartEvent(TokenEventArgs e) { PartEvent?.Invoke(this, e); }
protected virtual void RaiseSocketExceptionEvent(TokenEventArgs e) { SocketExceptionEvent?.Invoke(this, e); }
protected virtual void RaiseModeEvent(TokenEventArgs e) { ModeEvent?.Invoke(this, e); }
private void OnSocketException(object sender, TokenEventArgs e) { WriteLineA(e.tokens[0], $"<span class=\"info\">* Could not connect: {e.tokens[1]}</span>"); }
protected virtual void RaiseNickEvent(TokenEventArgs e) { NickEvent?.Invoke(this, e); }