internal static async Task <CleverbotResponse> CreateAsync(string message, string conversationId, string apiKey) { WebClient c = new WebClient(); string conversationLine = (string.IsNullOrWhiteSpace(conversationId) ? "" : $"&cs={conversationId}"); byte[] bytesRecieved = await c.DownloadDataTaskAsync($"https://www.cleverbot.com/getreply?key={ apiKey }&wrapper=cleverbot.net&input={ message }{ conversationLine }"); if (bytesRecieved == null) { return(null); } string result = Encoding.UTF8.GetString(bytesRecieved); CleverbotResponse response = JsonConvert.DeserializeObject <CleverbotResponse>(result); if (response == null) { return(null); } response.apiKey = apiKey; response.CreateInteractionsList(); return(response); }
internal static async Task <CleverbotResponse> CreateAsync(string message, string conversationId, string apiKey, int?wacky = null, int?talkative = null, int?attentive = null) { HttpClient c = new HttpClient(); string conversationLine = (string.IsNullOrWhiteSpace(conversationId) ? "" : $"&cs={conversationId}"); string tweak_1 = wacky.HasValue ? $"&cb_settings_tweak1={wacky.Value}" : ""; string tweak_2 = talkative.HasValue ? $"&cb_settings_tweak2={talkative.Value}" : ""; string tweak_3 = attentive.HasValue ? $"&cb_settings_tweak3={attentive.Value}" : ""; byte[] bytesReceived = await c.GetByteArrayAsync($"https://www.cleverbot.com/getreply?key={ apiKey }&wrapper=cleverbot.net&input={ message }{ conversationLine }{tweak_1}{tweak_2}{tweak_3}").ConfigureAwait(false); if (bytesReceived == null) { return(null); } string result = Encoding.UTF8.GetString(bytesReceived, 0, bytesReceived.Length); CleverbotResponse response = JsonConvert.DeserializeObject <CleverbotResponse>(result); if (response == null) { return(null); } response.apiKey = apiKey; response.CreateInteractionsList(); return(response); }