Ejemplo n.º 1
0
        /// <summary>
        /// Locals the user on notice received.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The <see cref="IrcMessageEventArgs"/> instance containing the event data.
        /// </param>
        private void LocalUserOnNoticeReceived(object sender, IrcMessageEventArgs e)
        {
            if (e.Source is IrcUser)
            {
                var sourceUser = e.Source as IrcUser;

                Trace.TraceInformation("{0} {1} sent a NOTICE: {2}", sourceUser.NickName, sourceUser.HostName, e.Text);

                if (this.SupportsIdentification && this.IsNickServNotice(sourceUser.NickName, e.Text))
                {
                    this.JoinChannels();
                }
                else
                {
                    var user = this.userService.GetUserByHost(sourceUser.HostName) ?? this.GetOrCreateGuestUser(sourceUser);
                    var request = new Request { Channel = null, MessageFormat = MessageFormat.Notice, MessageType = MessageType.Private, User = user, Message = e.Text };

                    this.LogRequest(request);

                    Parallel.ForEach(this.Modules, module =>
                    {
                        module.OnNotice(user, e.Text);
                        module.Process(request);
                    });
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Locals the user on message received.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The <see cref="IrcMessageEventArgs"/> instance containing the event data.
        /// </param>
        private void LocalUserOnMessageReceived(object sender, IrcMessageEventArgs e)
        {
            Trace.TraceInformation("Private Message received: {0}");

            var ircUser = (IrcUser)e.Source;

            if (ircUser != null)
            {
                var user = this.userService.GetUserByHost(ircUser.HostName) ?? this.GetOrCreateGuestUser(ircUser);
                var request = new Request { Channel = null, MessageFormat = MessageFormat.Message, MessageType = MessageType.Private, User = user, Message = e.Text };

                this.LogRequest(request);

                Parallel.ForEach(this.Modules, module =>
                {
                    module.OnPrivateMessage(user, e.Text);
                    module.Process(request);
                });
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Processes the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        internal void Process(Request request)
        {
            if (this.IsCommand(request.Message) && request.User.AccessLevel < this.LevelRequired)
            {
                Trace.TraceWarning("{0} tried to access commandHandlerHandler {1} using {2}", request.User.Nick, this.Trigger, request.Message);
            }

            if (this.IsCommand(request.Message) && request.User.AccessLevel >= this.LevelRequired)
            {
                Trace.TraceInformation("{0} was called with message: {1}", this.Trigger, request.Message);

                var arguments = this.ParseArguments(request.Message);

                if (this.CommandHandler != null)
                {
                    try
                    {
                        this.CommandHandler(request.User, request.Channel, request.MessageType, request.MessageFormat, request.Message, arguments);
                    }
                    catch (Exception e)
                    {
                        Trace.TraceError("There was an error executing a commandHandler for {0}", request.Message);
                        Trace.TraceError(e.Message);
                    }
                }

                if (this.Perform != null)
                {
                    try
                    {
                        this.Perform();
                    }
                    catch (Exception e)
                    {
                        Trace.TraceError("There was an error executing a Perform action for {0}", request.Message);
                        Trace.TraceError(e.Message);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Channels the on message received.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The <see cref="IrcMessageEventArgs"/> instance containing the event data.
        /// </param>
        private void ChannelOnMessageReceived(object sender, IrcMessageEventArgs e)
        {
            var ircChannel = (IrcChannel)sender;

            if (e.Source is IrcUser)
            {
                var sourceUser = (IrcUser)e.Source;
                var user = this.userService.GetUserByHost(sourceUser.HostName) ?? this.GetOrCreateGuestUser(sourceUser);
                var request = new Request { Channel = ircChannel.Name, MessageFormat = MessageFormat.Message, MessageType = MessageType.Public, User = user, Message = e.Text };

                this.LogRequest(request);

                Parallel.ForEach(this.Modules, module =>
                {
                    module.OnPublicMessage(user, ircChannel.Name, e.Text);
                    module.Process(request);
                });
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Processes the specified request.
 /// </summary>
 /// <param name="request">The request.</param>
 public void Process(Request request)
 {
     this.commands.ForEach(command => command.Process(request));
 }