oh shit it works

wow
This commit is contained in:
MallocNull 2014-07-16 14:40:20 -05:00
parent deef45eae2
commit 7be5dd1e36
21 changed files with 421 additions and 46 deletions

View file

@ -19,7 +19,8 @@ namespace bot {
public static void loadNavigationList() {
navigationList = new List<NavigationNode>();
var r = Query.Reader("SELECT * FROM `navigate`", _G.spawnNewConnection());
var tmp = _G.spawnNewConnection();
var r = Query.Reader("SELECT * FROM `navigate`", tmp);
while(r.Read()) {
navigationList.Add(new NavigationNode(
r.GetInt32("findtype"),
@ -28,19 +29,24 @@ namespace bot {
r.GetString("parameter")));
}
r.Close();
tmp.Close();
}
public static void loadResponseList() {
responseList = new List<Response>();
var r = Query.Reader("SELECT * FROM `responses`", _G.spawnNewConnection());
var tmp = _G.spawnNewConnection();
var r = Query.Reader("SELECT * FROM `responses`", tmp);
while(r.Read()) {
responseList.Add(new Response(
r.GetString("conditions"),
r.GetInt32("respid"),
r.GetString("parameters"),
r.GetInt32("cooldown")));
bool value = responseList.Last().conditions.calculateValue(new Message("guy", "the time is nigh to say nicenight"));
value = !value;
}
r.Close();
tmp.Close();
}
static void Main(string[] args) {
@ -76,19 +82,47 @@ namespace bot {
Query.Quiet(tmp, _G.conn);
_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);
while(true) {
try {
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);
// TODO add autonomous thread start
Chat.reloadContext(_G.driver);
Console.WriteLine(_G.propername + " has started successfully.");
while(Chat.isChatting(_G.driver)) {
Message msg = Chat.waitForNewMessage(_G.driver);
if(msg == null) break;
if(msg.msg == "!dump") {
foreach(Response r in responseList)
Chat.sendMessage("IF "+ r.condstr +" THEN "+ r.responseType.Name);
}
if(msg.msg == "!update") {
Bot.loadResponseList();
Chat.sendMessage("response list updated");
}
foreach(Response response in responseList)
response.triggerResponse(msg);
}
_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.startThread(Pulse.pulseThread);
Console.WriteLine(_G.propername +" has started successfully.");
while(true) ;
}
}
}

103
bot/bot/Chat.cs Normal file
View file

@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;
using OpenQA.Selenium.Internal;
using OpenQA.Selenium.Support.UI;
using MySql.Data.MySqlClient;
using System.Threading;
using System.Reflection;
namespace bot {
class Chat {
static int messageDivSize;
static int currentMessage;
public static void reloadContext(FirefoxDriver d) {
List<IWebElement> 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));
}
if(d.FindElement(By.Id("audioButton")).GetAttribute("class").ToLower() == "button")
d.FindElement(By.Id("audioButton")).Click();
}
public static void sendMessage(string text) {
sendMessage(text, _G.driver);
}
public static void sendMessage(string text, FirefoxDriver d) {
// TODO protection context corrections
if(isChatting(d)) {
d.FindElement(By.Id("inputField")).SendKeys(text);
d.FindElement(By.Id("submitButton")).Click();
try { Thread.Sleep(500); } catch(Exception e) { }
}
}
public static bool isChatting(FirefoxDriver d) {
try {
DateTime startCheck = DateTime.Now;
while(d.FindElement(By.Id("statusIconContainer")).GetAttribute("class") == "statusContainerAlert") {
if((DateTime.Now - startCheck).TotalSeconds > 30)
return false;
}
} catch(Exception err) {
return false;
}
return true;
}
public static Message waitForNewMessage(FirefoxDriver d) {
// TODO protection context addition
int temp = currentMessage;
if(messageDivSize >= 50) {
DateTime start = DateTime.Now;
d.Navigate().Refresh();
try {
(new WebDriverWait(d, new TimeSpan(0, 0, 60))).Until(ExpectedConditions.ElementExists(By.Id("inputField")));
} catch(Exception e) { }
reloadContext(d);
}
Console.WriteLine("Waiting for msg id greater than " + currentMessage);
bool ischat = true;
while(ischat = isChatting(d)) {
try {
List<IWebElement> chatdata = d.FindElement(By.Id("chatList")).FindElements(By.TagName("div")).ToList();
bool found = false;
foreach(IWebElement we in chatdata) {
int nodeID = Int32.Parse(we.GetAttribute("id").Substring(11));
if(nodeID > currentMessage) {
currentMessage = nodeID;
found = true;
break;
}
}
if(found) break;
try { Thread.Sleep(1000); } catch(Exception e) { }
} catch(Exception e) { }
}
if(ischat) {
messageDivSize++;
String msg;
while(true) {
try {
msg = d.FindElement(By.Id("ajaxChat_m_" + (currentMessage))).Text.Substring(11);
break;
} catch(Exception err) { }
}
Console.WriteLine(msg);
return new Message(msg.Substring(0, msg.IndexOf(':')), msg.Substring(msg.IndexOf(':') + 2));
} else return null;
}
}
}

