diff --git a/bot/bot/Bot.cs b/bot/bot/Bot.cs
index 7dab118..48b84a5 100644
--- a/bot/bot/Bot.cs
+++ b/bot/bot/Bot.cs
@@ -7,9 +7,6 @@ using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;
using OpenQA.Selenium.Internal;
using OpenQA.Selenium.Support.UI;
-using SuperSocket;
-using SuperSocket.SocketBase;
-using SuperWebSocket;
using MySql.Data.MySqlClient;
using System.Threading;
@@ -81,6 +78,11 @@ namespace bot {
_G.driver = new FirefoxDriver();
foreach(NavigationNode node in navigationList)
node.performNavigation(_G.driver);
+ try {
+ (new WebDriverWait(_G.driver, new TimeSpan(0, 0, 300))).Until(ExpectedConditions.ElementExists(By.Id("inputField")));
+ } catch(Exception e) {
+ _G.criticalError("Navigation to chat failed! Fix instructions.", true);
+ }
_G.startThread(Pulse.pulseThread);
diff --git a/bot/bot/ConditionHolder.cs b/bot/bot/ConditionHolder.cs
new file mode 100644
index 0000000..9d868e2
--- /dev/null
+++ b/bot/bot/ConditionHolder.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace bot {
+ class ConditionHolder {
+ public ConditionHolder(string conditions) {
+
+ }
+ }
+}
diff --git a/bot/bot/NavigationNode.cs b/bot/bot/NavigationNode.cs
index a75b978..08b5add 100644
--- a/bot/bot/NavigationNode.cs
+++ b/bot/bot/NavigationNode.cs
@@ -7,9 +7,6 @@ using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;
using OpenQA.Selenium.Internal;
using OpenQA.Selenium.Support.UI;
-using SuperSocket;
-using SuperSocket.SocketBase;
-using SuperWebSocket;
using MySql.Data.MySqlClient;
using System.Threading;
diff --git a/bot/bot/Response.cs b/bot/bot/Response.cs
index 28d5cfe..da6e93c 100644
--- a/bot/bot/Response.cs
+++ b/bot/bot/Response.cs
@@ -8,14 +8,14 @@ using MySql.Data.MySqlClient;
namespace bot {
class Response {
- public string conditions;
+ public ConditionHolder conditions;
public Type responseType;
public string parameters;
public int cooldown;
public int lastCall;
public Response(string conditions, string responseType, string parameters, int cooldown) {
- this.conditions = conditions;
+ this.conditions = new ConditionHolder(conditions);
this.responseType = Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "bot.responses", StringComparison.Ordinal) && String.Equals(t.Name, responseType, StringComparison.Ordinal)).ToArray()[0];
this.parameters = parameters;
this.cooldown = cooldown;
@@ -23,7 +23,7 @@ namespace bot {
}
public Response(string conditions, int responseId, string parameters, int cooldown) {
- this.conditions = conditions;
+ this.conditions = new ConditionHolder(conditions);
string typeName = (string)(new MySqlCommand("SELECT `name` FROM `resptypes` WHERE `id`=" + responseId, _G.conn)).ExecuteScalar();
this.responseType = Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "bot.responses", StringComparison.Ordinal) && String.Equals(t.Name, typeName, StringComparison.Ordinal)).ToArray()[0];
this.parameters = parameters;
diff --git a/bot/bot/_G.cs b/bot/bot/_G.cs
index 7dc511c..9deb6fe 100644
--- a/bot/bot/_G.cs
+++ b/bot/bot/_G.cs
@@ -7,9 +7,6 @@ using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;
using OpenQA.Selenium.Internal;
using OpenQA.Selenium.Support.UI;
-using SuperSocket;
-using SuperSocket.SocketBase;
-using SuperWebSocket;
using MySql.Data.MySqlClient;
using System.Threading;
@@ -40,12 +37,21 @@ namespace bot {
for(int i = 0; i < 4; i++)
dbinfo[i] = r.ReadLine();
} catch(Exception e) {
- Environment.FailFast("Error attempting to read from dbinfo.txt: "+e.Message+"\n\nProper format:\nSERVER ADDRESS\nUSERNAME\nPASSWORD\nDATABASE_NAME");
+ criticalError("Error attempting to read from dbinfo.txt: " + e.Message + "\n\nProper format:\nSERVER ADDRESS\nUSERNAME\nPASSWORD\nDATABASE_NAME");
return false;
}
return true;
}
+ public static void criticalError(string err, bool log = false) {
+ if(log)
+ logError(err);
+ Console.WriteLine(err);
+ Console.WriteLine("Press any key to quit.");
+ Console.ReadKey();
+ Environment.FailFast(err);
+ }
+
public static bool isDaylightSavings() {
return (observeDST) ? TimeZoneInfo.GetSystemTimeZones().First(o => o.DisplayName.ToLower().Contains("central time")).IsDaylightSavingTime(DateTime.UtcNow) : false;
}
@@ -76,14 +82,14 @@ namespace bot {
tmp = new MySqlConnection("SERVER=" + dbinfo[0] + ";DATABASE=" + dbinfo[3] + ";UID=" + dbinfo[1] + ";PASSWORD=" + dbinfo[2] + ";");
tmp.Open();
} catch(Exception e) {
- Environment.FailFast("Could not open database connection!");
+ criticalError("Could not open database connection!");
return null;
}
return tmp;
}
public static void logError(string err) {
- (new MySqlCommand("INSERT INTO `error` (`time`,`msg`) VALUES ('"+ getLocalTimeFromUTC() +" UTC"+ timezone +"','"+err+"')", errconn)).ExecuteNonQuery();
+ Query.Quiet("INSERT INTO `error` (`time`,`msg`) VALUES ('"+ getLocalTimeFromUTC() +" UTC"+ timezone +"','"+err+"')", errconn);
}
public delegate void threadFunc();
diff --git a/bot/bot/bot.csproj b/bot/bot/bot.csproj
index 1ffd3e8..a8ee87f 100644
--- a/bot/bot/bot.csproj
+++ b/bot/bot/bot.csproj
@@ -53,24 +53,6 @@
DST? dst) { ?> checked="checked" />
-
- If - - - - - - - - + - - Add Condition - -
-- then - - ". $desc ."
"; - $i++; - } - ?> - -
-
-
-
- Parameters:
-
- - - -
+ + Add Condition + + ++ then + + ". $desc ."
"; + $i++; + } + ?> + +
+
+
+
+ Parameters:
+
+ Cooldown: + + seconds +
++ + + +
+