base work pt 1
we have liftoff
This commit is contained in:
parent
e65b6685e6
commit
3f2b5661fa
30 changed files with 265 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,6 +2,7 @@
|
||||||
## Temporary Exclusions
|
## Temporary Exclusions
|
||||||
#################
|
#################
|
||||||
conn.php
|
conn.php
|
||||||
|
_G.cs
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
#################
|
#################
|
||||||
|
|
33
bot/bot/Bot.cs
Normal file
33
bot/bot/Bot.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
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 SuperSocket;
|
||||||
|
using SuperSocket.SocketBase;
|
||||||
|
using SuperWebSocket;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace bot {
|
||||||
|
class Bot {
|
||||||
|
public static MySqlConnection conn;
|
||||||
|
|
||||||
|
static void Main(string[] args) {
|
||||||
|
conn = new MySqlConnection("SERVER="+ _G.serveraddr +";DATABASE="+ _G.dbname +";UID="+ _G.dbuser +";PASSWORD="+ _G.dbpass +";");
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
foreach(Type t in ResponseCaller.getResponseTypes()) {
|
||||||
|
string[] typeInfo = (string[])t.GetMethod("getInfo").Invoke(null, null);
|
||||||
|
try { (new MySqlCommand("UPDATE `resptypes` SET friendlyname='" + typeInfo[1].Replace("'", "\\'") + "',description='" + typeInfo[2].Replace("'", "\\'") + "' WHERE name='" + typeInfo[0] + "'", conn)).ExecuteNonQuery(); } catch(Exception e) { }
|
||||||
|
try { (new MySqlCommand("INSERT INTO `resptypes` (name,friendlyname,description) VALUES ('" + typeInfo[0] + "','" + typeInfo[1].Replace("'", "\\'") + "','" + typeInfo[2].Replace("'", "\\'") + "')", conn)).ExecuteNonQuery(); } catch(Exception e) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,13 +3,10 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace bot {
|
||||||
|
class Condition {
|
||||||
|
|
||||||
namespace bot
|
|
||||||
{
|
|
||||||
class Main
|
|
||||||
{
|
|
||||||
static void Main(string[] args)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
17
bot/bot/Message.cs
Normal file
17
bot/bot/Message.cs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace bot {
|
||||||
|
class Message {
|
||||||
|
public string name;
|
||||||
|
public string msg;
|
||||||
|
|
||||||
|
public Message(String name, String msg) {
|
||||||
|
this.name = name;
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
bot/bot/Query.cs
Normal file
22
bot/bot/Query.cs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
|
namespace bot {
|
||||||
|
static class Query {
|
||||||
|
static object Scalar(string query, MySqlConnection conn) {
|
||||||
|
return (new MySqlCommand(query, conn)).ExecuteScalar();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Quiet(string query, MySqlConnection conn) {
|
||||||
|
(new MySqlCommand(query, conn)).ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MySqlDataReader Reader(string query, MySqlConnection conn) {
|
||||||
|
// TODO write this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
34
bot/bot/Response.cs
Normal file
34
bot/bot/Response.cs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Reflection;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
|
namespace bot {
|
||||||
|
class Response {
|
||||||
|
public string 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.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response(string conditions, int responseId, string parameters, int cooldown) {
|
||||||
|
this.conditions = conditions;
|
||||||
|
string typeName = (string)(new MySqlCommand("SELECT `name` FROM `resptypes` WHERE `id`=" + responseId, Bot.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
bot/bot/ResponseCaller.cs
Normal file
27
bot/bot/ResponseCaller.cs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace bot {
|
||||||
|
static class ResponseCaller {
|
||||||
|
static Type[] responseTypes = null;
|
||||||
|
|
||||||
|
static void loadResponseTypes() {
|
||||||
|
if(responseTypes == null)
|
||||||
|
responseTypes = Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "bot.responses", StringComparison.Ordinal)).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void callResponse(String responseName) {
|
||||||
|
loadResponseTypes();
|
||||||
|
//responseTypes[0].GetMethod("test").Invoke(null, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Type[] getResponseTypes() {
|
||||||
|
loadResponseTypes();
|
||||||
|
return responseTypes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
bot/bot/_GG.cs
Normal file
18
bot/bot/_GG.cs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
* MODIFY THIS FILE TO FIT YOUR SERVER'S CONFIGURATION!
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace bot {
|
||||||
|
static class _GG {
|
||||||
|
const string serveraddr = "ADDR";
|
||||||
|
const string dbuser = "NAME";
|
||||||
|
const string dbpass = "PWD";
|
||||||
|
const string dbname = "DATABASE_NAME";
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,6 +32,45 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="log4net">
|
||||||
|
<HintPath>dll\log4net.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Scripting">
|
||||||
|
<HintPath>dll\Microsoft.Scripting.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="MySql.Data">
|
||||||
|
<HintPath>dll\MySql.Data.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="MySql.Data.Entity.EF5">
|
||||||
|
<HintPath>dll\MySql.Data.Entity.EF5.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="MySql.Data.Entity.EF6">
|
||||||
|
<HintPath>dll\MySql.Data.Entity.EF6.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="MySql.Web">
|
||||||
|
<HintPath>dll\MySql.Web.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Selenium.WebDriverBackedSelenium">
|
||||||
|
<HintPath>dll\Selenium.WebDriverBackedSelenium.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SuperSocket.Common">
|
||||||
|
<HintPath>dll\SuperSocket.Common.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SuperSocket.Dlr">
|
||||||
|
<HintPath>dll\SuperSocket.Dlr.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SuperSocket.Facility">
|
||||||
|
<HintPath>dll\SuperSocket.Facility.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SuperSocket.SocketBase">
|
||||||
|
<HintPath>dll\SuperSocket.SocketBase.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SuperSocket.SocketEngine">
|
||||||
|
<HintPath>dll\SuperSocket.SocketEngine.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SuperWebSocket">
|
||||||
|
<HintPath>dll\SuperWebSocket.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
@ -39,14 +78,36 @@
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="ThoughtWorks.Selenium.Core">
|
||||||
|
<HintPath>dll\ThoughtWorks.Selenium.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="WebDriver">
|
||||||
|
<HintPath>dll\WebDriver.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="WebDriver.Support">
|
||||||
|
<HintPath>dll\WebDriver.Support.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Main.cs" />
|
<Compile Include="Bot.cs" />
|
||||||
|
<Compile Include="Condition.cs" />
|
||||||
|
<Compile Include="Query.cs" />
|
||||||
|
<Compile Include="responses\jumble.cs" />
|
||||||
|
<Compile Include="responses\replace.cs" />
|
||||||
|
<Compile Include="_G.cs" />
|
||||||
|
<Compile Include="Message.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Response.cs" />
|
||||||
|
<Compile Include="responses\sendmsg.cs" />
|
||||||
|
<Compile Include="ResponseCaller.cs" />
|
||||||
|
<Compile Include="_GG.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="conditions\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|
BIN
bot/bot/dll/Microsoft.Scripting.dll
Normal file
BIN
bot/bot/dll/Microsoft.Scripting.dll
Normal file
Binary file not shown.
BIN
bot/bot/dll/Selenium.WebDriverBackedSelenium.dll
Normal file
BIN
bot/bot/dll/Selenium.WebDriverBackedSelenium.dll
Normal file
Binary file not shown.
BIN
bot/bot/dll/SuperSocket.Common.dll
Normal file
BIN
bot/bot/dll/SuperSocket.Common.dll
Normal file
Binary file not shown.
BIN
bot/bot/dll/SuperSocket.Dlr.dll
Normal file
BIN
bot/bot/dll/SuperSocket.Dlr.dll
Normal file
Binary file not shown.
BIN
bot/bot/dll/SuperSocket.Facility.dll
Normal file
BIN
bot/bot/dll/SuperSocket.Facility.dll
Normal file
Binary file not shown.
BIN
bot/bot/dll/SuperSocket.SocketBase.dll
Normal file
BIN
bot/bot/dll/SuperSocket.SocketBase.dll
Normal file
Binary file not shown.
BIN
bot/bot/dll/SuperSocket.SocketEngine.dll
Normal file
BIN
bot/bot/dll/SuperSocket.SocketEngine.dll
Normal file
Binary file not shown.
BIN
bot/bot/dll/ThoughtWorks.Selenium.Core.dll
Normal file
BIN
bot/bot/dll/ThoughtWorks.Selenium.Core.dll
Normal file
Binary file not shown.
BIN
bot/bot/dll/WebDriver.Support.dll
Normal file
BIN
bot/bot/dll/WebDriver.Support.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
bot/bot/dll/log4net.dll
Normal file
BIN
bot/bot/dll/log4net.dll
Normal file
Binary file not shown.
10
bot/bot/responses/jumble.cs
Normal file
10
bot/bot/responses/jumble.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace bot.responses {
|
||||||
|
class jumble {
|
||||||
|
}
|
||||||
|
}
|
10
bot/bot/responses/replace.cs
Normal file
10
bot/bot/responses/replace.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace bot.responses {
|
||||||
|
class replace {
|
||||||
|
}
|
||||||
|
}
|
19
bot/bot/responses/sendmsg.cs
Normal file
19
bot/bot/responses/sendmsg.cs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace bot.responses {
|
||||||
|
class sendmsg {
|
||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
8
www/index.php
Normal file
8
www/index.php
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?php
|
||||||
|
include("conn.php");
|
||||||
|
?>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>AJAX Bot Administration</title>
|
||||||
|
</head>
|
||||||
|
</html>
|
Loading…
Reference in a new issue