/// <summary> /// Attempts to ban the specified <see cref="IrcUser"/> from the <see cref="IrcChannel"/>. /// </summary> /// <param name="user">The <see cref="IrcUser"/>.</param> /// <param name="alsoKick">Optional. Whether the <see cref="IrcUser"/> should also be kicked out of the channel. True by default.</param> /// <param name="kickReason">Optional. If the <paramref name="alsoKick"/> parameter is set to true, the reason for the kick, if any.</param> /// <remarks>This method will only work if the current user is an operator on the <see cref="IrcChannel"/>.</remarks> public void BanUser(IrcUser user, bool alsoKick = true, string kickReason = "") { Validate.IsNotNull(user, "user"); Validate.IsNotNull(kickReason, "kickReason"); // MODE <channel name> +b <user name> this.Send("MODE", this.FullName, "+b", user.Nickname); if (alsoKick) { this.KickUser(user, kickReason); } }
/// <summary> /// Adds or removes a mode from the specified <see cref="IrcUser"/>'s mode on the <see cref="IrcChannel"/>. /// This method should be used for actual mode changes made using the MODE command. /// </summary> internal void AddOrRemoveUserMode(IrcUser user, bool add, char modeChar) { IrcChannelUserModes mode; if (!this.Network.Parameters.ChannelModes.UserModes.TryGetValue(modeChar, out mode)) { return; } if (add) { this.UserModes[user] |= mode; } else { this.UserModes[user] &= ~mode; } }
/// <summary> /// Gets a known <see cref="IrcUser"/> from their name. /// </summary> /// <param name="nickname">The user name.</param> /// <returns>The <see cref="IrcUser"/>.</returns> public IrcUser GetUser(string nickname) { Validate.IsNotDisposed(this._disposed); Validate.HasText(nickname, "nickname"); IrcValidate.IsConnected(this.IsConnected); var user = this.KnownUsers.FirstOrDefault(u => this.Parameters.CaseMapping.AreEqual(u.Nickname, nickname)); if (user == null) { user = new IrcUser(this.Client, this) { Nickname = nickname }; this.KnownUsersInternal.Add(user); } return(user); }
/// <summary> /// Attempts to remove the specified flag from the specified <see cref="IrcUser"/>'s mode on the <see cref="IrcChannel"/>. /// </summary> /// <param name="user">The <see cref="IrcUser"/>.</param> /// <param name="mode">The mode.</param> /// <remarks>This method will only work if the current <see cref="IrcUser"/> is an operator on the <see cref="IrcChannel"/>.</remarks> public void RemoveUserMode(IrcUser user, IrcChannelUserModes mode) { Validate.IsNotNull(user, "user"); Validate.IsEnumValue(mode, "mode"); if (mode == IrcChannelUserModes.Normal) { return; } if (!this.Network.Parameters.ChannelModes.UserModes.Any(p => p.Value == mode)) { throw new ArgumentException("The specified mode is not available on the network."); } string modeString = "-" + this.Network.Parameters.ChannelModes.UserModes.First(p => p.Value == mode).Key.ToString(); // MODE <channel name> -<mode char> <user name> this.Send("MODE", this.FullName, modeString, user.Nickname); }
internal InviteReceivedEventArgs(IrcUser sender) { this.Sender = sender; }
internal MessageReceivedEventArgs(IrcUser sender, string message) { this.Sender = sender; this.Message = message; }
internal void OnUserKicked(IrcUser kickedUser, IrcUser kicker, string reason) { this.Raise(ref this.UserKicked, new UserKickedEventArgs(kickedUser, kicker, reason)); }
internal void OnModeChanged(string mode, IrcUser setter) { this.Raise(ref this.ModeChanged, new ModeChangedEventArgs(mode, setter)); }
internal void OnUserJoined(IrcUser user) { this.Raise(ref this.UserJoined, new UserEventArgs(user)); }
internal void OnUserLeft(IrcUser user, string reason) { this.Raise(ref this.UserLeft, new UserLeftEventArgs(user, reason)); }
internal void OnUserDiscovered(IrcUser user) { this.Raise(this.UserDiscovered, new UserEventArgs(user)); }
internal void OnInviteReceived(IrcUser sender) { this.Raise(ref this.InviteReceived, new InviteReceivedEventArgs(sender)); }
/// <summary> /// Removes the specified <see cref="IrcUser"/> from the <see cref="IrcChannel"/>. /// </summary> internal void RemoveUser(IrcUser user) { this.UserModes.RemoveUser(user); user.ChannelsInternal.Remove(this); }
internal UserEventArgs(IrcUser user) { this.User = user; }
internal UserLeftEventArgs(IrcUser user, string reason) { this.User = user; this.Reason = reason; }
internal UserKickedEventArgs(IrcUser kickedUser, IrcUser kicker, string reason) { this.KickedUser = kickedUser; this.Kicker = kicker; this.Reason = reason; }
internal ModeChangedEventArgs(string mode, IrcUser setter) { this.Mode = mode; this.Setter = setter; }
internal void OnMessageReceived(IrcUser sender, string message) { this.Raise(ref this.MessageReceived, new MessageReceivedEventArgs(sender, message)); }
internal IrcUserChannelModePair(IrcUser user, IrcChannelUserModes mode) { this.User = user; this.Mode = mode; }