Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
 public static async Task <string> TalkTo(string message)
 {
     return(await Task.Run(() => _cleverBotSession.Think(message)));
 }