View file

@ -16,20 +16,29 @@ namespace bot {
public bool not;
public Type conditionType;
public string parameter;
public int op;
public Condition() { }
public Condition(bool n, Type c, string p) {
public Condition(bool n, Type c, string p, int o) {
not = n;
conditionType = c;
parameter = p;
op = o;
}
public Condition(bool n, int c, string p) {
public Condition(bool n, int c, string p, int o) {
not = n;
string typeName = (string)(new MySqlCommand("SELECT `name` FROM `conditions` WHERE `id`=" + c, _G.conn)).ExecuteScalar();
conditionType = Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "bot.conditions", StringComparison.Ordinal) && String.Equals(t.Name, typeName, StringComparison.Ordinal)).ToArray()[0];
parameter = p;
op = o;
}
public bool evaluateCondition(Message msg) {
bool retval = ConditionChecker.checkCondition(conditionType, msg, parameter);ConditionChecker.checkCondition(conditionType, msg, parameter);
if(not) retval = !retval;
return retval;
}
}
}

View file

@ -19,6 +19,11 @@ namespace bot {
return (bool)conditionTypes.First(t => t.Name == conditionName).GetMethod("performCheck").Invoke(null, new Object[] { (object)msg, (object)parameter });
}
public static bool checkCondition(Type conditionType, Message msg, string parameter) {
loadConditionTypes();
return (bool)conditionType.GetMethod("performCheck").Invoke(null, new Object[] { (object)msg, (object)parameter });
}
public static Type[] getConditions() {
loadConditionTypes();
return conditionTypes;

View file

@ -18,35 +18,108 @@ namespace bot {
string cond = c[on];
List<string> tk = cond.Split(',').ToList();
if(tk.Count > 2) {
if(pair[0] == -1) {
try {
conditions.Add(new Condition((tk[1] == "1") ? true : false, Int32.Parse(tk[2]), tk[3], Int32.Parse(c[on + 1])));
} catch(Exception err) {
conditions.Add(new Condition((tk[1] == "1") ? true : false, Int32.Parse(tk[2]), tk[3], -1));
}
}
if(Int32.Parse(tk[0]) > 0 && searching == -1) {
conditions.Clear();
searching = 0;
pair[0] = i;
if(i != 0) {
if(pair[1] == -1) {
var tmpmpmpmtkoj = condstring.Substring(0, _G.indexOfNthCommand(condstring, i));
sequence.Add(new ConditionHolder(tmpmpmpmtkoj));
} else if(pair[1] != i-1) {
var tmpmpmpmtkoj = _G.Substring(condstring, _G.indexOfNthCommand(condstring, pair[1]+1), _G.indexOfNthCommand(condstring, i));
sequence.Add(new ConditionHolder(tmpmpmpmtkoj));
}
}
}
if(searching != -1)
searching += Int32.Parse(tk[0]) - Int32.Parse(tk[4]);
if(searching == 0) {
searching = -1;
pair[1] = i;
string str = "", tmp = "";
string str = "";
if(pair[0] != 0) {
//tmp = condstring.Substring(0,
} else {
try {
str = _G.Substring(condstring, (pair[0] == 0) ? 0 : _G.indexOfNthCommand(condstring, pair[0]), _G.indexOfNthCommand(condstring, pair[1]+1));
} catch(Exception err) {
str = _G.Substring(condstring, (pair[0] == 0) ? 0 : _G.indexOfNthCommand(condstring, pair[0]), condstring.Length);
}
str = Int32.Parse(str.Substring(0, str.IndexOf(','))) - 1 + str.Substring(str.IndexOf(','));
int concatval = -1;
if(str[str.Length - 3] == ';') {
concatval = Int32.Parse(str.Substring(str.Length - 2, 1));
str = str.Substring(0, str.Length - 2);
}
str = condstring.Substring((pair[0] == 0) ? 0 : _G.indexOfNth(condstring, ';', pair[0] + 1) + 1, _G.indexOfNth(condstring, ';', pair[1] + 2) + 1);
str = Int32.Parse(str.Substring(0, str.IndexOf(','))) - 1 + str.Substring(str.IndexOf(','));
var tmpmpmp = str.Substring(str.LastIndexOf(',') + 1, (str.LastIndexOf(';') - (str.LastIndexOf(',') + 1)));
str = str.Substring(0, str.LastIndexOf(',') + 1) + (Int32.Parse(str.Substring(str.LastIndexOf(',') + 1, (str.LastIndexOf(';') - (str.LastIndexOf(',') + 1)))) - 1) + ";" + ((concatval==-1)?"":concatval+";");
sequence.Add(new ConditionHolder(str, false));
}
i++;
}
}
if(pair[0] != -1 && pair[1] != i-1) {
var tmkmfdknk = _G.Substring(condstring, _G.indexOfNthCommand(condstring, pair[1]+1), condstring.Length);
sequence.Add(new ConditionHolder(tmkmfdknk, false));
}
return;
}
public bool calculateValue(Message msg, out int lastOperator) {
if(conditions.Count != 0)
lastOperator = conditions.Last().op;
else
sequence.Last().calculateValue(msg, out lastOperator);
return calculateValue(msg);
}
public bool calculateValue(Message msg) {
return true;
bool retval = false;
if(conditions.Count != 0) {
for(int i = 0; i < conditions.Count; i++) {
if(i == 0)
retval = conditions[i].evaluateCondition(msg);
else {
switch(conditions[i - 1].op) {
case 0:
retval = retval && conditions[i].evaluateCondition(msg);
break;
case 1:
retval = retval || conditions[i].evaluateCondition(msg);
break;
}
}
}
} else {
int lastOp = -1;
for(int i = 0; i < sequence.Count; i++) {
if(i == 0)
retval = sequence[i].calculateValue(msg, out lastOp);
else {
switch(lastOp) {
case 0:
retval = retval && sequence[i].calculateValue(msg, out lastOp);
break;
case 1:
retval = retval || sequence[i].calculateValue(msg, out lastOp);
break;
}
}
}
}
return retval;
}
}
}

