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 static void SkipSong(ChatMessage user, string body, PlayerBotCommand command) { string responseMessage = ""; bool coinSystemSuccess = true; try { if (ConfigSet.Config.PlayerConfig.IsUsingCoinSystem) { var tmpUser = AssistantDb.Instance.Viewers.GetAll().First(user1 => user1.Username == user.Username); MinRangCheck(tmpUser); if (!CoinSystem.CoinSystem.Instance.SubtractCoins(tmpUser, ConfigSet.Config.PlayerConfig.SkipSongPrice)) { coinSystemSuccess = false; responseMessage = $"not enough coins! Skip song price : {ConfigSet.Config.PlayerConfig.SkipSongPrice} . You balance : {tmpUser.Coins} {ConfigSet.Config.CoinConfig.CoinsName}"; } } if (coinSystemSuccess) { responseMessage = $"skipped song! Title : '{MyPlayer.Instance.CurrentSong.Title}'"; MyPlayer.Instance.PlayNextSong(); } } catch (Exception e) { responseMessage = e.Message; } Bot.CommandMessage(user.Username, responseMessage, command); }
private void ButtonBase_OnClick(object sender, System.Windows.RoutedEventArgs e) { int id = Int32.Parse(((Button)sender).Tag.ToString()); DetailsCommandSettingsWindow settingsWindow = new DetailsCommandSettingsWindow(); PlayerBotCommand xCommand = CommandsController.PlayerCommandsList.FirstOrDefault(command => command.Id == id); settingsWindow.DataContext = new DetailsCommandSettingsViewModel <PlayerBotCommand>(xCommand); settingsWindow.ShowDialog(); }
public static void ChatPlaylist(ChatMessage user, string body, PlayerBotCommand command) { string responseMessage = MyPlayer.Instance.GetChatPlaylistInfo(); if (responseMessage == "") { responseMessage = "Chat playlist is empty"; } Bot.CommandMessage(user.Username, responseMessage, command); }
private static void SongRequestFirst(ChatMessage user, string body, PlayerBotCommand command) { string playerResponse = "empty"; try { if (ConfigSet.Config.PlayerConfig.ChatPlaylistOn) { var tmpUser = AssistantDb.Instance.Viewers.GetAll().First(user1 => user1.Username == user.Username); MinRangCheck(tmpUser); bool coinSystemSuccess = false; if (ConfigSet.Config.PlayerConfig.IsUsingCoinSystem) { if (CoinSystem.CoinSystem.Instance.SubtractCoins(tmpUser, ConfigSet.Config.PlayerConfig.FirstSongPrice)) { coinSystemSuccess = true; } else { playerResponse = $"not enough coins! First song price : {ConfigSet.Config.PlayerConfig.FirstSongPrice} . You balance : {tmpUser.Coins} {ConfigSet.Config.CoinConfig.CoinsName}"; } } else { coinSystemSuccess = true; } if (coinSystemSuccess) { playerResponse = MyPlayer.Instance.AddFirstChatSong(body, user.Username); if (playerResponse == "") { playerResponse = "Song not found or invalid link =("; if (ConfigSet.Config.PlayerConfig.IsUsingCoinSystem) { CoinSystem.CoinSystem.Instance.AddCoins(tmpUser, ConfigSet.Config.PlayerConfig.SongPrice); } } } } else { playerResponse = "Chat playlist disabled !"; } } catch (Exception e) { playerResponse = e.Message; } Bot.CommandMessage(user.Username, playerResponse, command); }
public static void SongQeueLeght(ChatMessage user, string body, PlayerBotCommand command) { string responseMessage = ""; try { var length = MyPlayer.Instance.ChatPlayList.Count - MyPlayer.Instance.LastChatSong.Index; responseMessage = $"In playlist queue {length} song(s)"; } catch (Exception e) { responseMessage = $"Playlist is empty!"; } Bot.CommandMessage(user.Username, responseMessage, command); }
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 CurentSong(ChatMessage user, string body, PlayerBotCommand command) { string responseMessage = MyPlayer.Instance.GetCurrentSongInfo(); Bot.CommandMessage(user.Username, responseMessage, command); }