Example #1
0
        internal static Task HandleTargetedMessage(IrcClient client, IrcMessage message)
        {
            IrcTargetedMessage targetedMessage = new IrcTargetedMessage(client, message);

            if (targetedMessage.IsChannelMessage)
            {
                var channel = (IrcChannel)targetedMessage.Target;
                var e       = new IrcChannelMessageEventArgs(targetedMessage);

                if (targetedMessage.Type == IrcTargetedMessage.MessageType.Privmsg)
                {
                    client.OnChannelMessageReceived(e);
                    channel.OnMessageReceived(e);
                }
                else if (targetedMessage.Type == IrcTargetedMessage.MessageType.Notice)
                {
                    client.OnChannelNoticeReceived(e);
                    channel.OnNoticeReceived(e);
                }
            }
            else
            {
                var e = new IrcUserMessageEventArgs(targetedMessage);

                if (targetedMessage.Type == IrcTargetedMessage.MessageType.Privmsg)
                {
                    client.OnUserMessageReceived(e);
                }
                else if (targetedMessage.Type == IrcTargetedMessage.MessageType.Notice)
                {
                    client.OnUserNoticeReceived(e);
                }
            }

            return(Task.CompletedTask);
        }
Example #2
0
 /// <summary>
 ///     Raises the <see cref="ChannelNoticeReceived"/> event.
 /// </summary>
 /// <param name="e">The <see cref="EventArgs"/> instance holding the event data.</param>
 internal void OnChannelNoticeReceived(IrcChannelMessageEventArgs e)
 {
     ChannelNoticeReceived?.Invoke(this, e);
 }