private static void InitAllCommands() { List <DefaultCommand> defaultCommands = AssistantDb.Instance.DefaultCommands.GetAll().ToList(); foreach (var command in defaultCommands) { DefaultBotCommand newCommand = new DefaultBotCommand(command); newCommand.SetNewAction(DefaultCommandsFunctional.Actions[command.Action]); DefaultCommandsList.Add(newCommand); } List <PlayerCommand> playerCommands = AssistantDb.Instance.PlayerCommands.GetAll().ToList(); foreach (var command in playerCommands) { PlayerBotCommand newCommand = new PlayerBotCommand(command); newCommand.SetNewAction(PlayerCommandsFunctional.Actions[command.Action]); PlayerCommandsList.Add(newCommand); } List <CustomCommand> customCoommands = AssistantDb.Instance.CustomCommands.GetAll().ToList(); foreach (var command in customCoommands) { CustomBotCommand newCommand = new CustomBotCommand(command); newCommand.SetNewAction(CustomCommandsFunctional.Actions[command.Action]); newCommand.ResponseMessage = command.ResponseMessage; CustomCommandsList.Add(newCommand); } }
private void AddCommand() { int newCommandId = Guid.NewGuid().GetHashCode(); CustomBotCommand command = new CustomBotCommand() { Id = newCommandId, Name = "Command", IsMessage = true, IsWhisp = false, IsEnabled = true, Description = "You command description", IsUserLevelErrorResponse = true, UserLevel = TwitchRangs.Unfollower, GlobalCooldown = new TimeSpan(0, 0, 5), IsGlobalCooldown = false, IsGlobalErrorResponse = false, IsWhispErrors = false, IsChatErrors = false, ActionName = "SendCustomCommandMessage", ResponseMessage = "You message" }; command.SetNewAction(CustomCommandsFunctional.Actions[command.ActionName]); Commands.Add(command); }
private void DetailSettingsBtn_OnClick(object sender, RoutedEventArgs e) { int id = Int32.Parse(((Button)sender).Tag.ToString()); DetailsCommandSettingsWindow settingsWindow = new DetailsCommandSettingsWindow(); CustomBotCommand xCommand = CommandsController.CustomCommandsList.FirstOrDefault(command => command.Id == id); settingsWindow.DataContext = new DetailsCommandSettingsViewModel <CustomBotCommand>(xCommand); settingsWindow.ShowDialog(); }
public static bool ExecuteCommandByName(ChatMessage user, string commandName, string commandBody = null) { try { TwitchBotGlobalObjects.CheckAndAddOrEditUserIfNeed(user); DefaultBotCommand xBotCommand = DefaultCommandsList.FirstOrDefault(command => "!" + command.Name == commandName); TryExecuteCommand(user, commandBody, xBotCommand); PlayerBotCommand xPlayerCommand = PlayerCommandsList.FirstOrDefault(command => "!" + command.Name == commandName); TryExecuteCommand(user, commandBody, xPlayerCommand); CustomBotCommand xCustomCommand = CustomCommandsList.FirstOrDefault(command => "!" + command.Name == commandName); TryExecuteCommand(user, commandBody, xCustomCommand); return(true); } catch (Exception e) { return(false); } }
public static void SendCustomCommandMessage(ChatMessage user, string body, CustomBotCommand command) { Bot.CommandMessage(user.Username, command.ResponseMessage, command); }