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))); } }
public static void AddBot(User bot) { Chatbot chat = new Chatbot(bot); Chatbots.Add(chat); chat.ReloadBot(bot); }