Esempio n. 1
0
 internal IrcChannelModeEventArgs(IrcMessage message)
     : base(message)
 {
     Who     = message.From as IrcPeer;
     Channel = message.Parameters.Count > 0 ? new IrcTarget(message.Parameters[0]) : null;
     Modes   = message.Parameters.Count > 1 ? IrcChannelMode.ParseModes(message.Parameters.Skip(1)) : null;
 }
Esempio n. 2
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 void Mode(string channel, IEnumerable <IrcChannelMode> modes)
        {
            if (!modes.Any())
            {
                Send("MODE", new IrcTarget(channel));
                return;
            }

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

            while (enumerator.MoveNext())
            {
                modeChunk.Add(enumerator.Current);
                if (++i == 3)
                {
                    Send("MODE", new IrcTarget(channel), IrcChannelMode.RenderModes(modeChunk));
                    modeChunk.Clear();
                    i = 0;
                }
            }
            if (modeChunk.Count > 0)
            {
                Send("MODE", new IrcTarget(channel), IrcChannelMode.RenderModes(modeChunk));
            }
        }
Esempio n. 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 void Mode(string channel, string modeSpec)
 {
     Mode(channel, IrcChannelMode.ParseModes(modeSpec));
 }