Provides data for the IrcClient.RawMessageSent and IrcClient.RawMessageReceived events.
Inheritance: System.EventArgs
コード例 #1
0
		public async static void RawMessageReceived(object sender, IrcRawMessageEventArgs args)
		{
			if (!args.RawContent.StartsWith("PING"))
			{
				RawMessageHandler.ProcessRawMessage(args.RawContent);
			}
		}
コード例 #2
0
ファイル: TwitchChat.cs プロジェクト: Rezura/LiveSplit
 void WaitForChannelJoin(object sender, IrcRawMessageEventArgs e)
 {
     if (e.Message.Command == "353")
     {
         Client.Channels.FirstOrDefault().MessageReceived += Channel_MessageReceived;
         Client.RawMessageReceived -= WaitForChannelJoin;
         AddFlag(Client.Channels.FirstOrDefault().Name.Substring(1), ChatBadges.Moderator | ChatBadges.Broadcaster);
         SendMessage("/mods");
     }
 }
コード例 #3
0
        void client_RawMessageReceived(object sender, IrcRawMessageEventArgs e)
        {
            var client = (IrcClient)sender;

            var message = e.Message;
            if (message.Command == "PRIVMSG" && message.Parameters[0] == "#" + client.LocalUser.UserName.ToLower() && !string.Equals(message.Source.Name, client.LocalUser.UserName, StringComparison.CurrentCultureIgnoreCase))
            {
                if (MessageReceived != null)
                {
                    MessageReceived(message.Source.Name, message.Parameters[1]);
                }
            }
        }
コード例 #4
0
ファイル: IRC.cs プロジェクト: edwinr/VPServices
        void onIRCMessage(object sender, IrcRawMessageEventArgs e)
        {
            if ( config.GetBoolean("DebugProtocol", false) )
                Log.Fine(Name, "Protocol message: {0}", e.RawContent);

            var bot = app.Bot;
            if ( e.Message.Parameters[0] == channel )
            {
                if ( e.Message.Command.IEquals("PRIVMSG") )
                {
                    var msg = e.Message.Parameters[1];

                    if (msg[0] == ircAction)
                    {
                        msg = msg.Trim(ircAction);
                        msg = msg.Remove(0, 7);
                        bot.ConsoleBroadcast(ChatEffect.None, colorChat, "", "{0} {1}", e.Message.Source.Name, msg);
                    }
                    else
                        bot.ConsoleBroadcast(ChatEffect.None, colorChat, e.Message.Source.Name, msg);
                }
                else if ( e.Message.Command.IEquals("JOIN") )
                    bot.ConsoleBroadcast(ChatEffect.Italic, VPServices.ColorInfo, "", msgEntry, e.Message.Source.Name, channel);
                else if ( e.Message.Command.IEquals("PART") )
                    bot.ConsoleBroadcast(ChatEffect.Italic, VPServices.ColorInfo, "", msgPart, e.Message.Source.Name, channel);
            }
            else if ( e.Message.Command.IEquals("QUIT") )
                bot.ConsoleBroadcast(ChatEffect.Italic, VPServices.ColorInfo, "", msgQuit, e.Message.Source.Name, e.Message.Parameters[0]);
        }
コード例 #5
0
ファイル: IrcBot.cs プロジェクト: quiznilo/Zerobot
 protected abstract void OnRawMessageSent(IrcClient client, IrcRawMessageEventArgs e);
コード例 #6
0
ファイル: Client.cs プロジェクト: code-n-beer/SimoBot
 private void OnRawMessage(object sender, IrcRawMessageEventArgs e)
 {
     Console.WriteLine(e.RawContent);
 }
