Exemplo n.º 1
0
 /// <summary>
 ///   Applies this mode to the ModeArguments property of the given <see cref="ChannelModeMessage" />.
 /// </summary>
 /// <param name="msg">The message which will be modified to include this mode.</param>
 protected override void AddParameter(ChannelModeMessage msg)
 {
     if (UserLimit != -1)
     {
         msg.ModeArguments.Add(UserLimit.ToString(CultureInfo.InvariantCulture));
     }
 }
 /// <summary>
 /// Applies this mode to the ModeChanges property of the given <see cref="ChannelModeMessage" />.
 /// </summary>
 /// <param name="msg">The message which will be modified to include this mode.</param>
 /// <param name="includeAction">Specifies if the action modifier should be applied.</param>
 protected virtual void AddChanges(ChannelModeMessage msg, Boolean includeAction)
 {
     if ( includeAction ) {
         msg.ModeChanges += Action.ToString();
     }
     msg.ModeChanges += Symbol;
 }
Exemplo n.º 3
0
 /// <summary>
 ///   Applies this mode to the ModeArguments property of the given <see cref="ChannelModeMessage" />.
 /// </summary>
 /// <param name="msg">The message which will be modified to include this mode.</param>
 protected override void AddParameter(ChannelModeMessage msg)
 {
     if (this.Parameter.Length != 0)
     {
         msg.ModeArguments.Add(this.Parameter);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 ///   Applies this mode to the ModeChanges property of the given
 ///   <see cref="ChannelModeMessage" />.
 /// </summary>
 /// <param name="msg">The message which will be modified to include this mode.</param>
 /// <param name="includeAction">Specifies if the action modifier should be applied.</param>
 protected void AddChanges(ChannelModeMessage msg, bool includeAction)
 {
     if (includeAction)
     {
         msg.ModeChanges += this.Action == ModeAction.Add ? "+" : "-";
     }
     msg.ModeChanges += this.Symbol;
 }
 /// <summary>
 /// Applies the current modes to the given <see cref="ChannelModeMessage"/>.
 /// </summary>
 /// <param name="msg">The message to be altered.</param>
 public virtual void ApplyTo( ChannelModeMessage msg )
 {
     if ( msg == null )
     {
         return;
     }
     msg.ModeChanges = "";
     msg.ModeArguments.Clear();
     if ( modes.Count > 0 )
     {
         // The first one always adds its mode
         ChannelMode currentMode = modes[ 0 ];
         ModeAction currentAction = currentMode.Action;
         currentMode.ApplyTo( msg, true );
         // The rest compare to the current
         for ( Int32 i = 1; i < modes.Count; i++ )
         {
             currentMode = modes[ i ];
             currentMode.ApplyTo( msg, currentAction != currentMode.Action );
             currentAction = currentMode.Action;
         }
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Finds a message type to handle the message.
        /// </summary>
        public ReceivableMessage Process()
        {
            // Named messages.
            if (NickMessage.CanProcess(this))
            {
                return(new NickMessage(this));
            }
            if (QuitMessage.CanProcess(this))
            {
                return(new QuitMessage(this));
            }
            if (JoinMessage.CanProcess(this))
            {
                return(new JoinMessage(this));
            }
            if (PartMessage.CanProcess(this))
            {
                return(new PartMessage(this));
            }
            if (PrivateMessage.CanProcess(this))
            {
                return(new PrivateMessage(this));
            }
            if (PingMessage.CanProcess(this))
            {
                return(new PingMessage(this));
            }
            if (NoticeMessage.CanProcess(this))
            {
                return(new NoticeMessage(this));
            }
            if (UserModeMessage.CanProcess(this))
            {
                return(new UserModeMessage(this));
            }
            if (ChannelModeMessage.CanProcess(this))
            {
                return(new ChannelModeMessage(this));
            }
            if (KickMessage.CanProcess(this))
            {
                return(new KickMessage(this));
            }
            if (InviteMessage.CanProcess(this))
            {
                return(new InviteMessage(this));
            }
            if (OperwallMessage.CanProcess(this))
            {
                return(new OperwallMessage(this));
            }
            if (Receive.TopicMessage.CanProcess(this))
            {
                return(new Receive.TopicMessage(this));
            }

            // IRCv3 messages.
            if (Receive.v3.CapabilityMessage.CanProcess(this))
            {
                return(new Receive.v3.CapabilityMessage(this));
            }
            if (Receive.v3.AwayMessage.CanProcess(this))
            {
                return(new Receive.v3.AwayMessage(this));
            }

            // Numerics.
            if (NumericMessage.CanProcess(this))
            {
                // Pass all numeric messages to NumericMessage so an event can be fired, then pass it to more specific instances.
                // ReSharper disable once ObjectCreationAsStatement
                new NumericMessage(this);

                if (WelcomeMessage.CanProcess(this))
                {
                    return(new WelcomeMessage(this));
                }
                if (YourHostMessage.CanProcess(this))
                {
                    return(new YourHostMessage(this));
                }
                if (CreatedMessage.CanProcess(this))
                {
                    return(new CreatedMessage(this));
                }
                if (MyInfoMessage.CanProcess(this))
                {
                    return(new MyInfoMessage(this));
                }
                if (SupportMessage.CanProcess(this))
                {
                    return(new SupportMessage(this));
                }
                if (BounceMessage.CanProcess(this))
                {
                    return(new BounceMessage(this));
                }
                if (MOTDEndMessage.CanProcess(this))
                {
                    return(new MOTDEndMessage(this));
                }
                if (MOTDStartMessage.CanProcess(this))
                {
                    return(new MOTDStartMessage(this));
                }
                if (MOTDMessage.CanProcess(this))
                {
                    return(new MOTDMessage(this));
                }
                if (LUserMessage.CanProcess(this))
                {
                    return(new LUserMessage(this));
                }
                if (NamesMessage.CanProcess(this))
                {
                    return(new NamesMessage(this));
                }
                if (EndOfNamesMessage.CanProcess(this))
                {
                    return(new EndOfNamesMessage(this));
                }
                if (TopicMessage.CanProcess(this))
                {
                    return(new TopicMessage(this));
                }
                if (TopicWhoTimeMessage.CanProcess(this))
                {
                    return(new TopicWhoTimeMessage(this));
                }
                if (ListMessage.CanProcess(this))
                {
                    return(new ListMessage(this));
                }
                if (ListEndMessage.CanProcess(this))
                {
                    return(new ListEndMessage(this));
                }
                if (YoureOperMessage.CanProcess(this))
                {
                    return(new YoureOperMessage(this));
                }
                if (AwayMessage.CanProcess(this))
                {
                    return(new AwayMessage(this));
                }
                if (UnAwayMessage.CanProcess(this))
                {
                    return(new UnAwayMessage(this));
                }
                if (NowAwayMessage.CanProcess(this))
                {
                    return(new NowAwayMessage(this));
                }
                if (ChannelModeIsMessage.CanProcess(this))
                {
                    return(new ChannelModeIsMessage(this));
                }
                if (UModeIsMessage.CanProcess(this))
                {
                    return(new UModeIsMessage(this));
                }
                if (VersionMessage.CanProcess(this))
                {
                    return(new VersionMessage(this));
                }
                if (TimeMessage.CanProcess(this))
                {
                    return(new TimeMessage(this));
                }
                if (WhoMessage.CanProcess(this))
                {
                    return(new WhoMessage(this));
                }
                if (WhoisMessage.CanProcess(this))
                {
                    return(new WhoisMessage(this));
                }
                if (EndOfWhoMessage.CanProcess(this))
                {
                    return(new EndOfWhoMessage(this));
                }
                if (EndOfWhoisMessage.CanProcess(this))
                {
                    return(new EndOfWhoisMessage(this));
                }
                if (BanListMessage.CanProcess(this))
                {
                    return(new BanListMessage(this));
                }
                if (EndOfBanListMessage.CanProcess(this))
                {
                    return(new EndOfBanListMessage(this));
                }
                if (InviteListMessage.CanProcess(this))
                {
                    return(new InviteListMessage(this));
                }
                if (EndOfInviteListMessage.CanProcess(this))
                {
                    return(new EndOfInviteListMessage(this));
                }
                if (ExceptListMessage.CanProcess(this))
                {
                    return(new ExceptListMessage(this));
                }
                if (EndOfExceptListMessage.CanProcess(this))
                {
                    return(new EndOfExceptListMessage(this));
                }
                if (IsOnMessage.CanProcess(this))
                {
                    return(new IsOnMessage(this));
                }

                // Catch all for unhandled error messages.
                if (ErrorMessage.CanProcess(this))
                {
                    return(new ErrorMessage(this));
                }
            }

            Console.WriteLine("Message handler for \"" + Text + "\" not found.");
            return(null);
        }
 /// <summary>
 /// Applies this mode to the ModeArguments property of the given <see cref="ChannelModeMessage" />.
 /// </summary>
 /// <param name="msg">The message which will be modified to include this mode.</param>
 protected override void AddParameter(ChannelModeMessage msg)
 {
     msg.ModeArguments.Add(Mask.ToString());
 }
Exemplo n.º 8
0
 /// <summary>
 ///   Applies this mode to the ModeArguments property of the given
 ///   <see cref="ChannelModeMessage" />.
 /// </summary>
 /// <param name="msg">The message which will be modified to include this mode.</param>
 protected override void AddParameter(ChannelModeMessage msg)
 {
     msg.ModeArguments.Add(this.Nick);
 }
Exemplo n.º 9
0
 /// <summary>
 ///   Loads the given mode data into this <see cref="ChannelModesCreator" />
 /// </summary>
 public void Parse(ChannelModeMessage msg)
 {
     if (msg == null)
     {
         return;
     }
     this.Parse(msg.ModeChanges, msg.ModeArguments);
 }
Exemplo n.º 10
0
 /// <summary>
 ///   Applies this mode to the ModeArguments property of the given
 ///   <see cref="ChannelModeMessage" />.
 /// </summary>
 /// <param name="msg">The message which will be modified to include this mode.</param>
 protected virtual void AddParameter(ChannelModeMessage msg)
 {
 }
Exemplo n.º 11
0
 /// <summary>
 ///   Applies the mode to the given <see cref="ChannelModeMessage" />.
 /// </summary>
 /// <param name="msg">The message which will be modified to include this mode.</param>
 /// <param name="includeAction">Specifies if the action modifier should be applied.</param>
 public void ApplyTo(ChannelModeMessage msg, bool includeAction)
 {
     this.AddChanges(msg, includeAction);
     this.AddParameter(msg);
 }
Exemplo n.º 12
0
 internal void OnChannelMode(ChannelModeMessage message) => ChannelMode?.Invoke(message);
 /// <summary>
 /// Applies the mode to the given <see cref="ChannelModeMessage"/>.
 /// </summary>
 /// <param name="msg">The message which will be modified to include this mode.</param>
 /// <param name="includeAction">Specifies if the action modifier should be applied.</param>
 public virtual void ApplyTo(ChannelModeMessage msg, Boolean includeAction )
 {
     AddChanges(msg,includeAction);
     AddParameter(msg);
 }
 /// <summary>
 /// Applies this mode to the ModeArguments property of the given <see cref="ChannelModeMessage" />.
 /// </summary>
 /// <param name="msg">The message which will be modified to include this mode.</param>
 protected override void AddParameter(ChannelModeMessage msg)
 {
     if ( Password.Length != 0 ) {
         msg.ModeArguments.Add(Password);
     }
 }