private async Task ChannelRefreshBackground() { await BackgroundTaskWrapper.RunBackgroundTask(this.backgroundThreadCancellationTokenSource, async (tokenSource) => { tokenSource.Token.ThrowIfCancellationRequested(); await ChannelSession.RefreshChannel(); await Task.Delay(30000, tokenSource.Token); tokenSource.Token.ThrowIfCancellationRequested(); await ChannelSession.RefreshChannel(); await Task.Delay(30000, tokenSource.Token); tokenSource.Token.ThrowIfCancellationRequested(); foreach (UserViewModel user in await ChannelSession.ActiveUsers.GetAllWorkableUsers()) { user.UpdateMinuteData(); } foreach (UserCurrencyViewModel currency in ChannelSession.Settings.Currencies.Values) { await currency.UpdateUserData(); } await ChannelSession.SaveSettings(); tokenSource.Token.ThrowIfCancellationRequested(); }); }
public SetGameChatCommand() : base("Set Game", "setgame", 5, MixerRoleEnum.Mod) { this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) => { if (ChannelSession.Chat != null) { if (arguments.Count() > 0) { string newGameName = string.Join(" ", arguments); IEnumerable <GameTypeModel> games = await ChannelSession.Connection.GetGameTypes(newGameName); GameTypeModel newGame = games.FirstOrDefault(g => g.name.Equals(newGameName, StringComparison.CurrentCultureIgnoreCase)); if (newGame != null) { await ChannelSession.RefreshChannel(); ChannelSession.Channel.typeId = newGame.id; await ChannelSession.Connection.UpdateChannel(ChannelSession.Channel); await ChannelSession.RefreshChannel(); await ChannelSession.Chat.Whisper(user.UserName, "Game Updated: " + newGame.name); } else { await ChannelSession.Chat.Whisper(user.UserName, "We could not find a game with that name"); } } else { await ChannelSession.Chat.Whisper(user.UserName, "Usage: !setgame <GAME NAME>"); } } })); }
public override async Task CustomRun(CommandParametersModel parameters) { if (parameters.Arguments.Count() > 0) { string name = string.Join(" ", parameters.Arguments).ToLower(); IEnumerable <Twitch.Base.Models.NewAPI.Games.GameModel> games = await ChannelSession.TwitchUserConnection.GetNewAPIGamesByName(name); if (games != null && games.Count() > 0) { Twitch.Base.Models.NewAPI.Games.GameModel game = games.FirstOrDefault(g => g.name.ToLower().Equals(name)); if (game == null) { game = games.First(); } await ChannelSession.TwitchUserConnection.UpdateV5Channel(ChannelSession.TwitchChannelV5, game : game); await ChannelSession.RefreshChannel(); await ChannelSession.Services.Chat.SendMessage("Game Updated: " + game.name); return; } await ChannelSession.Services.Chat.SendMessage("We could not find a game with that name"); } else { await ChannelSession.Services.Chat.SendMessage("Usage: !setgame <GAME NAME>"); } }
public override async Task CustomRun(CommandParametersModel parameters) { string gameName = null; if (parameters.Arguments.Count() > 0) { gameName = string.Join(" ", parameters.Arguments); } else { await ChannelSession.RefreshChannel(); if (ChannelSession.TwitchChannelV5 != null) { gameName = ChannelSession.TwitchChannelV5.game; } } GameInformation details = await SteamGamePreMadeChatCommandModel.GetSteamGameInfo(gameName); if (details != null) { await ChannelSession.Services.Chat.SendMessage(details.ToString()); } else { await ChannelSession.Services.Chat.SendMessage(string.Format("Could not find the game \"{0}\" on Steam", gameName)); } }
public GameChatCommand() : base(MixItUp.Base.Resources.Game, new List <string>() { "game" }, 5, UserRoleEnum.User) { this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) => { if (ChannelSession.Services.Chat != null) { await ChannelSession.RefreshChannel(); if (ChannelSession.TwitchChannelV5 != null) { GameInformation details = await XboxGameChatCommand.GetXboxGameInfo(ChannelSession.TwitchChannelV5.game); if (details == null) { details = await SteamGameChatCommand.GetSteamGameInfo(ChannelSession.TwitchChannelV5.game); } if (details != null) { await ChannelSession.Services.Chat.SendMessage(details.ToString()); } else { await ChannelSession.Services.Chat.SendMessage("Game: " + ChannelSession.TwitchChannelV5.game); } } } })); }
public SetAudienceChatCommand() : base("Set Audience", "setaudience", 5, MixerRoleEnum.Mod) { this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) => { if (ChannelSession.Chat != null) { if (arguments.Count() == 1) { string rating = arguments.ElementAt(0); if (rating.Equals(FamilySetting) || rating.Equals(TeenSetting) || rating.Equals(AdultSettings) || rating.Equals(Adult18PlusSetting)) { await ChannelSession.RefreshChannel(); rating = rating.ToLower().Replace(AdultSettings, Adult18PlusSetting); ChannelSession.Channel.audience = rating; await ChannelSession.Connection.UpdateChannel(ChannelSession.Channel); await ChannelSession.RefreshChannel(); return; } } await ChannelSession.Chat.Whisper(user.UserName, "Usage: !setaudience family|teen|adult"); } })); }
public SteamGameChatCommand() : base(MixItUp.Base.Resources.SteamGame, new List <string>() { "steamgame", "steam" }, 5, UserRoleEnum.User) { this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) => { if (ChannelSession.Services.Chat != null) { string gameName = null; if (arguments.Count() > 0) { gameName = string.Join(" ", arguments); } else { await ChannelSession.RefreshChannel(); if (ChannelSession.TwitchChannelV5 != null) { gameName = ChannelSession.TwitchChannelV5.game; } } GameInformation details = await SteamGameChatCommand.GetSteamGameInfo(gameName); if (details != null) { await ChannelSession.Services.Chat.SendMessage(details.ToString()); } else { await ChannelSession.Services.Chat.SendMessage(string.Format("Could not find the game \"{0}\" on Steam", gameName)); } } })); }
public SteamGameChatCommand() : base("Steam Game", new List <string>() { "steamgame", "steam" }, UserRole.User, 30) { this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) => { if (ChannelSession.Chat != null) { string gameName; if (arguments.Count() > 0) { gameName = string.Join(" ", arguments); } else { await ChannelSession.RefreshChannel(); gameName = ChannelSession.Channel.type.name; } string details = await SteamGameChatCommand.GetSteamGameInfo(gameName); if (!string.IsNullOrEmpty(details)) { await ChannelSession.Chat.SendMessage(details); } else { await ChannelSession.Chat.SendMessage(string.Format("Could not find the game \"{0}\" on Steam", gameName)); } } })); }
private async void UpdateChannelDataButton_Click(object sender, System.Windows.RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(this.StreamTitleTextBox.Text)) { await MessageBoxHelper.ShowMessageDialog("A stream title must be specified"); return; } GameTypeModel gameType = await GetValidGameType(this.GameNameTextBox.Text); if (gameType == null) { await MessageBoxHelper.ShowMessageDialog("A valid & existing game name must be selected"); return; } if (this.AgeRatingComboBox.SelectedIndex < 0) { await MessageBoxHelper.ShowMessageDialog("A valid age rating must be selected"); return; } await this.Window.RunAsyncOperation(async() => { await ChannelSession.Connection.UpdateChannel(ChannelSession.Channel.id, this.StreamTitleTextBox.Text, gameType.id, ((string)this.AgeRatingComboBox.SelectedItem).ToLower()); await ChannelSession.RefreshChannel(); }); }
private async void FindChannelToRaidButton_Click(object sender, System.Windows.RoutedEventArgs e) { await this.Window.RunAsyncOperation(async() => { if (this.ChannelToRaidSearchCriteriaComboBox.SelectedIndex < 0) { await MessageBoxHelper.ShowMessageDialog("Must select a search criteria for finding a channel to raid"); return; } await ChannelSession.RefreshChannel(); IEnumerable <ChannelModel> channels = null; RaidSearchCriteriaEnum searchCriteria = EnumHelper.GetEnumValueFromString <RaidSearchCriteriaEnum>((string)this.ChannelToRaidSearchCriteriaComboBox.SelectedItem); if (searchCriteria == RaidSearchCriteriaEnum.SameGame) { channels = await ChannelSession.Connection.GetChannelsByGameTypes(ChannelSession.Channel.type, 1); } else { channels = await ChannelSession.Connection.GetChannels(500); switch (searchCriteria) { case RaidSearchCriteriaEnum.AgeRating: channels = channels.Where(c => c.audience.Equals(ChannelSession.Channel.audience)); break; case RaidSearchCriteriaEnum.LargeStreamer: channels = channels.Where(c => c.viewersCurrent >= 25); break; case RaidSearchCriteriaEnum.MediumStreamer: channels = channels.Where(c => c.viewersCurrent >= 10 && c.viewersCurrent < 25); break; case RaidSearchCriteriaEnum.SmallStreamer: channels = channels.Where(c => c.viewersCurrent < 10); break; case RaidSearchCriteriaEnum.PartneredStreamer: channels = channels.Where(c => c.partnered); break; } } this.ChannelRaidNameTextBox.Clear(); if (channels != null && channels.Count() > 0) { Random random = new Random(); ChannelModel channelToRaid = channels.ElementAt(random.Next(0, channels.Count())); UserModel user = await ChannelSession.Connection.GetUser(channelToRaid.userId); this.ChannelRaidNameTextBox.Text = user.username; } else { await MessageBoxHelper.ShowMessageDialog("Unable to find a channel that met your search critera, please try selecting a different option"); } }); }
public XboxGameChatCommand() : base("Xbox Game", new List <string>() { "xboxgame" }, 5, MixerRoleEnum.User) { this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) => { if (ChannelSession.Chat != null) { string gameName; if (arguments.Count() > 0) { gameName = string.Join(" ", arguments); } else { await ChannelSession.RefreshChannel(); gameName = ChannelSession.Channel.type.name; } GameInformation details = await XboxGameChatCommand.GetXboxGameInfo(gameName); if (details != null) { await ChannelSession.Chat.SendMessage(details.ToString()); } else { await ChannelSession.Chat.SendMessage(string.Format("Could not find the game \"{0}\" on Xbox", gameName)); } } })); }
public SetGameChatCommand() : base(MixItUp.Base.Resources.SetGame, "setgame", 5, UserRoleEnum.Mod) { this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) => { if (ChannelSession.Services.Chat != null) { if (arguments.Count() > 0) { string name = string.Join(" ", arguments).ToLower(); IEnumerable <Twitch.Base.Models.NewAPI.Games.GameModel> games = await ChannelSession.TwitchUserConnection.GetNewAPIGamesByName(name); if (games != null && games.Count() > 0) { Twitch.Base.Models.NewAPI.Games.GameModel game = games.FirstOrDefault(g => g.name.ToLower().Equals(name)); if (game == null) { game = games.First(); } await ChannelSession.TwitchUserConnection.UpdateV5Channel(ChannelSession.TwitchChannelV5, game: game); await ChannelSession.RefreshChannel(); await ChannelSession.Services.Chat.SendMessage("Game Updated: " + game.name); return; } await ChannelSession.Services.Chat.SendMessage("We could not find a game with that name"); } else { await ChannelSession.Services.Chat.SendMessage("Usage: !setgame <GAME NAME>"); } } })); }
public TitleChatCommand() : base("Title", new List <string>() { "title", "stream" }, 5, MixerRoleEnum.User) { this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) => { if (ChannelSession.Chat != null) { await ChannelSession.RefreshChannel(); await ChannelSession.Chat.SendMessage("Stream Title: " + ChannelSession.Channel.name); } })); }
public TitleChatCommand() : base(MixItUp.Base.Resources.Title, new List <string>() { "title", "stream" }, 5, UserRoleEnum.User) { this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) => { if (ChannelSession.Services.Chat != null) { await ChannelSession.RefreshChannel(); await ChannelSession.Services.Chat.SendMessage("Stream Title: " + ChannelSession.TwitchChannelV5.status); } })); }
private async Task ChannelRefreshBackground() { await BackgroundTaskWrapper.RunBackgroundTask(this.backgroundThreadCancellationTokenSource, async (tokenSource) => { tokenSource.Token.ThrowIfCancellationRequested(); await ChannelSession.RefreshChannel(); await Task.Delay(30000); tokenSource.Token.ThrowIfCancellationRequested(); await ChannelSession.RefreshChannel(); await Task.Delay(30000); tokenSource.Token.ThrowIfCancellationRequested(); List <UserCurrencyViewModel> currenciesToUpdate = new List <UserCurrencyViewModel>(); foreach (UserCurrencyViewModel currency in ChannelSession.Settings.Currencies.Values) { if (currency.IsActive) { currenciesToUpdate.Add(currency); } } await this.UpdateEachUser((user) => { user.Data.ViewingMinutes++; foreach (UserCurrencyViewModel currency in currenciesToUpdate) { if ((user.Data.ViewingMinutes % currency.AcquireInterval) == 0) { user.Data.AddCurrencyAmount(currency, currency.AcquireAmount); if (user.Roles.Contains(UserRole.Subscriber)) { user.Data.AddCurrencyAmount(currency, currency.SubscriberBonus); } } } return(Task.FromResult(0)); }); tokenSource.Token.ThrowIfCancellationRequested(); await ChannelSession.SaveSettings(); }); }
public override async Task CustomRun(CommandParametersModel parameters) { if (parameters.Arguments.Count() > 0) { string name = string.Join(" ", parameters.Arguments); await ChannelSession.TwitchUserConnection.UpdateV5Channel(ChannelSession.TwitchChannelV5, status : name); await ChannelSession.RefreshChannel(); await ChannelSession.Services.Chat.SendMessage("Title Updated: " + name); return; } else { await ChannelSession.Services.Chat.SendMessage("Usage: !settitle <TITLE NAME>"); } }
public SetTitleChatCommand() : base("Set Title", "settitle", 5, MixerRoleEnum.Mod) { this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) => { if (ChannelSession.Chat != null) { if (arguments.Count() > 0) { await ChannelSession.Connection.UpdateChannel(ChannelSession.Channel.id, name: string.Join(" ", arguments)); await ChannelSession.RefreshChannel(); } else { await ChannelSession.Chat.Whisper(user.UserName, "Usage: !settitle <TITLE NAME>"); } } })); }
public GameChatCommand() : base("Game", new List <string>() { "game" }, UserRole.User, 5) { this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) => { if (ChannelSession.Chat != null) { await ChannelSession.RefreshChannel(); string details = await SteamGameChatCommand.GetSteamGameInfo(ChannelSession.Channel.type.name); if (!string.IsNullOrEmpty(details)) { await ChannelSession.Chat.SendMessage(details); } else { await ChannelSession.Chat.SendMessage("Game: " + ChannelSession.Channel.type.name); } } })); }
public SetTitleChatCommand() : base(MixItUp.Base.Resources.SetTitle, "settitle", 5, UserRoleEnum.Mod) { this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) => { if (ChannelSession.Services.Chat != null) { if (arguments.Count() > 0) { string name = string.Join(" ", arguments); await ChannelSession.TwitchUserConnection.UpdateV5Channel(ChannelSession.TwitchChannelV5, status: name); await ChannelSession.RefreshChannel(); await ChannelSession.Services.Chat.SendMessage("Title Updated: " + name); return; } else { await ChannelSession.Services.Chat.SendMessage("Usage: !settitle <TITLE NAME>"); } } })); }
public override async Task CustomRun(CommandParametersModel parameters) { await ChannelSession.RefreshChannel(); if (ChannelSession.TwitchChannelV5 != null) { GameInformation details = await XboxGamePreMadeChatCommandModel.GetXboxGameInfo(ChannelSession.TwitchChannelV5.game); if (details == null) { details = await SteamGamePreMadeChatCommandModel.GetSteamGameInfo(ChannelSession.TwitchChannelV5.game); } if (details != null) { await ChannelSession.Services.Chat.SendMessage(details.ToString()); } else { await ChannelSession.Services.Chat.SendMessage("Game: " + ChannelSession.TwitchChannelV5.game); } } }
protected override async Task PerformInternal(CommandParametersModel parameters) { await ChannelSession.RefreshChannel(); await ChannelSession.Services.Chat.SendMessage("Stream Title: " + ChannelSession.TwitchChannelV5.status); }
private async void FindChannelToRaidButton_Click(object sender, System.Windows.RoutedEventArgs e) { await this.Window.RunAsyncOperation(async() => { if (this.ChannelToRaidSearchCriteriaComboBox.SelectedIndex < 0) { await MessageBoxHelper.ShowMessageDialog("Must select a search criteria for finding a channel to raid"); return; } await ChannelSession.RefreshChannel(); IEnumerable <ChannelModel> channels = null; RaidSearchCriteriaEnum searchCriteria = EnumHelper.GetEnumValueFromString <RaidSearchCriteriaEnum>((string)this.ChannelToRaidSearchCriteriaComboBox.SelectedItem); if (searchCriteria == RaidSearchCriteriaEnum.SameGame) { channels = await ChannelSession.Connection.GetChannelsByGameTypes(ChannelSession.Channel.type, 1); } else if (searchCriteria == RaidSearchCriteriaEnum.SameTeam) { Dictionary <uint, UserWithChannelModel> teamChannels = new Dictionary <uint, UserWithChannelModel>(); foreach (TeamMembershipExpandedModel extendedTeam in await ChannelSession.Connection.GetUserTeams(ChannelSession.User)) { TeamModel team = await ChannelSession.Connection.GetTeam(extendedTeam.id); IEnumerable <UserWithChannelModel> teamUsers = await ChannelSession.Connection.GetTeamUsers(team); foreach (UserWithChannelModel userChannel in teamUsers.Where(u => u.channel.online)) { teamChannels[userChannel.id] = userChannel; } } channels = teamChannels.Values.Select(c => c.channel); } else { string query = "channels"; if (searchCriteria == RaidSearchCriteriaEnum.AgeRating) { query += "?where=audience:eq:" + ChannelSession.Channel.audience; } else if (searchCriteria == RaidSearchCriteriaEnum.LargeStreamer) { query += "?where=viewersCurrent:gte:25"; } else if (searchCriteria == RaidSearchCriteriaEnum.MediumStreamer) { query += "?where=viewersCurrent:gte:10,viewersCurrent:lt:25"; } else if (searchCriteria == RaidSearchCriteriaEnum.SmallStreamer) { query += "?where=viewersCurrent:gt:0,viewersCurrent:lt:10"; } else if (searchCriteria == RaidSearchCriteriaEnum.PartneredStreamer) { query += "?where=partnered:eq:true"; } channels = await ChannelSession.Connection.Connection.Channels.GetPagedNumberAsync <ChannelModel>(query, 50, linkPagesAvailable: false); } this.ChannelRaidNameTextBox.Clear(); if (channels != null && channels.Count() > 0) { this.channelToRaid = channels.ElementAt(RandomHelper.GenerateRandomNumber(channels.Count())); UserModel user = await ChannelSession.Connection.GetUser(this.channelToRaid.userId); GameTypeModel game = await ChannelSession.Connection.GetGameType(this.channelToRaid.typeId.GetValueOrDefault()); this.ChannelRaidNameTextBox.Text = user.username; this.ChannelRaidViewersTextBox.Text = this.channelToRaid.viewersCurrent.ToString(); this.ChannelRaidAudienceTextBox.Text = EnumHelper.GetEnumName(EnumHelper.GetEnumValueFromString <AgeRatingEnum>(this.channelToRaid.audience)); this.ChannelRaidGameTextBox.Text = (game != null) ? game.name : "Unknown"; } else { await MessageBoxHelper.ShowMessageDialog("Unable to find a channel that met your search critera, please try selecting a different option"); } }); }
public override async Task CustomRun(CommandParametersModel parameters) { await ChannelSession.RefreshChannel(); await ChannelSession.Services.Chat.SendMessage("Stream Title: " + ChannelSession.TwitchChannelV5.status); }