sql exported
saccheggiate ardete il tempio fia delitto la pieto
This commit is contained in:
parent
e2860cee02
commit
5aa1f1ef18
7 changed files with 133 additions and 15 deletions
|
@ -19,11 +19,11 @@ namespace bot {
|
|||
static List<Response> indResponseList = new List<Response>();
|
||||
|
||||
public static void loadNavigationList() {
|
||||
navigationList = new List<NavigationNode>();
|
||||
List<NavigationNode> tmpList = new List<NavigationNode>();
|
||||
var tmp = _G.spawnNewConnection();
|
||||
var r = Query.Reader("SELECT * FROM `navigate`", tmp);
|
||||
while(r.Read()) {
|
||||
navigationList.Add(new NavigationNode(
|
||||
tmpList.Add(new NavigationNode(
|
||||
r.GetInt32("findtype"),
|
||||
r.GetString("locator"),
|
||||
r.GetInt32("action"),
|
||||
|
@ -31,21 +31,23 @@ namespace bot {
|
|||
}
|
||||
r.Close();
|
||||
tmp.Close();
|
||||
navigationList = tmpList;
|
||||
}
|
||||
|
||||
public static void loadResponseList() {
|
||||
responseList = new List<Response>();
|
||||
List<Response> tmpListDep = new List<Response>();
|
||||
List<Response> tmpListInd = new List<Response>();
|
||||
var tmp = _G.spawnNewConnection();
|
||||
var r = Query.Reader("SELECT * FROM `responses`", tmp);
|
||||
while(r.Read()) {
|
||||
if(!r.GetBoolean("independent"))
|
||||
responseList.Add(new Response(
|
||||
tmpListDep.Add(new Response(
|
||||
r.GetString("conditions"),
|
||||
r.GetInt32("respid"),
|
||||
r.GetString("parameters"),
|
||||
r.GetInt32("cooldown")));
|
||||
else
|
||||
indResponseList.Add(new Response(
|
||||
tmpListInd.Add(new Response(
|
||||
r.GetString("conditions"),
|
||||
r.GetInt32("respid"),
|
||||
r.GetString("parameters"),
|
||||
|
@ -53,6 +55,8 @@ namespace bot {
|
|||
}
|
||||
r.Close();
|
||||
tmp.Close();
|
||||
responseList = tmpListDep;
|
||||
indResponseList = tmpListInd;
|
||||
}
|
||||
|
||||
static void Main(string[] args) {
|
||||
|
@ -112,10 +116,10 @@ namespace bot {
|
|||
while(Chat.isChatting(_G.driver)) {
|
||||
Message msg = Chat.waitForNewMessage(_G.driver);
|
||||
if(msg == null) break;
|
||||
if(msg.msg == "!dump") {
|
||||
/*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");
|
||||
|
|
|
@ -96,7 +96,12 @@ namespace bot {
|
|||
} catch(Exception err) { }
|
||||
}
|
||||
Console.WriteLine(msg);
|
||||
|
||||
try {
|
||||
return new Message(msg.Substring(0, msg.IndexOf(':')), msg.Substring(msg.IndexOf(':') + 2));
|
||||
} catch(Exception err) {
|
||||
return new Message("","");
|
||||
}
|
||||
} else return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace bot {
|
||||
class Pulse {
|
||||
public const int pulseTime = 60;
|
||||
|
||||
public static void updateHeartbeat() {
|
||||
string beat = _G.getLocalTimeFromUTC().ToString();
|
||||
Query.Quiet("UPDATE `updater` SET `heartbeat`='" + beat + "' WHERE `id`=1", _G.conn);
|
||||
|
@ -34,7 +36,7 @@ namespace bot {
|
|||
DateTime t = new DateTime(0);
|
||||
|
||||
while(true) {
|
||||
if((DateTime.Now - t).TotalSeconds > 30) {
|
||||
if((DateTime.Now - t).TotalSeconds > pulseTime) {
|
||||
updateHeartbeat();
|
||||
checkUpdates();
|
||||
t = DateTime.Now;
|
||||
|
|
|
@ -4,6 +4,10 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Reflection;
|
||||
using OpenQA.Selenium.Firefox;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Internal;
|
||||
using OpenQA.Selenium.Support.UI;
|
||||
|
||||
namespace bot.responses {
|
||||
class sendmsg {
|
||||
|
@ -11,15 +15,20 @@ namespace bot.responses {
|
|||
|
||||
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."};
|
||||
"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. {1} is replaced by a random user that's logged into the chat."};
|
||||
}
|
||||
|
||||
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('`');
|
||||
|
||||
List<string> onlineUsers = new List<string>();
|
||||
foreach(IWebElement elem in _G.driver.FindElement(By.Id("onlineList")).FindElements(By.XPath("*")))
|
||||
onlineUsers.Add(elem.Text);
|
||||
|
||||
foreach(string part in parts)
|
||||
Chat.sendMessage(String.Format(part,msg.name));
|
||||
Chat.sendMessage(String.Format(part,msg.name,onlineUsers[rng.Next(0,onlineUsers.Count)]));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1 +1,97 @@
|
|||
TODO: EXPORT SQL
|
||||
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8 */;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `admin` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`username` varchar(20) NOT NULL DEFAULT 'admin',
|
||||
`password` varchar(256) NOT NULL DEFAULT '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918',
|
||||
`accountaccess` tinyint(1) NOT NULL DEFAULT '1',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `autonomous` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`startday` int(11) NOT NULL DEFAULT '-1',
|
||||
`starttime` bigint(20) NOT NULL DEFAULT '-1',
|
||||
`periodicity` bigint(20) NOT NULL DEFAULT '1440',
|
||||
`randomness` bigint(20) NOT NULL DEFAULT '0',
|
||||
`respid` int(11) NOT NULL,
|
||||
`parameters` longtext NOT NULL,
|
||||
`autolink` int(11) NOT NULL DEFAULT '-1',
|
||||
`linkrespond` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`timeout` bigint(20) NOT NULL,
|
||||
`torandomness` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `conditions` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`friendlyname` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `config` (
|
||||
`id` int(11) NOT NULL DEFAULT '1',
|
||||
`cooldown` bigint(20) NOT NULL DEFAULT '300',
|
||||
`parsechatbot` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`username` varchar(256) NOT NULL DEFAULT 'BOTMAN360',
|
||||
`name` varchar(256) NOT NULL DEFAULT 'AJAX Bot',
|
||||
`timezone` varchar(6) NOT NULL DEFAULT '+00:00',
|
||||
`dst` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`buffersize` int(11) NOT NULL DEFAULT '50',
|
||||
UNIQUE KEY `id` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `error` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`time` varchar(128) NOT NULL,
|
||||
`msg` longtext NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `navigate` (
|
||||
`id` int(20) NOT NULL AUTO_INCREMENT,
|
||||
`findtype` int(11) NOT NULL,
|
||||
`locator` varchar(256) NOT NULL,
|
||||
`action` int(11) NOT NULL,
|
||||
`parameter` longtext NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `responses` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`conditions` longtext NOT NULL,
|
||||
`respid` int(11) NOT NULL,
|
||||
`parameters` longtext,
|
||||
`cooldown` bigint(20) NOT NULL DEFAULT '-1',
|
||||
`independent` tinyint(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `resptypes` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`friendlyname` varchar(255) NOT NULL,
|
||||
`description` longtext NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `updater` (
|
||||
`id` int(11) NOT NULL DEFAULT '1',
|
||||
`heartbeat` varchar(128) NOT NULL DEFAULT '0',
|
||||
`responses` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`autonomous` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`config` tinyint(1) NOT NULL DEFAULT '0',
|
||||
UNIQUE KEY `id` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
INSERT INTO `admin` () VALUES ()
|
||||
INSERT INTO `config` () VALUES ()
|
||||
INSERT INTO `updater` () VALUES ()
|
|
@ -106,11 +106,13 @@ include("header.php");
|
|||
?>
|
||||
</select>
|
||||
<select name="timepredicate">
|
||||
<option value=""></option>
|
||||
<option value="-1"></option>
|
||||
<option value="0">AM</option>
|
||||
<option value="1">PM</option>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
then
|
||||
On trigger,
|
||||
<select name="resptype" id="resptype" onchange="handleRespChange();">
|
||||
<?php
|
||||
$q = mysql_query("SELECT * FROM `resptypes`");
|
||||
|
|
|
@ -56,7 +56,7 @@ if($_POST["resptype"] && !$_POST["editId"]) {
|
|||
if(isset($_POST["op".$i])) $c .= $_POST["op".$i] .";";
|
||||
}
|
||||
|
||||
mysql_query("INSERT INTO `responses` (`conditions`,`respid`,`parameters`,`cooldown`,`independent`) VALUES ('". mysql_real_escape_string($c) ."',". $_POST['resptype'] .",'". mysql_real_escape_string($_POST['parameters']) ."',". (($_POST['ccd']==0)?-1:$_POST['cooldown']) .",". (($_POST['indie'])?"1":"0") .")") or die(mysql_error());
|
||||
mysql_query("INSERT INTO `responses` (`conditions`,`respid`,`parameters`,`cooldown`,`independent`) VALUES ('". mysql_real_escape_string($c) ."',". $_POST['resptype'] .",'". mysql_real_escape_string($_POST['parameters']) ."',". (($_POST['cdd']==0)?-1:$_POST['cooldown']) .",". (($_POST['indie'])?"1":"0") .")") or die(mysql_error());
|
||||
mysql_query("UPDATE `updater` SET `responses`=1 WHERE `id`=1");
|
||||
header("Location: resp.php");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue