Beispiel #1
0
        public static string getChatResponse(CleverbotSession session, string message)
        {
            string response = session.Send(message);

            return(response);
        }
        private async void BotOnMessageReceived(object sender, MessageEventArgs e)
        {
            if (Active)
            {
                listBox1.Invoke(
                    new add(addToListbox),
                    new object[] {
                    e.Message.From.FirstName + ": " + e.Message.Text.ToString()
                }
                    );
                switch (e.Message.Text)
                {
                case "?chatfirstname":
                    await bot.SendTextMessageAsync(e.Message.From.Id, e.Message.From.FirstName);

                    break;

                case "?chatlastname":
                    await bot.SendTextMessageAsync(e.Message.From.Id, e.Message.From.LastName);

                    break;

                case "?chatusername":
                    await bot.SendTextMessageAsync(e.Message.From.Id, e.Message.From.Username);

                    break;

                case "?cpu":
                    await bot.SendTextMessageAsync(e.Message.From.Id, mComputerUsage.getCurrentCpuUsage());

                    break;

                case "?ram":
                    await bot.SendTextMessageAsync(e.Message.From.Id, mComputerUsage.getAvailableRAM());

                    break;

                //case "/shutdown":
                //    await bot.SendTextMessageAsync(e.Message.From.Id, mComputerUsage.shutdown());
                //    break;
                //case "/restart":
                //    await bot.SendTextMessageAsync(e.Message.From.Id, mComputerUsage.restart());
                //    break;
                case "/sperren":
                    await bot.SendTextMessageAsync(e.Message.From.Id, mComputerUsage.lockWorkstation());

                    break;

                default:
                    if (e.Message.Text.StartsWith("?") || e.Message.Text.StartsWith("/"))
                    {
                        await bot.SendTextMessageAsync(e.Message.From.Id, "Diese Befehl ist mir leider nicht bekannt");
                    }
                    else
                    {
                        string answer = session.Send(e.Message.Text);
                        await bot.SendTextMessageAsync(e.Message.From.Id, answer);

                        listBox1.Invoke(
                            new add(addToListbox),
                            new object[] {
                            e.Message.From.FirstName + ": " + "Message: " + e.Message.Text + "\n" + " ~~ Bot: " + answer
                        });
                    }

                    break;
                }
            }
        }