diff --git a/bot/bot/Chat.cs b/bot/bot/Chat.cs index 5092698..bc2509e 100644 --- a/bot/bot/Chat.cs +++ b/bot/bot/Chat.cs @@ -17,12 +17,17 @@ namespace bot { static int currentMessage; public static void reloadContext(FirefoxDriver d) { - List chatdata = d.FindElement(By.Id("chatList")).FindElements(By.TagName("div")).ToList(); - messageDivSize = chatdata.Count; - foreach(IWebElement we in chatdata) { - if(Int32.Parse(we.GetAttribute("id").Substring(11)) > currentMessage) - currentMessage = Int32.Parse(we.GetAttribute("id").Substring(11)); - } + while(true) { + try { + List chatdata = d.FindElement(By.Id("chatList")).FindElements(By.TagName("div")).ToList(); + messageDivSize = chatdata.Count; + foreach(IWebElement we in chatdata) { + if(Int32.Parse(we.GetAttribute("id").Substring(11)) > currentMessage) + currentMessage = Int32.Parse(we.GetAttribute("id").Substring(11)); + } + break; + } catch(Exception shoehorn) {} + } if(d.FindElement(By.Id("audioButton")).GetAttribute("class").ToLower() == "button") d.FindElement(By.Id("audioButton")).Click(); } diff --git a/bot/bot/_G.cs b/bot/bot/_G.cs index 4dec0d3..4e74ba3 100644 --- a/bot/bot/_G.cs +++ b/bot/bot/_G.cs @@ -85,7 +85,7 @@ namespace bot { tmp = new MySqlConnection("SERVER=" + dbinfo[0] + ";DATABASE=" + dbinfo[3] + ";UID=" + dbinfo[1] + ";PASSWORD=" + dbinfo[2] + ";"); tmp.Open(); } catch(Exception e) { - criticalError("Could not open database connection!"); + criticalError("Could not open database connection! "+ e.Message); return null; } return tmp;