From 32d4fc69fc5fb6668a037d9ed941aa022dfc4f99 Mon Sep 17 00:00:00 2001 From: MallocNull Date: Fri, 18 Jul 2014 16:22:05 -0500 Subject: [PATCH] stuff i guess --- bot/bot/Bot.cs | 12 +- bot/bot/Response.cs | 11 +- www/auto.php | 271 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 288 insertions(+), 6 deletions(-) create mode 100644 www/auto.php diff --git a/bot/bot/Bot.cs b/bot/bot/Bot.cs index bd65bed..fb718b2 100644 --- a/bot/bot/Bot.cs +++ b/bot/bot/Bot.cs @@ -101,6 +101,8 @@ namespace bot { Console.WriteLine(_G.propername + " has started successfully."); + DateTime lastAction = new DateTime(0); + while(Chat.isChatting(_G.driver)) { Message msg = Chat.waitForNewMessage(_G.driver); if(msg == null) break; @@ -112,15 +114,19 @@ namespace bot { Bot.loadResponseList(); Chat.sendMessage("response list updated"); } - foreach(Response response in responseList) - response.triggerResponse(msg); + + foreach(Response response in responseList) { + if((DateTime.Now - lastAction).TotalSeconds >= _G.defaultCooldown) { + if(response.triggerResponse(msg)) lastAction = DateTime.Now; + } + } } _G.stopAllThreads(); Console.WriteLine("Restarting bot ..."); } catch(Exception err) { - _G.criticalError("Main thread experienced unexpected fatal error! Details: "+ err.Message +" in "+ err.StackTrace, true); + _G.criticalError("Main thread experienced unexpected fatal error! Details: "+ err.Message +" "+ err.StackTrace, true); } } } diff --git a/bot/bot/Response.cs b/bot/bot/Response.cs index 2d2a289..6cd63b8 100644 --- a/bot/bot/Response.cs +++ b/bot/bot/Response.cs @@ -34,14 +34,19 @@ namespace bot { this.lastCall = new DateTime(0); } - public void triggerResponse(Message msg) { + public bool triggerResponse(Message msg) { if(cooldown != -1) { if((DateTime.Now - lastCall).TotalSeconds < cooldown) - return; + return false; } if(msg.name.ToLower() != _G.username.ToLower()) { - if(conditions.calculateValue(msg)) ResponseCaller.callResponse(responseType, parameters, msg); + if(conditions.calculateValue(msg)) { + ResponseCaller.callResponse(responseType, parameters, msg); + lastCall = DateTime.Now; + return true; + } } + return false; } } } diff --git a/www/auto.php b/www/auto.php new file mode 100644 index 0000000..8d2f0a2 --- /dev/null +++ b/www/auto.php @@ -0,0 +1,271 @@ + + +
+
+ + Autonomy List +

New Autonomous Routine

+
+ + + + +   + + + ". parseConditionString($resp->conditions, mysql_fetch_object(mysql_query("SELECT * FROM `resptypes` WHERE `id`=". $resp->respid))->friendlyname) ." + + + "; + }*/ + ?> +
+ + Create New Autonomous Routine +
+

+ +

+

+ then + + ". $desc ."

"; + $i++; + } + ?> +

+

+ + + + Parameters: +

+ +
+

+

+ Cooldown: + + seconds +

+

+ +      + +

+
+ + Edit Response +
+

+ If + + conditions; + $conds = explode(";",$conds); + $conds = array_slice($conds, 0, count($conds)-1); + $on = 1; + foreach($conds as $cond) { + $tk = explode(",",$cond); + if(count($tk) > 3) { ?> + + + + + + + + + + + + + + + + + + Add Condition + +

+

+ then + + ". $desc ."

"; + $i++; + } + ?> +

+

+ + respid))->description; + ?> + + Parameters: +

+ +
+ +

+

+ Cooldown: + + cooldown == -1) { ?> disabled="disabled" /> seconds +

+

+ + +      + +

+
+ + +
+
+ \ No newline at end of file