Chewie.ChatParser.handleCommands C# (CSharp) Method

handleCommands() private method

private handleCommands ( bool silent, int i, string webURL, string command ) : void
silent bool
i int
webURL string
command string
return void
        void handleCommands( bool silent, int i, string webURL, string command )
        {
            string respondSTR = "";
            string answer = "Acknowledged, processing...";
            int count = 0;
            byte[] chewieBuf = new byte[ 8192 ];
            string htmlClear = @"<(.|\n)*?>";
            HttpWebRequest chewieWeb;
            HttpWebResponse chewieRes;
            Stream readChewie;

            if ( silent == false && chewieBrain.cmdsfromfile[ i, 3 ] == "No" )
                sendChatMsg ( clientFriends.Interface, chewieBrain.ChatRoom, chewieBrain.MessageType, System.Text.Encoding.UTF8.GetBytes ( answer ), answer.Length + 1 );

            //Sends an HTTP request to the specific file

            try
            {
                chewieWeb = ( ( HttpWebRequest ) WebRequest.Create ( webURL ) );
                chewieRes = ( ( HttpWebResponse ) chewieWeb.GetResponse () );
                readChewie = chewieRes.GetResponseStream ();
                do
                {
                    count = readChewie.Read ( chewieBuf, 0, chewieBuf.Length );

                    if ( count != 0 )
                    {
                        respondSTR = Encoding.ASCII.GetString ( chewieBuf, 0, count );
                    }
                }
                while ( count > 0 );

                try
                {

                    // clean up the string removing html parses

                    foreach ( Match match in Regex.Matches ( respondSTR, htmlClear ) )
                        respondSTR = Regex.Replace ( respondSTR, htmlClear, "" );

                    if ( silent == true )
                    {
                        if ( chewieBrain.cmdsfromfile[ i, 3 ] == "Yes" )
                        {
                            Program.parsetoChewie ( "Command " + chewieBrain.cmdsfromfile[ i, 2 ] + " completed silently." );
                        }
                        else
                            sendChatMsg ( clientFriends.Interface, chewieBrain.ChatRoom, chewieBrain.MessageType, System.Text.Encoding.UTF8.GetBytes ( respondSTR ), respondSTR.Length + 1 );
                    }
                    else if ( silent == false )
                    {
                        if ( chewieBrain.cmdsfromfile[ i, 3 ] == "No" )
                        {
                            sendChatMsg ( clientFriends.Interface, chewieBrain.ChatRoom, chewieBrain.MessageType, System.Text.Encoding.UTF8.GetBytes ( respondSTR ), respondSTR.Length + 1 );
                        }
                        else
                            Program.parsetoChewie ( "Command " + chewieBrain.cmdsfromfile[ i, 2 ] + " completed silently." );
                    }
                }
                catch ( Exception )
                {
                }
            }
            catch ( Exception  )
            {
                Program.parsetoChewie ( "Command " + command + " has an invalid url.  Check your settings!" );
            }
        }

Same methods

ChatParser::handleCommands ( int cnt, string chewieCMD, string webURL ) : void