コード例 #7
0
ファイル: IrcClient.cs プロジェクト: txdv/ircdotnet
        /// <inheritdoc cref="WriteMessage(string, object)"/>
        /// <summary>
        /// Writes the specified message (prefix, command, and parameters) to the network stream.
        /// </summary>
        /// <param name="message">The message to write.</param>
        /// <exception cref="ArgumentException"><paramref name="message"/> contains more than 15 many parameters.
        /// </exception>
        /// <exception cref="ArgumentException">The value of <see cref="IrcMessage.Command"/> of
        /// <paramref name="message"/> is invalid.</exception>
        /// <exception cref="ArgumentException">The value of one of the items of <see cref="IrcMessage.Parameters"/> of
        /// <paramref name="message"/> is invalid.</exception>
        /// <exception cref="ObjectDisposedException">The current instance has already been disposed.</exception>
        protected void WriteMessage(IrcMessage message)
        {
            CheckDisposed();

            if (message.Command == null)
                throw new ArgumentException(Properties.Resources.MessageInvalidCommand, "message");
            if (message.Parameters.Count > maxParamsCount)
                throw new ArgumentException(Properties.Resources.MessageTooManyParams, "parameters");

            var lineBuilder = new StringBuilder();

            // Append prefix to line, if specified.
            if (message.Prefix != null)
                lineBuilder.Append(":" + CheckPrefix(message.Prefix) + " ");

            // Append command name to line.
            lineBuilder.Append(CheckCommand(message.Command).ToUpper());

            // Append each parameter to line, adding ':' character before last parameter.
            for (int i = 0; i < message.Parameters.Count - 1; i++)
            {
                if (message.Parameters[i] != null)
                    lineBuilder.Append(" " + CheckMiddleParameter(message.Parameters[i].ToString()));
            }
            if (message.Parameters.Count > 0)
            {
                var lastParameter = message.Parameters[message.Parameters.Count - 1];
                if (lastParameter != null)
                    lineBuilder.Append(" :" + CheckTrailingParameter(lastParameter));
            }

            // Send raw message as line of text.
            var line = lineBuilder.ToString();
            var messageSentEventArgs = new IrcRawMessageEventArgs(message, line);
            WriteMessage(line, messageSentEventArgs);
        }
コード例 #8
0
ファイル: IrcClient.cs プロジェクト: txdv/ircdotnet
 /// <summary>
 /// Raises the <see cref="RawMessageSent"/> event.
 /// </summary>
 /// <param name="e">The <see cref="IrcRawMessageEventArgs"/> instance containing the event data.</param>
 protected virtual void OnRawMessageSent(IrcRawMessageEventArgs e)
 {
     var handler = this.RawMessageSent;
     if (handler != null)
         handler(this, e);
 }
コード例 #9
0
ファイル: Program.cs プロジェクト: jonbonne/OCTGN
 private static void ClientOnRawMessageReceived(object sender, IrcRawMessageEventArgs ircRawMessageEventArgs)
 {
     Console.WriteLine(ircRawMessageEventArgs.Message + " " + ircRawMessageEventArgs.RawContent);
 }
コード例 #10
0
ファイル: CommunicationManager.cs プロジェクト: rpk/SpikeLite
 // TODO: Kog 11/23/2009 - Maybe make this a bit of "Before" advice like privmessages?
 /// <summary>
 /// We're sending a message. 
 /// </summary>
 /// 
 /// <param name="sender">The object sending the message</param>
 /// <param name="e">The eventargs encapsulating information about the message being sent.</param>
 /// 
 /// <remarks>
 /// The message text will be unformatted, as sent by the IRCD. May be RFC1459 compliant. 
 /// </remarks>
 void RawMessageSent(object sender, IrcRawMessageEventArgs e)
 {
     if (_logger.IsTraceEnabled)
     {
         _logger.TraceFormat("Sent: {0}", e.RawContent);
     }
 }
コード例 #11
0
ファイル: AzureBot.cs プロジェクト: bremnes/IrcBot
 void client_RawMessageReceived(object sender, IrcRawMessageEventArgs e)
 {
     //Trace.TraceInformation("Rawmessage: " + e.RawContent);
 }
