private void SetUpEvents() { _hubConnection.On <CurrentSong>("startSongCommandNotification", currentSong => { OnSongStarted?.Invoke(this, currentSong); }); _hubConnection.On <CurrentSong>("finishSongCommandNotification", currentSong => { OnSongFinished?.Invoke(this, currentSong); }); _hubConnection.On <Song>("addSongCommandNotification", song => { OnSongAdded?.Invoke(this, song); }); _hubConnection.On <SongToRemove>("removeSongCommandNotification", song => { OnRemoveSong?.Invoke(this, song); }); _hubConnection.On("endSessionCommandNotification", () => { OnSessionEnded?.Invoke(this, null); }); _hubConnection.On("startSessionCommandNotification", () => { OnRemoveSong?.Invoke(this, null); }); }
private TwitchBot() { CommandDictionary = new Dictionary <string, Action <OnMessageReceivedArgs, List <string> > >(StringComparer.CurrentCultureIgnoreCase) { { "song", (e, f) => { OnCurrentSong?.Invoke(null, new BotCommandContainer(SongRequestCommandType.CurrentSong, e.ChatMessage.Username, null)); } }, { "remove", (e, f) => { if (f.Count > 2) { OnRemoveSong.Invoke(null, new BotCommandContainer(SongRequestCommandType.RemoveSong, e.ChatMessage.Username, f[2])); // Remove index } else { OnRemoveSong.Invoke(null, new BotCommandContainer(SongRequestCommandType.RemoveSong, e.ChatMessage.Username, null)); // Remove first } } }, { "removeall", (e, f) => { OnRemoveAllSongs.Invoke(null, new BotCommandContainer(SongRequestCommandType.RemoveAllSongs, e.ChatMessage.Username, null)); // Remove all } }, { "showlist", (e, f) => { OnPrintSongList.Invoke(null, new BotCommandContainer(SongRequestCommandType.PrintSongList, e.ChatMessage.Username, null)); } }, { "showmylist", (e, f) => { OnPrintUserSongRequests.Invoke(null, new BotCommandContainer(SongRequestCommandType.PrintUserSongRequest, e.ChatMessage.Username, null)); } }, { "skip", (e, f) => { if (e.ChatMessage.IsModerator) { OnSkipSong.Invoke(null, new BotCommandContainer(SongRequestCommandType.SkipSong, e.ChatMessage.Username, null)); } else { client.SendMessage(TwitchUsername, e.ChatMessage.Username + " : You do not have permission to use this command."); } } }, { "pause", (e, f) => { if (e.ChatMessage.IsModerator) { OnPauseSongRequests.Invoke(null, new BotCommandContainer(SongRequestCommandType.PauseSongRequests, e.ChatMessage.Username, null)); } else { client.SendMessage(TwitchUsername, e.ChatMessage.Username + " : You do not have permission to use this command."); } } }, { "play", (e, f) => { if (e.ChatMessage.IsModerator) { OnPlaySongRequests.Invoke(null, new BotCommandContainer(SongRequestCommandType.PlaySongRequests, e.ChatMessage.Username, null)); } else { client.SendMessage(TwitchUsername, e.ChatMessage.Username + " : You do not have permission to use this command."); } } }, { "clear", (e, f) => { if (e.ChatMessage.IsModerator) { OnClearSongRequests.Invoke(null, new BotCommandContainer(SongRequestCommandType.ClearSongRequests, e.ChatMessage.Username, null)); } else { client.SendMessage(TwitchUsername, e.ChatMessage.Username + " : You do not have permission to use this command."); } } }, { "help", (e, f) => { client.SendMessage(TwitchUsername, e.ChatMessage.Username + " : !SR commands: *media link* = Adds song to the song list ||" + " remove = Remove your latest song ||" + " showlist = Shows the next 5 songs in the song list ||" + " showmylist = Shows the songs you have added to the list ||" + " remove # = Remove song at index starting with earliest ||" + " removeall = Remove all songs you have added ||" + " skip (MOD ONLY) = Skips the current song ||" + " play (MOD ONLY) = Plays the current song ||" + " pause (MOD ONLY) = Pauses the current song ||" + " clear (MOD ONLY) = Wipes the current song list"); } }, { "", (e, f) => { client.SendMessage(TwitchUsername, AboutText); // Help text or bot info } } }; }