예제 #1
0
        /// <summary>
        /// Received some text from the server
        /// </summary>
        /// <param name="text">Text received</param>
        /// <param name="isJson">TRUE if the text is JSON-Encoded</param>
        /// <param name="links">Links embedded in text</param>
        public void OnTextReceived(string text, bool isJson)
        {
            List <string> links = new List <string>();
            string        json  = null;

            if (isJson)
            {
                json = text;
                text = ChatParser.ParseText(json, links);
            }
            ConsoleIO.WriteLineFormatted(text, true);
            if (text.Contains("LinTx"))
            {
                if (text.Contains("1"))
                {
                    handler.SendHeldItemSlot(0);
                }
                if (text.Contains("2"))
                {
                    handler.SendHeldItemSlot(1);
                }
                if (text.Contains("3"))
                {
                    handler.SendUseItem();
                }
            }
            if (Settings.DisplayChatLinks)
            {
                foreach (string link in links)
                {
                    ConsoleIO.WriteLineFormatted("§8MCC: Link: " + link, false);
                }
            }
            foreach (ChatBot bot in bots.ToArray())
            {
                try
                {
                    bot.GetText(text);
                    if (bots.Contains(bot))
                    {
                        bot.GetText(text, json);
                    }
                }
                catch (Exception e)
                {
                    if (!(e is ThreadAbortException))
                    {
                        ConsoleIO.WriteLineFormatted("§8GetText: Got error from " + bot.ToString() + ": " + e.ToString());
                    }
                    else
                    {
                        throw;  //ThreadAbortException should not be caught
                    }
                }
            }
        }