コード例 #12
0
 void ircClient_RawMessageSent(object sender, IrcRawMessageEventArgs e)
 {
     this.OnRawMessage(e.RawContent, RawMessageDirection.Sent);
 }
コード例 #13
0
 void ircClient_RawMessageReceived(object sender, IrcRawMessageEventArgs e)
 {
     this.OnRawMessage(e.RawContent, RawMessageDirection.Received);
 }
コード例 #14
0
ファイル: IrcClient.cs プロジェクト: carriercomm/TwitchIrc
        /// <summary>
        /// Sends the specified raw message to the server.
        /// </summary>
        /// <param name="message">The text (single line) of the message to send the server.</param>
        /// <exception cref="ObjectDisposedException">The current instance has already been disposed.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="message"/> is <see langword="null"/>.</exception>
        public void SendRawMessage(string message)
        {
            CheckDisposed();

            if (message == null)
                throw new ArgumentNullException("message");
            
            var messageSentEventArgs = new IrcRawMessageEventArgs(new IrcMessage(this, null, null, null), message);
            WriteMessage(message, messageSentEventArgs);
        }
コード例 #15
0
ファイル: Service.cs プロジェクト: rocky3598/OpenChat
 private void Client_RawMessageReceived(object sender, IrcRawMessageEventArgs ircRawMessageEventArgs)
 {
     //throw new NotImplementedException();
     OnClientRawMessageReceived(ircRawMessageEventArgs.RawContent);
 }
コード例 #16
0
ファイル: Program.cs プロジェクト: kellyelton/OctgnHelpBot
 private static void ClientOnRawMessageSent(object sender, IrcRawMessageEventArgs ircRawMessageEventArgs)
 {
     if(ircRawMessageEventArgs != null)
         Log("Message Sent: " + ircRawMessageEventArgs.RawContent, ConsoleColor.DarkGreen);
 }
コード例 #17
0
ファイル: Program.cs プロジェクト: kellyelton/OctgnHelpBot
        private static void ClientOnRawMessageReceived(object sender, IrcRawMessageEventArgs ircRawMessageEventArgs)
        {
            Log(ircRawMessageEventArgs.RawContent, ConsoleColor.White);
            try
            {
                var mess = JsonConvert.SerializeObject(ircRawMessageEventArgs.Message);
                Log(mess);
            }
            catch
            {

            }
            if (ircRawMessageEventArgs.Message.Parameters[0] == "gary199567" && ircRawMessageEventArgs.Message.Source.Name == "kellyelton")
            {
                client.SendRawMessage("PRIVMSG #octgn :" + ircRawMessageEventArgs.Message.Parameters[1]);
            }
        }
コード例 #18
0
ファイル: SpeedRunsLiveIRC.cs プロジェクト: 0xwas/LiveSplit
        void Client_RawMessageReceived(object sender, IrcRawMessageEventArgs e)
        {
            if (e.Message.Command == "010")
            {
                Client.Disconnect();
                Connect("irc2.speedrunslive.com", Username, Password);
                return;
            }

            if (e.Message.Command == "433")
            {
                if (NicknameInUse != null)
                    NicknameInUse(this, null);
            }

            if (e.Message.Source != null
                && e.Message.Source.Name == "NickServ"
                && e.Message.Command == "NOTICE")
            {
                if (e.Message.Parameters[1] == "Password accepted - you are now recognized.")
                {
                    Task.Factory.StartNew(() =>
                    {
                        foreach (var channel in ChannelsToJoin)
                            Client.Channels.Join(channel);
                    });
                }
                else if (e.Message.Parameters[1] == "Password incorrect.")
                {
                    if (PasswordIncorrect != null)
                        PasswordIncorrect(this, null);
                }
            }
            

            if (RawMessageReceived != null)
                RawMessageReceived(this, string.Format("{0} - {1}", e.Message.Command, e.Message.Parameters.Where(x => x != null).Aggregate((a, b) => a + " " + b)));
        }