View file

@ -9,26 +9,39 @@ using MySql.Data.MySqlClient;
namespace bot {
class Response {
public ConditionHolder conditions;
public string condstr;
public Type responseType;
public string parameters;
public int cooldown;
public int lastCall;
public DateTime lastCall;
public Response(string conditions, string responseType, string parameters, int cooldown) {
this.conditions = new ConditionHolder(conditions);
this.condstr = 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;
this.lastCall = 0;
this.lastCall = new DateTime(0);
}
public Response(string conditions, int responseId, string parameters, int cooldown) {
this.conditions = new ConditionHolder(conditions);
this.condstr = 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;
this.cooldown = cooldown;
this.lastCall = 0;
this.lastCall = new DateTime(0);
}
public void triggerResponse(Message msg) {
if(cooldown != -1) {
if((DateTime.Now - lastCall).TotalSeconds < cooldown)
return;
}
if(msg.name.ToLower() != _G.username.ToLower()) {
if(conditions.calculateValue(msg)) ResponseCaller.callResponse(responseType, parameters, msg);
}
}
}
}

View file

@ -16,7 +16,12 @@ namespace bot {
public static void callResponse(String responseName, string parameters, Message msg) {
loadResponseTypes();
responseTypes.First(t => t.Name == responseName).GetMethod("performOperation").Invoke(null, new Object[]{(object)parameters, (object)msg});
responseTypes.First(t => t.Name == responseName).GetMethod("performOperation").Invoke(null, new Object[] { (object)parameters, (object)msg });
}
public static void callResponse(Type responseType, string parameters, Message msg) {
loadResponseTypes();
responseType.GetMethod("performOperation").Invoke(null, new Object[] { (object)parameters, (object)msg });
}
public static Type[] getResponseTypes() {

View file

@ -25,6 +25,7 @@ namespace bot {
public static bool observeDST = false;
public static string username = "";
public static string propername = "AJAX Bot";
public static int bufferSize = 50;
public static int defaultCooldown = 300;
@ -72,6 +73,7 @@ namespace bot {
propername = r.GetString("name");
timezone = r.GetString("timezone");
observeDST = r.GetBoolean("dst");
bufferSize = r.GetInt32("buffersize");
r.Close();
Bot.loadNavigationList();
}
@ -92,12 +94,19 @@ namespace bot {
Query.Quiet("INSERT INTO `error` (`time`,`msg`) VALUES ('"+ getLocalTimeFromUTC() +" UTC"+ timezone +"','"+err+"')", errconn);
}
public static int indexOfNth(string str, char c, int index) {
public static string Substring(string str, int start, int end) {
return str.Substring(start, end - start);
}
public static int indexOfNthCommand(string str, int index) {
int fcount = 0;
for(int i = 0; i < str.Length; i++) {
if(str[i] == c) fcount++;
if(str[i] == ';') {
fcount++;
i += 2;
}
if(fcount == index)
return i;
return i+1;
}
return -1;
}

View file

@ -72,10 +72,16 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Bot.cs" />
<Compile Include="Chat.cs" />
<Compile Include="Condition.cs" />
<Compile Include="ConditionChecker.cs" />
<Compile Include="ConditionHolder.cs" />
<Compile Include="conditions\msgcntword.cs" />
<Compile Include="conditions\msgcontains.cs" />
<Compile Include="conditions\msgis.cs" />
<Compile Include="conditions\msgstartsw.cs" />
<Compile Include="conditions\nameis.cs" />
<Compile Include="conditions\random.cs" />
<Compile Include="NavigationNode.cs" />
<Compile Include="Pulse.cs" />
<Compile Include="Query.cs" />

View file

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bot.conditions {
class msgcntword {
static public string[] getInfo() {
return new string[] { typeof(msgcntword).Name, "message contains phrase" };
}
static public bool performCheck(Message msg, string parameter) {
return false; // implement
}
}
}

View file

@ -11,7 +11,7 @@ namespace bot.conditions {
}
static public bool performCheck(Message msg, string parameter) {
return msg.msg.Contains(parameter);
return msg.msg.ToLower().Contains(parameter.ToLower());
}
}
}

View file

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bot.conditions {
class msgis {
static public string[] getInfo() {
return new string[] { typeof(msgis).Name, "message is" };
}
static public bool performCheck(Message msg, string parameter) {
return msg.msg.ToLower() == parameter.ToLower();
}
}
}

View file

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bot.conditions {
class msgstartsw {
static public string[] getInfo() {
return new string[] { typeof(msgstartsw).Name, "message starts with" };
}
static public bool performCheck(Message msg, string parameter) {
return msg.msg.ToLower().StartsWith(parameter.ToLower());
}
}
}

View file

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bot.conditions {
class nameis {
static public string[] getInfo() {
return new string[] { typeof(nameis).Name, "username is" };
}
static public bool performCheck(Message msg, string parameter) {
return msg.name.ToLower() == parameter.ToLower();
}
}
}

View file

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bot.conditions {
class random {
static private Random rng = new Random();
static public string[] getInfo() {
return new string[] { typeof(random).Name, "random, 1 in " };
}
static public bool performCheck(Message msg, string parameter) {
int chance;
try {
chance = Int32.Parse(parameter);
} catch(Exception err) { return false; }
if(chance <= 1) return true;
else {
int pick = (int)Math.Round((double)((chance-1) / 2));
if(rng.Next(chance) == pick) return true;
else return false;
}
}
}
}

View file

@ -7,13 +7,22 @@ using System.Reflection;
namespace bot.responses {
class jumble {
static private Random rng = new Random();
static public string[] getInfo() {
return new string[] {typeof(jumble).Name, "Jumble Message",
"Takes all words in the sentence and rearranges them randomly, sending the result to the chat."};
}
static public void performOperation(string parameters, Message msg) {
List<String> mesg = new List<string>(msg.msg.ToLower().Replace(".", "").Replace("?", "").Replace("!", "").Replace(",", "").Replace("(whispers)", "").Split(' '));
mesg = new List<string>(mesg.OrderBy((strval) => rng.Next()));
StringBuilder b = new StringBuilder();
foreach(String s in mesg)
b.Append(s + " ");
Chat.sendMessage(b.ToString());
}
}
}

View file

@ -9,11 +9,12 @@ namespace bot.responses {
class replace {
static public string[] getInfo() {
return new string[] {typeof(replace).Name, "Replace Phrase",
"Takes a message, replaces all instances of the specified phrase, and sends it to the chat."};
"Takes a message, replaces all instances of the specified phrase, and sends it to the chat. First line of parameters should be thing to be replaced, second line should be what is should be substituted with."};
}
static public void performOperation(string parameters, Message msg) {
string[] tmp = parameters.Split('\n');
Chat.sendMessage(msg.msg.Replace(tmp[0].Trim(),tmp[1].Trim()));
}
}
}

View file

@ -7,13 +7,19 @@ using System.Reflection;
namespace bot.responses {
class sendmsg {
static private Random rng = new Random();
static public string[] getInfo() {
return new string[] {typeof(sendmsg).Name, "Send Message",
"Sends a message or messages. New lines seperate strings, causing the bot to pick one randomly. To break up a string into multiple messages, seperate clauses with the accent grave (`). {0} is replaced by the message sender's name."};
}
static public void performOperation(string parameters, Message msg) {
string[] parts = parameters.Split('\n');
string selected = (parts.Length>1)?parts[rng.Next(parts.Length)]:parts[0];
parts = selected.Split('`');
foreach(string part in parts)
Chat.sendMessage(String.Format(part,msg.name));
}
}
}

View file

@ -5,16 +5,21 @@ if($_POST["changeConfig"]) {
if(strlen($_POST["tzHour"]) == 2 && is_numeric($_POST["tzHour"]) && strlen($_POST["tzMins"]) == 2 && is_numeric($_POST["tzMins"]) && $_POST["tzHour"] && $_POST["tzMins"]) {
if(trim($_POST["name"])) {
if(trim($_POST["username"])) {
mysql_query("UPDATE `config` SET
`cooldown`='". $_POST['cooldown'] ."',
`name`='". mysql_real_escape_string(trim($_POST['name'])) ."',
`username`='". mysql_real_escape_string(trim($_POST['username'])) ."',
`dst`=". (($_POST['dst'])?"1":"0") .",
`timezone`='". $_POST['tzSign'] . $_POST['tzHour'] .":". $_POST['tzMins'] ."',
`parsechatbot`=". (($_POST['chatbot'])?"1":"0") ."
WHERE `id`=1") or die(mysql_error());
mysql_query("UPDATE `updater` SET `config`=1 WHERE `id`=1");
$config = mysql_fetch_object(mysql_query("SELECT * FROM `config` WHERE `id`=1"));
if(is_numeric($_POST["buffsize"]) && $_POST["buffsize"] > 0 && $_POST["buffsize"]) {
mysql_query("UPDATE `config` SET
`cooldown`='". $_POST['cooldown'] ."',
`name`='". mysql_real_escape_string(trim($_POST['name'])) ."',
`username`='". mysql_real_escape_string(trim($_POST['username'])) ."',
`dst`=". (($_POST['dst'])?"1":"0") .",
`timezone`='". $_POST['tzSign'] . $_POST['tzHour'] .":". $_POST['tzMins'] ."',
`parsechatbot`=". (($_POST['chatbot'])?"1":"0") .",
`buffersize`=". $_POST['buffsize'] ."
WHERE `id`=1") or die(mysql_error());
mysql_query("UPDATE `updater` SET `config`=1 WHERE `id`=1");
$config = mysql_fetch_object(mysql_query("SELECT * FROM `config` WHERE `id`=1"));
} else {
$configerr = "Buffer size is not a positive integer!";
}
} else {
$configerr = "Chat username is empty!";
}
@ -250,6 +255,7 @@ include("header.php"); ?>
</td></tr>
<tr><td style="text-align: right;">Chat Username:</td><td><input type="text" name="username" value="<?php echo escapeDoubleQuotes($config->username); ?>" /></td></tr>
<tr><td style="text-align: right;">Bot Name:</td><td><input type="text" name="name" value="<?php echo escapeDoubleQuotes($config->name); ?>" /></td></tr>
<tr><td style="text-align: right;">Chat Buffer Size:</td><td><input type="text" name="buffsize" value="<?php echo $config->buffersize; ?>" /> messages</td></tr>
<tr><td></td><td><input type="submit" name="changeConfig" value="Modify" /></td></tr>
</table>
</form>

View file

@ -1,8 +1,6 @@
<?php
include("conn.php");
var_dump($config);
$err = $_GET["err"];
if($_POST["loginAttempt"]) {

View file

@ -44,6 +44,7 @@ if($_POST["editId"]) {
}
mysql_query("UPDATE `responses` SET `conditions`='". mysql_real_escape_string($c) ."', `respid`=". $_POST['resptype'] .", `parameters`='". mysql_real_escape_string($_POST['parameters']) ."', `cooldown`=". (($_POST['cdd']==0)?-1:$_POST['cooldown']) ." WHERE `id`=". $_POST['editId']) or die(mysql_error());
mysql_query("UPDATE `updater` SET `responses`=1 WHERE `id`=1");
header("Location: resp.php");
}
@ -56,6 +57,7 @@ if($_POST["resptype"] && !$_POST["editId"]) {
}
mysql_query("INSERT INTO `responses` (`conditions`,`respid`,`parameters`,`cooldown`) VALUES ('". mysql_real_escape_string($c) ."',". $_POST['resptype'] .",'". mysql_real_escape_string($_POST['parameters']) ."',". (($_POST['ccd']==0)?-1:$_POST['cooldown']) .")") or die(mysql_error());
mysql_query("UPDATE `updater` SET `responses`=1 WHERE `id`=1");
header("Location: resp.php");
}