Exemple #1
0
        /// <summary>
        /// Set or unset modes for a channel.
        /// </summary>
        /// <param name="channel">The channel on which to set modes.</param>
        /// <param name="modes">The list modes to set or unset.</param>
        public async Task ModeAsync(string channel, IEnumerable <IrcChannelMode> modes)
        {
            var ircChannelModes = modes as IList <IrcChannelMode> ?? modes.ToList();

            if (!ircChannelModes.Any())
            {
                await SendAsync("MODE", new IrcTarget(channel));

                return;
            }

            var enumerator = ircChannelModes.GetEnumerator();
            var modeChunk  = new List <IrcChannelMode>();
            int i          = 0;

            while (enumerator.MoveNext())
            {
                modeChunk.Add(enumerator.Current);
                if (++i == 3)
                {
                    await SendAsync("MODE", new IrcTarget(channel), IrcChannelMode.RenderModes(modeChunk));

                    modeChunk.Clear();
                    i = 0;
                }
            }
            if (modeChunk.Count > 0)
            {
                await SendAsync("MODE", new IrcTarget(channel), IrcChannelMode.RenderModes(modeChunk));
            }
        }
Exemple #2
0
 internal IrcChannelModeEventArgs(IrcMessage message)
     : base(message)
 {
     this.Who     = message.From as IrcPeer;
     this.Channel = message.Parameters.Count > 0 ? new IrcTarget(message.Parameters[0]) : null;
     this.Modes   = message.Parameters.Count > 1 ? IrcChannelMode.ParseModes(message.Parameters.Skip(1)) : null;
 }
Exemple #3
0
 /// <summary>
 /// Set or unset modes for a channel.
 /// </summary>
 /// <param name="channel">The channel on which to set modes.</param>
 /// <param name="modeSpec">The mode specification in the format +/-[modes] [parameters].</param>
 /// <remarks>
 /// Examples of the modeSpec parameter:
 ///   +nst
 ///   +i-ns
 ///   -i+l 500
 ///   +bb [email protected] [email protected]
 /// </remarks>
 public async Task ModeAsync(string channel, string modeSpec)
 {
     await ModeAsync(channel, IrcChannelMode.ParseModes(modeSpec));
 }