コード例 #19
0
ファイル: RawIrcBot.cs プロジェクト: bremnes/IrcBot
 private void _client_RawMessageReceived(object sender, IrcRawMessageEventArgs e)
 {
     Trace.TraceInformation(e.RawContent);
 }
コード例 #20
0
ファイル: IrcClient.cs プロジェクト: IrcDotNet/IrcDotNet
 /// <summary>
 ///     Raises the <see cref="RawMessageReceived" /> event.
 /// </summary>
 /// <param name="e">The <see cref="IrcRawMessageEventArgs" /> instance containing the event data.</param>
 protected virtual void OnRawMessageReceived(IrcRawMessageEventArgs e)
 {
     var handler = RawMessageReceived;
     if (handler != null)
         handler(this, e);
 }
コード例 #21
0
ファイル: IrcClient.cs プロジェクト: darkunderdog/TShockIRC
        private void ReceiveCompleted(object sender, SocketAsyncEventArgs e)
        {
            try
            {
                if (e.SocketError != SocketError.Success)
                {
                    HandleSocketError(e.SocketError);
                    return;
                }

                // Check if remote host has closed connection.
                if (e.BytesTransferred == 0)
                {
                    HandleClientDisconnected();
                    return;
                }

                // Indicate that block of data has been read into receive buffer.
                this.receiveStream.WritePosition += e.BytesTransferred;
                this.dataStreamReader.DiscardBufferedData();

                // Read each terminated line of characters from data stream.
                while (true)
                {
                    // Read next line from data stream.
                    var line = this.dataStreamLineReader.ReadLine();
                    if (line == null)
                        break;
                    if (line.Length == 0)
                        continue;

                    string prefix = null;
                    string lineAfterPrefix = null;

                    // Extract prefix from message line, if it contains one.
                    if (line[0] == ':')
                    {
                        var firstSpaceIndex = line.IndexOf(' ');
                        Debug.Assert(firstSpaceIndex != -1);
                        prefix = line.Substring(1, firstSpaceIndex - 1);
                        lineAfterPrefix = line.Substring(firstSpaceIndex + 1);
                    }
                    else
                    {
                        lineAfterPrefix = line;
                    }

                    // Extract command from message.
                    var command = lineAfterPrefix.Substring(0, lineAfterPrefix.IndexOf(' '));
                    var paramsLine = lineAfterPrefix.Substring(command.Length + 1);

                    // Extract parameters from message.
                    // Each parameter is separated by single space, except last one, which may contain spaces if it
                    // is prefixed by colon.
                    var parameters = new string[maxParamsCount];
                    int paramStartIndex, paramEndIndex = -1;
                    int lineColonIndex = paramsLine.IndexOf(" :");
                    if (lineColonIndex == -1 && !paramsLine.StartsWith(":"))
                        lineColonIndex = paramsLine.Length;
                    for (int i = 0; i < parameters.Length; i++)
                    {
                        paramStartIndex = paramEndIndex + 1;
                        paramEndIndex = paramsLine.IndexOf(' ', paramStartIndex);
                        if (paramEndIndex == -1)
                            paramEndIndex = paramsLine.Length;
                        if (paramEndIndex > lineColonIndex)
                        {
                            paramStartIndex++;
                            paramEndIndex = paramsLine.Length;
                        }
                        parameters[i] = paramsLine.Substring(paramStartIndex, paramEndIndex - paramStartIndex);
                        if (paramEndIndex == paramsLine.Length)
                            break;
                    }

                    // Parse received IRC message.
                    var message = new IrcMessage(this, prefix, command, parameters);
                    var messageReceivedEventArgs = new IrcRawMessageEventArgs(message, line);
                    OnRawMessageReceived(messageReceivedEventArgs);
                    ReadMessage(message, line);

            #if DEBUG
                    DebugUtilities.WriteIrcRawLine(this, ">>> " + messageReceivedEventArgs.RawContent);
            #endif
                }

                // Continue reading data from socket.
                ReceiveAsync();
            }
            catch (SocketException exSocket)
            {
                HandleSocketError(exSocket);
            }
            catch (ObjectDisposedException)
            {
                // Ignore.
            }
            #if !DEBUG
            catch (Exception ex)
            {
                OnError(new IrcErrorEventArgs(ex));
            }
            #endif
            finally
            {
                e.Dispose();
            }
        }
