/// <summary> /// Retrieve the modes for the specified channel. /// </summary> /// <param name="channel">The channel for which to retrieve modes.</param> public async Task ModeAsync(IrcTarget channel) { if (channel.IsChannel) { await SendAsync("MODE", channel); } }
private void OnMode(IrcMessage message) { if (message.Parameters.Count > 0) { if (IrcTarget.IsChannelName(message.Parameters[0])) { RaiseEvent(ChannelModeChanged, new IrcChannelModeEventArgs(message)); } else { var e = new IrcUserModeEventArgs(message); UserModes = (from m in e.Modes.Where(newMode => newMode.Set).Select(newMode => newMode.Mode).Union(UserModes).Distinct() where !e.Modes.Any(newMode => !newMode.Set && newMode.Mode == m) select m).ToArray(); RaiseEvent(UserModeChanged, new IrcUserModeEventArgs(message)); } } }
/// <summary> /// Send a notice to a user or channel. /// </summary> /// <param name="target">The user or channel that the notice will be delivered to.</param> /// <param name="text">The notice text.</param> public async Task NoticeAsync(IrcTarget target, string text) { await SendAsync("NOTICE", target, text); }
/// <summary> /// Send a private message to a user or channel. /// </summary> /// <param name="target">The user or channel that the message will be delivered to.</param> /// <param name="text">The message text.</param> public async Task PrivateMessageAsync(IrcTarget target, string text) { await SendAsync("PRIVMSG", target, text); }
/// <summary> /// Send a CTCP message to another client. /// </summary> /// <param name="target">The user to which the CTCP command will be delivered.</param> /// <param name="command">The CTCP command to send.</param> /// <param name="isResponse">Indicates whether the CTCP message is a response to a command that was received. This parameter /// is important for preventing an infinite back-and-forth loop between two clients.</param> public async Task SendCtcpAsync(IrcTarget target, CtcpCommand command, bool isResponse) { await SendAsync(isResponse? "NOTICE" : "PRIVMSG", target, command.ToString()); }
/// <summary> /// Send a message to the server. /// </summary> /// <param name="command">The name of the command.</param> /// <param name="target">The target of the command.</param> /// <param name="parameters">The optional command parameters.</param> public async Task SendAsync(string command, IrcTarget target, params string[] parameters) { await SendAsync(command, (new[] { target.ToString() }).Union(parameters).ToArray()); }
/// <summary> /// Determine whether the specified target refers to this session by comparing the nickname to the session's current nickname. /// </summary> /// <param name="target">The target to evaluate.</param> /// <returns>True if the target refers to this session, false otherwise.</returns> public bool IsSelf(IrcTarget target) { return(target != null && !target.IsChannel && string.Compare(target.Name, Nickname, StringComparison.OrdinalIgnoreCase) == 0); }
internal IrcJoinEventArgs(IrcMessage message) : base(message) { this.Who = message.From as IrcPeer; this.Channel = message.Parameters.Count > 0 ? new IrcTarget(message.Parameters[0]) : null; }