Exemple #1
0
        private void ReadMessage(IrcPreviewMessageEventArgs previewMessageEventArgs, bool isNotice)
        {
            if (!(previewMessageEventArgs.Source is IrcUser))
            {
                return;
            }

            // Check if message represents tagged data.
            if (previewMessageEventArgs.Text.First() == taggedDataDelimeterChar &&
                previewMessageEventArgs.Text.Last() == taggedDataDelimeterChar)
            {
                if (previewMessageEventArgs.Source is IrcUser)
                {
                    var message = new CtcpMessage();
                    message.Source     = (IrcUser)previewMessageEventArgs.Source;
                    message.Targets    = previewMessageEventArgs.Targets;
                    message.IsResponse = isNotice;

                    // Parse tagged data into message.
                    var dequotedText = LowLevelDequote(CtcpDequote(previewMessageEventArgs.Text.Substring(
                                                                       1, previewMessageEventArgs.Text.Length - 2)));
                    var firstSpaceIndex = dequotedText.IndexOf(' ');
                    if (firstSpaceIndex == -1)
                    {
                        message.Tag  = dequotedText;
                        message.Data = null;
                    }
                    else
                    {
                        message.Tag  = dequotedText.Substring(0, firstSpaceIndex);
                        message.Data = dequotedText.Substring(firstSpaceIndex + 1).TrimStart(':');
                    }

                    ReadMessage(message);
                    previewMessageEventArgs.Handled = true;
                }
            }
        }
        private void ReadMessage(IrcPreviewMessageEventArgs previewMessageEventArgs, bool isNotice)
        {
            if (!(previewMessageEventArgs.Source is IrcUser))
                return;

            // Check if message represents tagged data.
            if (previewMessageEventArgs.Text.First() == taggedDataDelimeterChar &&
                previewMessageEventArgs.Text.Last() == taggedDataDelimeterChar)
            {
                if (previewMessageEventArgs.Source is IrcUser)
                {
                    var message = new CtcpMessage();
                    message.Source = (IrcUser)previewMessageEventArgs.Source;
                    message.Targets = previewMessageEventArgs.Targets;
                    message.IsResponse = isNotice;

                    // Parse tagged data into message.
                    var dequotedText = LowLevelDequote(CtcpDequote(previewMessageEventArgs.Text.Substring(
                        1, previewMessageEventArgs.Text.Length - 2)));
                    var firstSpaceIndex = dequotedText.IndexOf(' ');
                    if (firstSpaceIndex == -1)
                    {
                        message.Tag = dequotedText;
                        message.Data = null;
                    }
                    else
                    {
                        message.Tag = dequotedText.Substring(0, firstSpaceIndex);
                        message.Data = dequotedText.Substring(firstSpaceIndex + 1).TrimStart(':');
                    }

                    ReadMessage(message);
                    previewMessageEventArgs.Handled = true;
                }
            }
        }
 private void ircClient_LocalUser_PreviewNoticeReceived(object sender, IrcPreviewMessageEventArgs e)
 {
     ReadMessage(e, true);
 }
Exemple #4
0
 private void ircClient_LocalUser_PreviewNoticeReceived(object sender, IrcPreviewMessageEventArgs e)
 {
     ReadMessage(e, true);
 }