コード例 #22
0
ファイル: IrcClient.cs プロジェクト: KAmaia/SpikeLite
        void IrcClient_RawMessageReceived(object sender, IrcRawMessageEventArgs e)
        {
            if (_logger.IsTraceEnabled)
            {
                _logger.TraceFormat("Received: {0}", e.RawContent);
            }

            if (e.Message.Command == "433")
            {
                var nickSuffix = _nickRetryCount.ToString();
                var newNick = _ircClient.LocalUser.NickName.Substring(0, _ircClient.LocalUser.NickName.Length - nickSuffix.Length) + nickSuffix;

                _ircClient.LocalUser.SetNickName(newNick);

                _nickRetryCount++;
            }
        }
コード例 #23
0
ファイル: IrcClient.cs プロジェクト: txdv/ircdotnet
        protected void ParseMessage(string line)
        {
            string prefix = null;
            string lineAfterPrefix = null;

            // Extract prefix from message line, if it contains one.
            if (line[0] == ':')
            {
                var firstSpaceIndex = line.IndexOf(' ');
                Debug.Assert(firstSpaceIndex != -1);
                prefix = line.Substring(1, firstSpaceIndex - 1);
                lineAfterPrefix = line.Substring(firstSpaceIndex + 1);
            }
            else
            {
                lineAfterPrefix = line;
            }

            // Extract command from message.
            var command = lineAfterPrefix.Substring(0, lineAfterPrefix.IndexOf(' '));
            var paramsLine = lineAfterPrefix.Substring(command.Length + 1);

            // Extract parameters from message.
            // Each parameter is separated by single space, except last one, which may contain spaces if it
            // is prefixed by colon.
            var parameters = new string[maxParamsCount];
            int paramStartIndex, paramEndIndex = -1;
            int lineColonIndex = paramsLine.IndexOf(" :");
            if (lineColonIndex == -1 && !paramsLine.StartsWith(":"))
                lineColonIndex = paramsLine.Length;
            for (int i = 0; i < parameters.Length; i++)
            {
                paramStartIndex = paramEndIndex + 1;
                paramEndIndex = paramsLine.IndexOf(' ', paramStartIndex);
                if (paramEndIndex == -1)
                    paramEndIndex = paramsLine.Length;
                if (paramEndIndex > lineColonIndex)
                {
                    paramStartIndex++;
                    paramEndIndex = paramsLine.Length;
                }
                parameters[i] = paramsLine.Substring(paramStartIndex, paramEndIndex - paramStartIndex);
                if (paramEndIndex == paramsLine.Length)
                    break;
            }

            // Parse received IRC message.
            var message = new IrcMessage(this, prefix, command, parameters);
            var messageReceivedEventArgs = new IrcRawMessageEventArgs(message, line);
            OnRawMessageReceived(messageReceivedEventArgs);
            ReadMessage(message, line);

            #if DEBUG
            DebugUtilities.WriteIrcRawLine(this, ">>> " + messageReceivedEventArgs.RawContent);
            #endif
        }
