Browse code

Revert "move to .net 4.5 and fixed cookies problem"

This reverts commit c92f363d0638d03750000729dfb534fe86a5a488.

Pierre-David Bélanger authored on 13/07/2015 15:23:19
Showing 17 changed files
... ...
@@ -1,8 +1,6 @@
1 1
 
2
-Microsoft Visual Studio Solution File, Format Version 12.00
3
-# Visual Studio 2013
4
-VisualStudioVersion = 12.0.31101.0
5
-MinimumVisualStudioVersion = 10.0.40219.1
2
+Microsoft Visual Studio Solution File, Format Version 10.00
3
+# Visual Studio 2008
6 4
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChatterBotAPI", "ChatterBotAPI\ChatterBotAPI.csproj", "{2E624962-F155-432C-A90A-E1CE75DEE9EA}"
7 5
 EndProject
8 6
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChatterBotAPITest", "ChatterBotAPITest\ChatterBotAPITest.csproj", "{DA59F247-C17B-4A92-BB03-CB458C6916F0}"
... ...
@@ -19,17 +17,14 @@ Global
19 17
 		{2E624962-F155-432C-A90A-E1CE75DEE9EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 18
 		{2E624962-F155-432C-A90A-E1CE75DEE9EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 19
 		{2E624962-F155-432C-A90A-E1CE75DEE9EA}.Release|Any CPU.Build.0 = Release|Any CPU
22
-		{DA59F247-C17B-4A92-BB03-CB458C6916F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23
-		{DA59F247-C17B-4A92-BB03-CB458C6916F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
24
-		{DA59F247-C17B-4A92-BB03-CB458C6916F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
25
-		{DA59F247-C17B-4A92-BB03-CB458C6916F0}.Release|Any CPU.Build.0 = Release|Any CPU
26 20
 		{4D5C5614-9C76-4464-AB6E-A4349784F123}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 21
 		{4D5C5614-9C76-4464-AB6E-A4349784F123}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 22
 		{4D5C5614-9C76-4464-AB6E-A4349784F123}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 23
 		{4D5C5614-9C76-4464-AB6E-A4349784F123}.Release|Any CPU.Build.0 = Release|Any CPU
30
-	EndGlobalSection
31
-	GlobalSection(SolutionProperties) = preSolution
32
-		HideSolutionNode = FALSE
24
+		{DA59F247-C17B-4A92-BB03-CB458C6916F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25
+		{DA59F247-C17B-4A92-BB03-CB458C6916F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
26
+		{DA59F247-C17B-4A92-BB03-CB458C6916F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
27
+		{DA59F247-C17B-4A92-BB03-CB458C6916F0}.Release|Any CPU.Build.0 = Release|Any CPU
33 28
 	EndGlobalSection
34 29
 	GlobalSection(MonoDevelopProperties) = preSolution
35 30
 		StartupItem = ChatterBotAPITestVB\ChatterBotAPITestVB.vbproj
... ...
@@ -1,4 +1,6 @@
1
- /*
1
+using System;
2
+
3
+/*
2 4
     ChatterBotAPI
3 5
     Copyright (C) 2011 pierredavidbelanger@gmail.com
4 6
  
... ...
@@ -15,11 +17,10 @@
15 17
     You should have received a copy of the GNU Lesser General Public License
16 18
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 19
 */
18
-
19
-namespace ChatterBotAPI
20
-{
21
-    public interface ChatterBot
22
-    {
23
-        ChatterBotSession CreateSession();
24
-    }
20
+namespace ChatterBotAPI {
21
+	
22
+	public interface ChatterBot {
23
+		
24
+		ChatterBotSession CreateSession();
25
+	}
25 26
 }
26 27
\ No newline at end of file
... ...
@@ -1,5 +1,5 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 3
   <PropertyGroup>
4 4
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 5
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
... ...
@@ -9,28 +9,7 @@
9 9
     <OutputType>Library</OutputType>
10 10
     <RootNamespace>ChatterBotAPI</RootNamespace>
11 11
     <AssemblyName>ChatterBotAPI</AssemblyName>
12
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13
-    <FileUpgradeFlags>
14
-    </FileUpgradeFlags>
15
-    <UpgradeBackupLocation>
16
-    </UpgradeBackupLocation>
17
-    <OldToolsVersion>3.5</OldToolsVersion>
18
-    <TargetFrameworkProfile />
19
-    <PublishUrl>publish\</PublishUrl>
20
-    <Install>true</Install>
21
-    <InstallFrom>Disk</InstallFrom>
22
-    <UpdateEnabled>false</UpdateEnabled>
23
-    <UpdateMode>Foreground</UpdateMode>
24
-    <UpdateInterval>7</UpdateInterval>
25
-    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
26
-    <UpdatePeriodically>false</UpdatePeriodically>
27
-    <UpdateRequired>false</UpdateRequired>
28
-    <MapFileExtensions>true</MapFileExtensions>
29
-    <ApplicationRevision>0</ApplicationRevision>
30
-    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
31
-    <IsWebBootstrapper>false</IsWebBootstrapper>
32
-    <UseApplicationTrust>false</UseApplicationTrust>
33
-    <BootstrapperEnabled>true</BootstrapperEnabled>
12
+    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
34 13
   </PropertyGroup>
35 14
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
36 15
     <DebugSymbols>true</DebugSymbols>
... ...
@@ -41,7 +20,6 @@
41 20
     <ErrorReport>prompt</ErrorReport>
42 21
     <WarningLevel>4</WarningLevel>
43 22
     <ConsolePause>false</ConsolePause>
44
-    <Prefer32Bit>false</Prefer32Bit>
45 23
   </PropertyGroup>
46 24
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
47 25
     <DebugType>none</DebugType>
... ...
@@ -50,20 +28,10 @@
50 28
     <ErrorReport>prompt</ErrorReport>
51 29
     <WarningLevel>4</WarningLevel>
52 30
     <ConsolePause>false</ConsolePause>
53
-    <Prefer32Bit>false</Prefer32Bit>
54 31
   </PropertyGroup>
55 32
   <ItemGroup>
56 33
     <Reference Include="System" />
57
-    <Reference Include="System.Net.Http" />
58
-    <Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
59
-      <HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
60
-      <Private>True</Private>
61
-    </Reference>
62
-    <Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
63
-      <HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
64
-      <Private>True</Private>
65
-    </Reference>
66
-    <Reference Include="System.Net.Http.WebRequest" />
34
+    <Reference Include="System.Web" />
67 35
     <Reference Include="System.Xml" />
68 36
   </ItemGroup>
69 37
   <ItemGroup>
... ...
@@ -77,25 +45,5 @@
77 45
     <Compile Include="Utils.cs" />
78 46
     <Compile Include="Pandorabots.cs" />
79 47
   </ItemGroup>
80
-  <ItemGroup>
81
-    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
82
-      <Visible>False</Visible>
83
-      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
84
-      <Install>false</Install>
85
-    </BootstrapperPackage>
86
-    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
87
-      <Visible>False</Visible>
88
-      <ProductName>.NET Framework 3.5 SP1</ProductName>
89
-      <Install>true</Install>
90
-    </BootstrapperPackage>
91
-  </ItemGroup>
92
-  <ItemGroup>
93
-    <None Include="packages.config" />
94
-  </ItemGroup>
95 48
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
96
-  <Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
97
-  <Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
98
-    <Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
99
-    <Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
100
-  </Target>
101 49
 </Project>
102 50
\ No newline at end of file
... ...
@@ -17,29 +17,25 @@ using System;
17 17
     You should have received a copy of the GNU Lesser General Public License
18 18
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 19
 */
20
+namespace ChatterBotAPI {
21
+	
22
+	public class ChatterBotFactory {
23
+		
24
+		public ChatterBot Create(ChatterBotType type) {
25
+			return Create(type, null);
26
+		}
20 27
 
21
-namespace ChatterBotAPI
22
-{
23
-    public class ChatterBotFactory
24
-    {
25
-        public ChatterBot Create(ChatterBotType type)
26
-        {
27
-            return Create(type, null);
28
-        }
29
-
30
-        public ChatterBot Create(ChatterBotType type, object arg)
31
-        {
32
-            switch (type)
33
-            {
34
-                case ChatterBotType.CLEVERBOT:
35
-                    return new Cleverbot("http://www.cleverbot.com/", "http://www.cleverbot.com/webservicemin", 26);
36
-                case ChatterBotType.JABBERWACKY:
37
-                    return new Cleverbot("http://jabberwacky.com", "http://jabberwacky.com/webservicemin", 20);
38
-                case ChatterBotType.PANDORABOTS:
39
-                    if (arg == null) throw new ApplicationException("PANDORABOTS needs a botid arg");
40
-                    return new Pandorabots(arg.ToString());
41
-            }
42
-            return null;
43
-        }
44
-    }
28
+		public ChatterBot Create(ChatterBotType type, object arg) {
29
+			switch (type) {
30
+			case ChatterBotType.CLEVERBOT:
31
+				return new Cleverbot("http://www.cleverbot.com/webservicemin", 26);
32
+			case ChatterBotType.JABBERWACKY:
33
+				return new Cleverbot("http://jabberwacky.com/webservicemin", 20);
34
+			case ChatterBotType.PANDORABOTS:
35
+				if (arg == null) throw new ApplicationException("PANDORABOTS needs a botid arg");
36
+				return new Pandorabots(arg.ToString());
37
+			}
38
+			return null;
39
+		}
40
+	}
45 41
 }
46 42
\ No newline at end of file
... ...
@@ -1,4 +1,6 @@
1
- /*
1
+using System;
2
+
3
+/*
2 4
     ChatterBotAPI
3 5
     Copyright (C) 2011 pierredavidbelanger@gmail.com
4 6
  
... ...
@@ -15,12 +17,12 @@
15 17
     You should have received a copy of the GNU Lesser General Public License
16 18
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 19
 */
18
-
19
-namespace ChatterBotAPI
20
-{
21
-    public interface ChatterBotSession
22
-    {
23
-        ChatterBotThought Think(ChatterBotThought thought);
24
-        string Think(string text);
25
-    }
20
+namespace ChatterBotAPI {
21
+	
22
+	public interface ChatterBotSession {
23
+		
24
+		ChatterBotThought Think(ChatterBotThought thought);
25
+		
26
+		string Think(string text);
27
+	}
26 28
 }
27 29
\ No newline at end of file
... ...
@@ -1,4 +1,6 @@
1
- /*
1
+using System;
2
+
3
+/*
2 4
     ChatterBotAPI
3 5
     Copyright (C) 2011 pierredavidbelanger@gmail.com
4 6
  
... ...
@@ -15,12 +17,12 @@
15 17
     You should have received a copy of the GNU Lesser General Public License
16 18
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 19
 */
18
-
19
-namespace ChatterBotAPI
20
-{
21
-    public class ChatterBotThought
22
-    {
23
-        public string[] Emotions { get; set; }
24
-        public string Text { get; set; }
25
-    }
20
+namespace ChatterBotAPI {
21
+	
22
+	public class ChatterBotThought {
23
+		
24
+		public string[] Emotions { get; set; }
25
+		
26
+		public string Text { get; set; }
27
+	}
26 28
 }
27 29
\ No newline at end of file
... ...
@@ -1,4 +1,6 @@
1
- /*
1
+using System;
2
+
3
+/*
2 4
     ChatterBotAPI
3 5
     Copyright (C) 2011 pierredavidbelanger@gmail.com
4 6
  
... ...
@@ -15,13 +17,11 @@
15 17
     You should have received a copy of the GNU Lesser General Public License
16 18
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 19
 */
18
-
19
-namespace ChatterBotAPI
20
-{
21
-    public enum ChatterBotType
22
-    {
23
-        CLEVERBOT,
24
-        JABBERWACKY,
25
-        PANDORABOTS
26
-    }
20
+namespace ChatterBotAPI {
21
+	
22
+	public enum ChatterBotType {
23
+		CLEVERBOT,
24
+		JABBERWACKY,
25
+		PANDORABOTS
26
+	}
27 27
 }
28 28
\ No newline at end of file
... ...
@@ -1,5 +1,6 @@
1
+using System;
2
+
1 3
 using System.Collections.Generic;
2
-using System.Net.Http;
3 4
 
4 5
 /*
5 6
     ChatterBotAPI
... ...
@@ -18,98 +19,85 @@ using System.Net.Http;
18 19
     You should have received a copy of the GNU Lesser General Public License
19 20
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 21
 */
21
-
22
-namespace ChatterBotAPI
23
-{
24
-    internal class Cleverbot : ChatterBot
25
-    {
26
-        private readonly string baseUrl;
27
-        private readonly int endIndex;
28
-        private readonly string url;
29
-
30
-        public Cleverbot(string baseUrl, string url, int endIndex)
31
-        {
32
-            this.baseUrl = baseUrl;
33
-            this.url = url;
34
-            this.endIndex = endIndex;
35
-        }
36
-
37
-        public ChatterBotSession CreateSession()
38
-        {
39
-            return new CleverbotSession(baseUrl, url, endIndex);
40
-        }
41
-    }
42
-
43
-    internal class CleverbotSession : ChatterBotSession
44
-    {
45
-        private readonly string baseUrl;
46
-        private readonly int endIndex;
47
-        private readonly string url;
48
-        private readonly HttpClient client;
49
-        private readonly IDictionary<string, string> vars;
50
-
51
-        public CleverbotSession(string baseUrl, string url, int endIndex)
52
-        {
53
-            this.url = url;
54
-            this.endIndex = endIndex;
55
-            client = Utils.GetHttpClient(baseUrl);
56
-            vars = new Dictionary<string, string>();
57
-            vars["start"] = "y";
58
-            vars["icognoid"] = "wsf";
59
-            vars["fno"] = "0";
60
-            vars["sub"] = "Say";
61
-            vars["islearning"] = "1";
62
-            vars["cleanslate"] = "false";
63
-        }
64
-
65
-        public ChatterBotThought Think(ChatterBotThought thought)
66
-        {
67
-            vars["stimulus"] = thought.Text;
68
-
69
-            var formData = Utils.ParametersToWWWFormURLEncoded(vars);
70
-            var formDataToDigest = formData.Substring(9, endIndex);
71
-            var formDataDigest = Utils.CalculateMD5Hash(formDataToDigest);
72
-            vars["icognocheck"] = formDataDigest;
73
-
74
-            var response = Utils.Post(client, url, vars);
75
-
76
-            var responseValues = response.Split('\r');
77
-
78
-            //vars[""] = Utils.StringAtIndex(responseValues, 0); ??
79
-            vars["sessionid"] = Utils.StringAtIndex(responseValues, 1);
80
-            vars["logurl"] = Utils.StringAtIndex(responseValues, 2);
81
-            vars["vText8"] = Utils.StringAtIndex(responseValues, 3);
82
-            vars["vText7"] = Utils.StringAtIndex(responseValues, 4);
83
-            vars["vText6"] = Utils.StringAtIndex(responseValues, 5);
84
-            vars["vText5"] = Utils.StringAtIndex(responseValues, 6);
85
-            vars["vText4"] = Utils.StringAtIndex(responseValues, 7);
86
-            vars["vText3"] = Utils.StringAtIndex(responseValues, 8);
87
-            vars["vText2"] = Utils.StringAtIndex(responseValues, 9);
88
-            vars["prevref"] = Utils.StringAtIndex(responseValues, 10);
89
-            //vars[""] = Utils.StringAtIndex(responseValues, 11); ??
90
-            vars["emotionalhistory"] = Utils.StringAtIndex(responseValues, 12);
91
-            vars["ttsLocMP3"] = Utils.StringAtIndex(responseValues, 13);
92
-            vars["ttsLocTXT"] = Utils.StringAtIndex(responseValues, 14);
93
-            vars["ttsLocTXT3"] = Utils.StringAtIndex(responseValues, 15);
94
-            vars["ttsText"] = Utils.StringAtIndex(responseValues, 16);
95
-            vars["lineRef"] = Utils.StringAtIndex(responseValues, 17);
96
-            vars["lineURL"] = Utils.StringAtIndex(responseValues, 18);
97
-            vars["linePOST"] = Utils.StringAtIndex(responseValues, 19);
98
-            vars["lineChoices"] = Utils.StringAtIndex(responseValues, 20);
99
-            vars["lineChoicesAbbrev"] = Utils.StringAtIndex(responseValues, 21);
100
-            vars["typingData"] = Utils.StringAtIndex(responseValues, 22);
101
-            vars["divert"] = Utils.StringAtIndex(responseValues, 23);
102
-
103
-            var responseThought = new ChatterBotThought();
104
-
105
-            responseThought.Text = Utils.StringAtIndex(responseValues, 16);
106
-
107
-            return responseThought;
108
-        }
109
-
110
-        public string Think(string text)
111
-        {
112
-            return Think(new ChatterBotThought {Text = text}).Text;
113
-        }
114
-    }
22
+namespace ChatterBotAPI {
23
+	
24
+	class Cleverbot: ChatterBot {
25
+		private readonly string url;
26
+		private readonly int endIndex;
27
+		
28
+		public Cleverbot(string url, int endIndex) {
29
+			this.url = url;
30
+			this.endIndex = endIndex;
31
+		}
32
+		
33
+		public ChatterBotSession CreateSession() {
34
+			return new CleverbotSession(url, endIndex);
35
+		}
36
+	}
37
+	
38
+	class CleverbotSession: ChatterBotSession {
39
+		private readonly string url;
40
+		private readonly int endIndex;
41
+		private readonly IDictionary<string, string> vars;
42
+		
43
+		public CleverbotSession(string url, int endIndex) {
44
+			this.url = url;
45
+			this.endIndex = endIndex;
46
+			vars = new Dictionary<string, string>();
47
+			vars["start"] = "y";
48
+			vars["icognoid"] = "wsf";
49
+			vars["fno"] = "0";
50
+			vars["sub"] = "Say";
51
+			vars["islearning"] = "1";
52
+			vars["cleanslate"] = "false";
53
+		}
54
+		
55
+		public ChatterBotThought Think(ChatterBotThought thought) {
56
+			vars["stimulus"] = thought.Text;
57
+			
58
+			string formData = Utils.ParametersToWWWFormURLEncoded(vars);
59
+			string formDataToDigest = formData.Substring(9, endIndex);
60
+			string formDataDigest = Utils.MD5(formDataToDigest);
61
+			vars["icognocheck"] = formDataDigest;
62
+			
63
+			string response = Utils.Post(url, vars);
64
+			
65
+			string[] responseValues = response.Split('\r');
66
+			
67
+			//vars[""] = Utils.StringAtIndex(responseValues, 0); ??
68
+			vars["sessionid"] = Utils.StringAtIndex(responseValues, 1);
69
+			vars["logurl"] = Utils.StringAtIndex(responseValues, 2);
70
+			vars["vText8"] = Utils.StringAtIndex(responseValues, 3);
71
+			vars["vText7"] = Utils.StringAtIndex(responseValues, 4);
72
+			vars["vText6"] = Utils.StringAtIndex(responseValues, 5);
73
+			vars["vText5"] = Utils.StringAtIndex(responseValues, 6);
74
+			vars["vText4"] = Utils.StringAtIndex(responseValues, 7);
75
+			vars["vText3"] = Utils.StringAtIndex(responseValues, 8);
76
+			vars["vText2"] = Utils.StringAtIndex(responseValues, 9);
77
+			vars["prevref"] = Utils.StringAtIndex(responseValues, 10);
78
+			//vars[""] = Utils.StringAtIndex(responseValues, 11); ??
79
+			vars["emotionalhistory"] = Utils.StringAtIndex(responseValues, 12);
80
+			vars["ttsLocMP3"] = Utils.StringAtIndex(responseValues, 13);
81
+			vars["ttsLocTXT"] = Utils.StringAtIndex(responseValues, 14);
82
+			vars["ttsLocTXT3"] = Utils.StringAtIndex(responseValues, 15);
83
+			vars["ttsText"] = Utils.StringAtIndex(responseValues, 16);
84
+			vars["lineRef"] = Utils.StringAtIndex(responseValues, 17);
85
+			vars["lineURL"] = Utils.StringAtIndex(responseValues, 18);
86
+			vars["linePOST"] = Utils.StringAtIndex(responseValues, 19);
87
+			vars["lineChoices"] = Utils.StringAtIndex(responseValues, 20);
88
+			vars["lineChoicesAbbrev"] = Utils.StringAtIndex(responseValues, 21);
89
+			vars["typingData"] = Utils.StringAtIndex(responseValues, 22);
90
+			vars["divert"] = Utils.StringAtIndex(responseValues, 23);
91
+			
92
+			ChatterBotThought responseThought = new ChatterBotThought();
93
+			
94
+			responseThought.Text = Utils.StringAtIndex(responseValues, 16);
95
+			
96
+			return responseThought;
97
+		}
98
+		
99
+		public string Think(string text) {
100
+			return Think(new ChatterBotThought() { Text = text }).Text;
101
+		}
102
+	}
115 103
 }
116 104
\ No newline at end of file
... ...
@@ -1,6 +1,6 @@
1 1
 using System;
2
+
2 3
 using System.Collections.Generic;
3
-using System.Net.Http;
4 4
 
5 5
 /*
6 6
     ChatterBotAPI
... ...
@@ -19,52 +19,42 @@ using System.Net.Http;
19 19
     You should have received a copy of the GNU Lesser General Public License
20 20
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 21
 */
22
-
23
-namespace ChatterBotAPI
24
-{
25
-    internal class Pandorabots : ChatterBot
26
-    {
27
-        private readonly string botid;
28
-
29
-        public Pandorabots(string botid)
30
-        {
31
-            this.botid = botid;
32
-        }
33
-
34
-        public ChatterBotSession CreateSession()
35
-        {
36
-            return new PandorabotsSession(botid);
37
-        }
38
-    }
39
-
40
-    internal class PandorabotsSession : ChatterBotSession
41
-    {
42
-        private readonly IDictionary<string, string> vars;
43
-        private readonly HttpClient client;
44
-
45
-        public PandorabotsSession(string botid)
46
-        {
47
-            vars = new Dictionary<string, string>();
48
-            vars["botid"] = botid;
49
-            vars["custid"] = Guid.NewGuid().ToString();
50
-            client = Utils.GetHttpClient(String.Empty);
51
-        }
52
-
53
-        public ChatterBotThought Think(ChatterBotThought thought)
54
-        {
55
-            vars["input"] = thought.Text;
56
-
57
-            var response = Utils.Post(client, "http://www.pandorabots.com/pandora/talk-xml", vars);
58
-
59
-            var responseThought = new ChatterBotThought();
60
-            responseThought.Text = Utils.XPathSearch(response, "//result/that/text()");
61
-
62
-            return responseThought;
63
-        }
64
-
65
-        public string Think(string text)
66
-        {
67
-            return Think(new ChatterBotThought {Text = text}).Text;
68
-        }
69
-    }
22
+namespace ChatterBotAPI {
23
+	
24
+	class Pandorabots: ChatterBot {
25
+		private readonly string botid;
26
+		
27
+		public Pandorabots(string botid) {
28
+			this.botid = botid;
29
+		}
30
+		
31
+		public ChatterBotSession CreateSession() {
32
+			return new PandorabotsSession(botid);
33
+		}
34
+	}
35
+	
36
+	class PandorabotsSession: ChatterBotSession {
37
+		private readonly IDictionary<string, string> vars;
38
+		
39
+		public PandorabotsSession(string botid) {
40
+			vars = new Dictionary<string, string>();
41
+			vars["botid"] = botid;
42
+			vars["custid"] = Guid.NewGuid().ToString();
43
+		}
44
+		
45
+		public ChatterBotThought Think(ChatterBotThought thought) {
46
+			vars["input"] = thought.Text;
47
+			
48
+			string response = Utils.Post("http://www.pandorabots.com/pandora/talk-xml", vars);
49
+			
50
+			ChatterBotThought responseThought = new ChatterBotThought();
51
+			responseThought.Text = Utils.XPathSearch(response, "//result/that/text()");
52
+			
53
+			return responseThought;
54
+		}
55
+		
56
+		public string Think(string text) {
57
+			return Think(new ChatterBotThought() { Text = text }).Text;
58
+		}
59
+	}
70 60
 }
71 61
\ No newline at end of file
... ...
@@ -1,10 +1,11 @@
1 1
 using System;
2
+
2 3
 using System.Collections.Generic;
3 4
 using System.IO;
4 5
 using System.Net;
5
-using System.Net.Http;
6 6
 using System.Text;
7
-using System.Threading.Tasks;
7
+using System.Web;
8
+using System.Web.Security;
8 9
 using System.Xml.XPath;
9 10
 
10 11
 /*
... ...
@@ -24,102 +25,55 @@ using System.Xml.XPath;
24 25
     You should have received a copy of the GNU Lesser General Public License
25 26
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
26 27
 */
27
-
28
-namespace ChatterBotAPI
29
-{
30
-    internal static class Utils
31
-    {
32
-
33
-        public async static Task<HttpClient> GetHttpClientAsync(string baseUrl)
34
-        {
35
-            var client = new HttpClient();
36
-            client.DefaultRequestHeaders.Add("UserAgent", "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0;");
37
-            client.DefaultRequestHeaders.Add("Accept-Language", "en-US");
38
-
39
-
40
-            if (!string.IsNullOrEmpty(baseUrl))
41
-            {
42
-                await client.GetAsync(new Uri(baseUrl));
43
-            }
44
-
45
-            return client;
46
-        }
47
-
48
-        public static HttpClient GetHttpClient(string baseUrl)
49
-        {
50
-            var result = GetHttpClientAsync(baseUrl);
51
-
52
-            result.Wait();
53
-            return result.Result;
54
-        }
55
-
56
-        public static string ParametersToWWWFormURLEncoded(IDictionary<string, string> parameters)
57
-        {
58
-            string wwwFormUrlEncoded = null;
59
-            foreach (var parameterKey in parameters.Keys)
60
-            {
61
-                var parameterValue = parameters[parameterKey];
62
-                var parameter = string.Format("{0}={1}", WebUtility.UrlEncode(parameterKey),
63
-                    WebUtility.UrlEncode(parameterValue));
64
-                if (wwwFormUrlEncoded == null)
65
-                {
66
-                    wwwFormUrlEncoded = parameter;
67
-                }
68
-                else
69
-                {
70
-                    wwwFormUrlEncoded = string.Format("{0}&{1}", wwwFormUrlEncoded, parameter);
71
-                }
72
-            }
73
-            return wwwFormUrlEncoded;
74
-        }
75
-
76
-        public static async Task<string> PostAsync(HttpClient client, string url, IDictionary<string, string> parameters)
77
-        {
78
-            var result =  await client.PostAsync(new Uri(url),
79
-                        new StringContent(ParametersToWWWFormURLEncoded(parameters), Encoding.UTF8, "application/x-www-form-urlencoded"));
80
-
81
-
82
-            var conetnt = await result.Content.ReadAsStringAsync();
83
-
84
-
85
-            return conetnt.Trim();
86
-        }
87
-
88
-        public static string Post(HttpClient client, string url, IDictionary<string, string> parameters)
89
-        {
90
-            var result = PostAsync(client, url, parameters);
91
-
92
-            result.Wait();
93
-            return result.Result;
94
-        }
95
-
96
-        public static string XPathSearch(string input, string expression)
97
-        {
98
-            var document = new XPathDocument(new MemoryStream(Encoding.ASCII.GetBytes(input)));
99
-            var navigator = document.CreateNavigator();
100
-            return navigator.SelectSingleNode(expression).Value.Trim();
101
-        }
102
-
103
-        public static string StringAtIndex(string[] strings, int index)
104
-        {
105
-            if (index >= strings.Length) return "";
106
-            return strings[index];
107
-        }
108
-
109
-        public static string CalculateMD5Hash(string input)
110
-        {
111
-            // step 1, calculate MD5 hash from input
112
-            var md5 = System.Security.Cryptography.MD5.Create();
113
-            var inputBytes = Encoding.ASCII.GetBytes(input);
114
-            var hash = md5.ComputeHash(inputBytes);
115
-
116
-            // step 2, convert byte array to hex string
117
-            var sb = new StringBuilder();
118
-            for (var i = 0; i < hash.Length; i++)
119
-            {
120
-                sb.Append(hash[i].ToString("X2"));
121
-            }
122
-            return sb.ToString();
123
-        }
124
-    }
28
+namespace ChatterBotAPI {
29
+	
30
+	static class Utils {
31
+		
32
+		public static string ParametersToWWWFormURLEncoded(IDictionary<string, string> parameters) {
33
+			string wwwFormUrlEncoded = null;
34
+			foreach (string parameterKey in parameters.Keys) {
35
+				string parameterValue = parameters[parameterKey];
36
+				string parameter = string.Format("{0}={1}", HttpUtility.UrlEncode(parameterKey), HttpUtility.UrlEncode(parameterValue));
37
+				if (wwwFormUrlEncoded == null) {
38
+					wwwFormUrlEncoded = parameter;
39
+				} else {
40
+					wwwFormUrlEncoded = string.Format("{0}&{1}", wwwFormUrlEncoded, parameter);
41
+				}
42
+			}
43
+			return wwwFormUrlEncoded;
44
+		}
45
+		
46
+		public static string MD5(string input) {
47
+			return FormsAuthentication.HashPasswordForStoringInConfigFile(input, "MD5");
48
+		}
49
+		
50
+		public static string Post(string url, IDictionary<string, string> parameters) {
51
+			string postData = ParametersToWWWFormURLEncoded(parameters);
52
+			byte[] postDataBytes = Encoding.ASCII.GetBytes(postData);
53
+			
54
+			WebRequest webRequest = WebRequest.Create(url);
55
+			webRequest.Method = "POST";
56
+			webRequest.ContentType = "application/x-www-form-urlencoded";
57
+			webRequest.ContentLength = postDataBytes.Length;
58
+			
59
+			Stream outputStream = webRequest.GetRequestStream();
60
+			outputStream.Write(postDataBytes, 0, postDataBytes.Length);
61
+			outputStream.Close();
62
+			
63
+			WebResponse webResponse = webRequest.GetResponse();
64
+			StreamReader responseStreamReader = new StreamReader(webResponse.GetResponseStream());
65
+			return responseStreamReader.ReadToEnd().Trim();
66
+		}
67
+		
68
+		public static string XPathSearch(string input, string expression) {
69
+			XPathDocument document = new XPathDocument(new MemoryStream(Encoding.ASCII.GetBytes(input)));
70
+			XPathNavigator navigator = document.CreateNavigator();
71
+			return navigator.SelectSingleNode(expression).Value.Trim();
72
+		}
73
+		
74
+		public static string StringAtIndex(string[] strings, int index) {
75
+			if (index >= strings.Length) return "";
76
+			return strings[index];
77
+		}
78
+	}
125 79
 }
126 80
\ No newline at end of file
127 81
deleted file mode 100644
... ...
@@ -1,6 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<packages>
3
-  <package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
4
-  <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
5
-  <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net45" />
6
-</packages>
7 0
\ No newline at end of file
... ...
@@ -1,5 +1,5 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 3
   <PropertyGroup>
4 4
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 5
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
... ...
@@ -9,28 +9,7 @@
9 9
     <OutputType>Exe</OutputType>
10 10
     <RootNamespace>ChatterBotAPITest</RootNamespace>
11 11
     <AssemblyName>ChatterBotAPITest</AssemblyName>
12
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13
-    <FileUpgradeFlags>
14
-    </FileUpgradeFlags>
15
-    <UpgradeBackupLocation>
16
-    </UpgradeBackupLocation>
17
-    <OldToolsVersion>3.5</OldToolsVersion>
18
-    <TargetFrameworkProfile />
19
-    <PublishUrl>publish\</PublishUrl>
20
-    <Install>true</Install>
21
-    <InstallFrom>Disk</InstallFrom>
22
-    <UpdateEnabled>false</UpdateEnabled>
23
-    <UpdateMode>Foreground</UpdateMode>
24
-    <UpdateInterval>7</UpdateInterval>
25
-    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
26
-    <UpdatePeriodically>false</UpdatePeriodically>
27
-    <UpdateRequired>false</UpdateRequired>
28
-    <MapFileExtensions>true</MapFileExtensions>
29
-    <ApplicationRevision>0</ApplicationRevision>
30
-    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
31
-    <IsWebBootstrapper>false</IsWebBootstrapper>
32
-    <UseApplicationTrust>false</UseApplicationTrust>
33
-    <BootstrapperEnabled>true</BootstrapperEnabled>
12
+    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
34 13
   </PropertyGroup>
35 14
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
36 15
     <DebugSymbols>true</DebugSymbols>
... ...
@@ -41,7 +20,6 @@
41 20
     <ErrorReport>prompt</ErrorReport>
42 21
     <WarningLevel>4</WarningLevel>
43 22
     <ConsolePause>false</ConsolePause>
44
-    <Prefer32Bit>false</Prefer32Bit>
45 23
   </PropertyGroup>
46 24
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
47 25
     <DebugType>none</DebugType>
... ...
@@ -50,7 +28,6 @@
50 28
     <ErrorReport>prompt</ErrorReport>
51 29
     <WarningLevel>4</WarningLevel>
52 30
     <Externalconsole>true</Externalconsole>
53
-    <Prefer32Bit>false</Prefer32Bit>
54 31
   </PropertyGroup>
55 32
   <ItemGroup>
56 33
     <Reference Include="System" />
... ...
@@ -66,19 +43,4 @@
66 43
       <Name>ChatterBotAPI</Name>
67 44
     </ProjectReference>
68 45
   </ItemGroup>
69
-  <ItemGroup>
70
-    <None Include="app.config" />
71
-  </ItemGroup>
72
-  <ItemGroup>
73
-    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
74
-      <Visible>False</Visible>
75
-      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
76
-      <Install>false</Install>
77
-    </BootstrapperPackage>
78
-    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
79
-      <Visible>False</Visible>
80
-      <ProductName>.NET Framework 3.5 SP1</ProductName>
81
-      <Install>true</Install>
82
-    </BootstrapperPackage>
83
-  </ItemGroup>
84 46
 </Project>
85 47
\ No newline at end of file
... ...
@@ -20,28 +20,28 @@ using ChatterBotAPI;
20 20
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 21
 */
22 22
 namespace ChatterBotAPITest {
23
-    
24
-    class MainClass {
25
-        
26
-        public static void Main(string[] args) {
27
-            ChatterBotFactory factory = new ChatterBotFactory();
28
-
29
-            ChatterBot bot1 = factory.Create(ChatterBotType.CLEVERBOT);
30
-            ChatterBotSession bot1session = bot1.CreateSession();
31
-
32
-            ChatterBot bot2 = factory.Create(ChatterBotType.CLEVERBOT, "b0dafd24ee35a477");
33
-            ChatterBotSession bot2session = bot2.CreateSession();
34
-            
35
-            string s = "Hi";
36
-            while (true) {
37
-                
38
-                Console.WriteLine("bot1> " + s);
39
-                
40
-                s = bot2session.Think(s);
41
-                Console.WriteLine("bot2> " + s);
42
-                
43
-                s = bot1session.Think(s);
44
-            }
45
-        }
46
-    }
23
+	
24
+	class MainClass {
25
+		
26
+		public static void Main(string[] args) {
27
+			ChatterBotFactory factory = new ChatterBotFactory();
28
+			
29
+			ChatterBot bot1 = factory.Create(ChatterBotType.CLEVERBOT);
30
+			ChatterBotSession bot1session = bot1.CreateSession();
31
+			
32
+			ChatterBot bot2 = factory.Create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
33
+			ChatterBotSession bot2session = bot2.CreateSession();
34
+			
35
+			string s = "Hi";
36
+			while (true) {
37
+				
38
+				Console.WriteLine("bot1> " + s);
39
+				
40
+				s = bot2session.Think(s);
41
+				Console.WriteLine("bot2> " + s);
42
+				
43
+				s = bot1session.Think(s);
44
+			}
45
+		}
46
+	}
47 47
 }
48 48
deleted file mode 100644
... ...
@@ -1,3 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<configuration>
3
-<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
... ...
@@ -1,5 +1,4 @@
1 1
 
2
-Imports System
3 2
 Imports ChatterBotAPI
4 3
 
5 4
 '    ChatterBotAPI
... ...
@@ -1,5 +1,5 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 3
   <PropertyGroup>
4 4
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 5
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
... ...
@@ -9,28 +9,7 @@
9 9
     <OutputType>Exe</OutputType>
10 10
     <RootNamespace>ChatterBotAPITestVB</RootNamespace>
11 11
     <AssemblyName>ChatterBotAPITestVB</AssemblyName>
12
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13
-    <FileUpgradeFlags>
14
-    </FileUpgradeFlags>
15
-    <UpgradeBackupLocation>
16
-    </UpgradeBackupLocation>
17
-    <OldToolsVersion>3.5</OldToolsVersion>
18
-    <TargetFrameworkProfile />
19
-    <PublishUrl>publish\</PublishUrl>
20
-    <Install>true</Install>
21
-    <InstallFrom>Disk</InstallFrom>
22
-    <UpdateEnabled>false</UpdateEnabled>
23
-    <UpdateMode>Foreground</UpdateMode>
24
-    <UpdateInterval>7</UpdateInterval>
25
-    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
26
-    <UpdatePeriodically>false</UpdatePeriodically>
27
-    <UpdateRequired>false</UpdateRequired>
28
-    <MapFileExtensions>true</MapFileExtensions>
29
-    <ApplicationRevision>0</ApplicationRevision>
30
-    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
31
-    <IsWebBootstrapper>false</IsWebBootstrapper>
32
-    <UseApplicationTrust>false</UseApplicationTrust>
33
-    <BootstrapperEnabled>true</BootstrapperEnabled>
12
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
34 13
   </PropertyGroup>
35 14
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
36 15
     <DebugSymbols>true</DebugSymbols>
... ...
@@ -40,8 +19,6 @@
40 19
     <DefineDebug>false</DefineDebug>
41 20
     <AdditionalParameters />
42 21
     <ConsolePause>false</ConsolePause>
43
-    <NoWarn>42353,42354,42355</NoWarn>
44
-    <Prefer32Bit>false</Prefer32Bit>
45 22
   </PropertyGroup>
46 23
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
47 24
     <OutputPath>bin\Release</OutputPath>
... ...
@@ -50,8 +27,6 @@
50 27
     <DefineTrace>false</DefineTrace>
51 28
     <AdditionalParameters />
52 29
     <ConsolePause>false</ConsolePause>
53
-    <NoWarn>42353,42354,42355</NoWarn>
54
-    <Prefer32Bit>false</Prefer32Bit>
55 30
   </PropertyGroup>
56 31
   <ItemGroup>
57 32
     <Reference Include="System" />
... ...
@@ -67,22 +42,4 @@
67 42
       <Name>ChatterBotAPI</Name>
68 43
     </ProjectReference>
69 44
   </ItemGroup>
70
-  <ItemGroup>
71
-    <None Include="app.config" />
72
-  </ItemGroup>
73
-  <ItemGroup>
74
-    <Folder Include="My Project\" />
75
-  </ItemGroup>
76
-  <ItemGroup>
77
-    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
78
-      <Visible>False</Visible>
79
-      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
80
-      <Install>false</Install>
81
-    </BootstrapperPackage>
82
-    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
83
-      <Visible>False</Visible>
84
-      <ProductName>.NET Framework 3.5 SP1</ProductName>
85
-      <Install>true</Install>
86
-    </BootstrapperPackage>
87
-  </ItemGroup>
88 45
 </Project>
89 46
\ No newline at end of file
90 47
deleted file mode 100644
... ...
@@ -1,23 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<configuration>
3
-    <system.diagnostics>
4
-        <sources>
5
-            <!-- This section defines the logging configuration for My.Application.Log -->
6
-            <source name="DefaultSource" switchName="DefaultSwitch">
7
-                <listeners>
8
-                    <add name="FileLog"/>
9
-                    <!-- Uncomment the below section to write to the Application Event Log -->
10
-                    <!--<add name="EventLog"/>-->
11
-                </listeners>
12
-            </source>
13
-        </sources>
14
-        <switches>
15
-            <add name="DefaultSwitch" value="Information"/>
16
-        </switches>
17
-        <sharedListeners>
18
-            <add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter"/>
19
-            <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
20
-            <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
21
-        </sharedListeners>
22
-    </system.diagnostics>
23
-<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>