Beispiel #1
0
        static void Main(string[] args)
        {
            Cleverbot cleverbot = new Cleverbot("API_KEY");

            Console.WriteLine("Speak Now");
            SpeechSynthesizer synthesizer = new SpeechSynthesizer();

            synthesizer.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Teen); // to change VoiceGender and VoiceAge check out those links below
            synthesizer.Volume = 100;                                          // (0 - 100)
            synthesizer.Rate   = 0;                                            // (-10 - 10)
            while (true)
            {
                SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine();
                Grammar dictationGrammar           = new DictationGrammar();
                recognizer.LoadGrammar(dictationGrammar);
                recognizer.SetInputToDefaultAudioDevice();
                RecognitionResult result = recognizer.Recognize();
                string            res    = "";
                if (result == null)
                {
                    res = "did you get that?";
                }
                else
                {
                    res = result.Text;
                }
                Console.WriteLine(res);
                string question = cleverbot.Ask(res);
                Console.WriteLine("Cleverbot: " + question);
                synthesizer.SpeakAsync(question);
            }
        }
Beispiel #2
0
 public CommandHandler(IServiceProvider provider)
 {
     Provider = provider;
     Client   = provider.GetService <DiscordSocketClient>();
     Config   = provider.GetService <Config>();
     Client.MessageReceived += ProcessCommandAsync;
     Commands      = provider.GetService <CommandService>();
     BaseModules   = new Dictionary <Type, ModuleInfo>();
     CleverbotAPI  = new Cleverbot(Config.CleverbotApiKey);
     PrefixService = provider.GetService <PrefixService>();
 }
Beispiel #3
0
        public async Task <IServiceProvider> ConfigureServices()
        {
            Imgur ImgurConnect = new Imgur(WebConnect);
            await ImgurConnect.LoadConfig(new FileData("Config/ImgurConfig.json"));

            await ImgurConnect.SetupConnection();

            WeatherUnderground WeatherUndergroundConnect = new WeatherUnderground(WebConnect);
            await WeatherUndergroundConnect.LoadConfig(new FileData("Config/WeatherUndergroundConfig.json"));

            Cleverbot CleverbotConnect = new Cleverbot(WebConnect);
            await CleverbotConnect.LoadConfig(new FileData("Config/CleverbotConfig.json"));


            var sc = new ServiceCollection();

            sc.AddSingleton(Client);
            sc.AddSingleton(Console);
            sc.AddSingleton(ImgurConnect);
            sc.AddSingleton(WeatherUndergroundConnect);
            sc.AddSingleton(CleverbotConnect);
            sc.AddSingleton <CommandHandler>();
            sc.AddSingleton(new CommandService(new CommandServiceConfig {
                CaseSensitiveCommands = false, ThrowOnError = true
            }));
            sc.AddSingleton(new TestService("testing: ", Console));
            sc.AddSingleton <WeatherUndergroundService>();
            sc.AddSingleton <ImgurService>();
            sc.AddSingleton <CleverbotService>();
            sc.AddSingleton <ScheduleMaker>();
            sc.AddSingleton <TvModeService>();

            var sp = sc.BuildServiceProvider();

            sp.GetService <TestService>();
            sp.GetService <ImgurService>();
            sp.GetService <CleverbotService>();
            sp.GetService <TvModeService>();
            sp.GetService <WeatherUndergroundService>();
            return(sp);
        }
Beispiel #4
0
        public async Task CleverbotLoop()
        {
            Cleverbot cleverbot = new Cleverbot("your-api-key");

            Console.WriteLine("Hello in the Cleverbot.Net test app, please type your message.\n");

            while (true)
            {
                Console.ForegroundColor = ConsoleColor.Gray;

                string msg = Console.ReadLine();

                cleverbot.GetResponseAsync(msg, x =>
                {
                    Console.CursorLeft = 0;

                    Console.ForegroundColor = ConsoleColor.White;

                    Console.WriteLine(x.Response);
                });

                Console.Write("...");
            }
        }
Beispiel #5
0
 public CleverbotService(Cleverbot cleverbot, ServerUpdater <string> console, DiscordSocketClient client) : base(console, client)
 {
     CleverbotConnect = cleverbot;
     CommandName      = "chat";
 }