public async Task <bool> TryAsk(IChatterBotSession cleverbot, ITextChannel channel, string message) { await channel.TriggerTypingAsync().ConfigureAwait(false); var response = await cleverbot.Think(message).ConfigureAwait(false); try { await channel.SendConfirmAsync(response.SanitizeMentions()).ConfigureAwait(false); } catch { await channel.SendConfirmAsync(response.SanitizeMentions()).ConfigureAwait(false); // try twice :\ } return(true); }
public static async Task <bool> TryAsk(IChatterBotSession cleverbot, IUserMessage msg, string message) { var channel = msg.Channel; var user = msg.Author; await channel.TriggerTypingAsync().ConfigureAwait(false); var response = await cleverbot.Think(message).ConfigureAwait(false); try { await channel.SendConfirmAsync(user.Mention + " " + response.SanitizeMentions()).ConfigureAwait(false); } catch { await channel.SendConfirmAsync(user.Mention + " " + response.SanitizeMentions()).ConfigureAwait(false); // try twice :\ } return(true); }
public static async Task <string> TalkTo(string message) { return(await Task.Run(() => _cleverBotSession.Think(message))); }