コード例 #24
0
ファイル: MainWindow.xaml.cs プロジェクト: andreyrd/NerdChat
        /// <summary>
        /// Service routine for recieving data from the IRC server.  Keep this routine simple and jump to another routine as soon as the nature of the message is known.  This should run in the main server thread.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void IrcClient_Receive(object sender, IrcRawMessageEventArgs e)
        {
            //Check for a prefix indicator.  If this isnt present the message cannot be processed
            if (!e.RawContent.Contains(':'))
                throw new ArgumentOutOfRangeException("Unable to parse message. " + e.RawContent);
            String[] parsedPrefix = e.RawContent.Split(':')[1].Split(' ');

            //Check if prefix is well formed
            if (parsedPrefix.Count() < 2)
                throw new ArgumentOutOfRangeException("Unable to parse prefix. " + e.RawContent);

            string userHost = parsedPrefix[0];
            string command = parsedPrefix[1];
            string userName = parsedPrefix[2];
            string logText = "";

            //Check if source is blacklisted
            if (m_BlackListHosts.Contains(userHost))
            {
                //TODO log this?
                return;
            }
            //Examine the command
            switch (command)
            {
                case "PRIVMSG":
                    logText = "PRIVMSG from " + userName;
                    if (!m_Channels.Contains(userName))
                        m_Channels.Add(userName);
                    //HandlePrivMsg(userName, e.RawContent.Substring(e.RawContent.IndexOf(':', 1)+1)); //skip the first ':' and grab everything after the second
                    break;

                default:
                    logText = "Unknown Message " + e.RawContent;
                    break;
            }

            //var client = (IrcClient)sender;
            //Log this in the main window
            chatBox.Dispatcher.Invoke(delegate
            {
                chatBox.AppendText(logText + "\n");
                chatBox.ScrollToEnd();
            });
        }
コード例 #25
0
ファイル: IrcBot.cs プロジェクト: koushikajay/Alfred
        private void OnRawMessageReceived(object sender, IrcRawMessageEventArgs e)
        {
            Log.Info("{0} {1}", e.Message.Command, string.Join(" ", e.Message.Parameters));

            if (e.Message.Command == "NICK")
            {
                var oldNick = e.Message.Source.Name;
                var newNick = e.Message.Parameters.FirstOrDefault();
                HandleNickChange(oldNick, newNick);
            }
        }
コード例 #26
0
ファイル: DefaultIrcClient.cs プロジェクト: pjmagee/Nircbot
 /// <summary>
 /// Ircs the ircClient on raw message sent.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The <see cref="IrcRawMessageEventArgs"/> instance containing the event data.
 /// </param>
 private void IrcClientOnRawMessageSent(object sender, IrcRawMessageEventArgs e)
 {
     // Trace.TraceInformation("{0}", e.RawContent);
 }
コード例 #27
0
ファイル: IrcBot.cs プロジェクト: quiznilo/Zerobot
 protected abstract void OnRawMessageReceived(IrcClient client, IrcRawMessageEventArgs e);
コード例 #28
0
ファイル: ChannelBot.cs プロジェクト: jonbonne/OCTGN
 private void ClientOnRawMessageSent(object sender, IrcRawMessageEventArgs ircRawMessageEventArgs)
 {
     //ircRawMessageEventArgs.
 }
コード例 #29
0
ファイル: IrcBot.cs プロジェクト: quiznilo/Zerobot
 private void IrcClient_OnRawMessageSent(object sender, IrcRawMessageEventArgs e)
 {
     var client = (IrcClient)sender;
     OnRawMessageSent(client, e);
 }
コード例 #30
0
ファイル: bot.cs プロジェクト: quiznilo/Zerobot
 protected override void OnRawMessageSent(IrcClient client, IrcRawMessageEventArgs e)
 {
     //Console.WriteLine("{0}{1}:{2} <<< <{3}> {3}", e.Message.Source, DateTime.Now.ToShortTimeString, e.Message.Command, e.Message.Parameters[0]);
     //			foreach (string rms in e.Message)
     //				Console.Write(rms);
     //			Console.WriteLine();
     //			Console.WriteLine("{0}-{1}:{2}:{3} <<< {4}",
     //				DateTime.Now.ToShortDateString(),
     //				DateTime.Now.Hour.ToString(),
     //				DateTime.Now.Minute.ToString(),
     //				DateTime.Now.Second.ToString(),
     //				e.RawContent);
     Console.WriteLine("{0}{1}", sColorTime(1), e.RawContent);
 }