Ejemplo n.º 1
0
        public string ReloadBot(string id)
        {
            try
            {
                Platform.LogEvent("Reload bot " + id, ConsoleColor.DarkCyan);
                long bid = long.Parse(id);
                Platform.Synchronize();

                List <User> bots = Platform.DBManager.Users.Where(x => x.Id == bid).ToList();
                if (bots.Count > 0)
                {
                    Chatbot cb = Platform.Chatbots.Where(x => x.User.Id == bid).ToList()[0];
                    cb.ReloadBot(bots[0]);
                    return(JsonConvert.SerializeObject(new GoodResponse("OK", "The bot has been successfully reloaded")));
                }
                else
                {
                    return(JsonConvert.SerializeObject(new ErrorResponse("BOT_NOT_EXIST", "This bot does not exist")));
                }
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(new ErrorResponse("FAILED", ex.Message)));
            }
        }
Ejemplo n.º 2
0
        public string Answer(string message, Chatbot bot)
        {
            Request r   = new Request(message, bot.BotUser, BotEngine);
            Result  res = BotEngine.Chat(r);

            return(res.Output.Length == 0?"I can't understand":res.Output);
        }
Ejemplo n.º 3
0
        public static void AddBot(User bot)
        {
            Chatbot chat = new Chatbot(bot);

            Chatbots.Add(chat);

            chat.ReloadBot(bot);
        }