public async Task <IChannelSettings> Create(ExpandedChannelModel channel, bool isStreamer) { IChannelSettings settings = new DesktopChannelSettings(channel, isStreamer); if (File.Exists(this.GetFilePath(settings))) { var tempSettings = await this.LoadSettings(this.GetFilePath(settings)); if (tempSettings == null) { GlobalEvents.ShowMessageBox("We were unable to load your settings file due to file corruption. Unfortunately, we could not repair your settings." + Environment.NewLine + Environment.NewLine + "We apologize for this inconvenience. If you have backups, you can restore them from the settings menu."); } else { settings = tempSettings; } } string databaseFilePath = this.GetDatabaseFilePath(settings); if (!File.Exists(databaseFilePath)) { File.Copy(SettingsTemplateDatabaseFileName, databaseFilePath); } return(settings); }
private static async void TrackFollows(MixerConnection connection, ExpandedChannelModel channel, ChatClient chat) { var constalation = await ConstellationClient.Create(connection); WriteLine("made constellation"); var connected = await constalation.Connect(); if (!connected) { WriteLine("constalation failed"); return; } WriteLine("connected to constellation"); await constalation.SubscribeToEventsWithResponse(new ConstellationEventType[] { new ConstellationEventType(ConstellationEventTypeEnum.channel__id__followed, channel.id) }); void Constalation_OnSubscribedEventOccurred(object sender, Base.Model.Constellation.ConstellationLiveEventModel e) { var following = e.payload.Value <bool>("following"); var user = e.payload.Value <JObject>("user"); var username = user.Value <string>("username"); var mood = following ? "follow" : "unfollow"; chat.Send($"/{mood} {username}"); Log($"{username}\t{mood}"); } constalation.OnSubscribedEventOccurred += Constalation_OnSubscribedEventOccurred; }
public DesktopChannelSettings(ExpandedChannelModel channel, bool isStreamer = true) : this() { this.Channel = channel; this.IsStreamer = isStreamer; this.Version = DesktopChannelSettings.LatestVersion; }
public IChannelSettings Create(ExpandedChannelModel channel, bool isStreamer) { IChannelSettings settings = new DesktopChannelSettings(channel, isStreamer); string databaseFilePath = this.GetDatabaseFilePath(settings); if (!File.Exists(databaseFilePath)) { File.Copy(SettingsTemplateDatabaseFileName, databaseFilePath); } return(settings); }
private async Task HandleUserSpecialIdentifiers(UserViewModel user, string identifierHeader) { if (user != null) { await user.RefreshDetails(); if (ChannelSession.Settings.UserData.ContainsKey(user.ID)) { UserDataViewModel userData = ChannelSession.Settings.UserData[user.ID]; foreach (UserCurrencyViewModel currency in ChannelSession.Settings.Currencies.Values) { UserCurrencyDataViewModel currencyData = userData.GetCurrency(currency); UserRankViewModel rank = currencyData.GetRank(); this.ReplaceSpecialIdentifier(identifierHeader + currency.UserRankNameSpecialIdentifier, rank.Name); this.ReplaceSpecialIdentifier(identifierHeader + currency.UserAmountSpecialIdentifier, currencyData.Amount.ToString()); } this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "time", userData.ViewingTimeString); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "hours", userData.ViewingHoursString); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "mins", userData.ViewingMinutesString); } if (this.ContainsSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "game")) { GameTypeModel game = await ChannelSession.Connection.GetGameType(user.GameTypeID); if (game != null) { this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "game", game.name.ToString()); } else { this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "game", "Unknown"); } } this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "followage", user.FollowAgeString); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "subage", user.SubscribeAgeString); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "submonths", user.SubscribeMonths.ToString()); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "avatar", user.AvatarLink); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "url", "https://www.mixer.com/" + user.UserName); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "name", user.UserName); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "id", user.ID.ToString()); if (this.ContainsSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "followers")) { ExpandedChannelModel channel = await ChannelSession.Connection.GetChannel(user.UserName); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "followers", channel?.numFollowers.ToString() ?? "0"); } } }
public async void AttemptLogin() { // hide login grid LoginGrid.Visibility = Visibility.Visible; // show main grid MainGrid.Visibility = Visibility.Collapsed; // attempt to login and authenticate with OAuth _connection = await MixerConnection.ConnectViaLocalhostOAuthBrowser(ConfigurationManager.AppSettings["ClientID"], _scopes); // check that we logged in and got a connection if (_connection != null) { // get the current logged in user _user = await _connection.Users.GetCurrentUser(); // get the channel we want to connect to _channel = await _connection.Channels.GetChannel("SmiteGame"); // create a chat client so we can connect to the chat _chatClient = await ChatClient.CreateFromChannel(_connection, _channel); // attach an event handler incase we disconnect from chat _chatClient.OnDisconnectOccurred += ChatClient_OnDisconnectOccurred; // try and connect + authenticate with the chat client (will fail if banned from chat etc...) if (await _chatClient.Connect() && await _chatClient.Authenticate()) { // set logged in user on ui ChannelUserTextBlock.Text = _user.username; // set stream title on ui StreamTitleTextBox.Text = _channel.name; // set game title on ui GameTitleTextBlock.Text = _channel.type.name; // set connection status on ui ConnectionStatus.Text = "Connected"; // set stream online status on ui StreamStatus.Text = _channel.online.ToString(); // set taskbar hover text to show we're connected MainIcon.ToolTipText = "Smite Mixer Idler (Connected)"; // set the icon to the coloured version MainIcon.Icon = Properties.Resources.lumbridgeAvatar; // show a notification to the user saying we connected and authenticated successfully MainIcon.ShowBalloonTip("Smite Mixer Idler", "Successfully connected to chat.", Properties.Resources.lumbridgeAvatar, true); // hide the login grid LoginGrid.Visibility = Visibility.Collapsed; // show the main grid MainGrid.Visibility = Visibility.Visible; } } }
private async void UserDialogControl_Loaded(object sender, System.Windows.RoutedEventArgs e) { if (this.user != null && !this.user.IsAnonymous && !string.IsNullOrEmpty(this.user.UserName)) { await this.user.RefreshDetails(force : true); this.UserAvatar.SetSize(100); await this.UserAvatar.SetUserAvatarUrl(this.user); PromoteToModButton.IsEnabled = ChannelSession.IsStreamer; DemoteFromModButton.IsEnabled = ChannelSession.IsStreamer; EditUserButton.IsEnabled = ChannelSession.IsStreamer; bool follows = false; if (this.user.ChannelID > 0) { ExpandedChannelModel channelToCheck = await ChannelSession.Connection.GetChannel(this.user.ChannelID); if (channelToCheck != null) { follows = (await ChannelSession.Connection.CheckIfFollows(channelToCheck, ChannelSession.User)).HasValue; if (channelToCheck.online) { this.StreamStatusTextBlock.Text = $"{channelToCheck.viewersCurrent} Viewers"; } else { this.StreamStatusTextBlock.Text = "Offline"; } } } if (follows) { this.UnfollowButton.Visibility = System.Windows.Visibility.Visible; this.FollowButton.Visibility = System.Windows.Visibility.Collapsed; } if (this.user.MixerRoles.Contains(MixerRoleEnum.Banned)) { this.UnbanButton.Visibility = System.Windows.Visibility.Visible; this.BanButton.Visibility = System.Windows.Visibility.Collapsed; } if (this.user.MixerRoles.Contains(MixerRoleEnum.Mod)) { this.DemoteFromModButton.Visibility = System.Windows.Visibility.Visible; this.PromoteToModButton.Visibility = System.Windows.Visibility.Collapsed; } this.DataContext = this.user; } }
public static async Task RefreshChannel() { if (ChannelSession.Channel != null) { ExpandedChannelModel channel = await ChannelSession.Connection.GetChannel(ChannelSession.Channel.user.username); if (channel != null) { ChannelSession.Channel = channel; } } }
public DesktopChannelSettings(ExpandedChannelModel channel, bool isStreamer = true) : this() { this.Channel = channel; this.IsStreamer = isStreamer; this.GiveawayUserJoinedCommand = CustomCommand.BasicChatCommand("Giveaway User Joined", "You have been entered into the giveaway, stay tuned to see who wins!", isWhisper: true); this.GiveawayWinnerSelectedCommand = CustomCommand.BasicChatCommand("Giveaway Winner Selected", "Congratulations @$username, you won! Type \"!claim\" in chat in the next 60 seconds to claim your prize!", isWhisper: true); this.ModerationStrike1Command = CustomCommand.BasicChatCommand("Moderation Strike 1", "$moderationreason. You have received a moderation strike & currently have $usermoderationstrikes strike(s)", isWhisper: true); this.ModerationStrike2Command = CustomCommand.BasicChatCommand("Moderation Strike 2", "$moderationreason. You have received a moderation strike & currently have $usermoderationstrikes strike(s)", isWhisper: true); this.ModerationStrike3Command = CustomCommand.BasicChatCommand("Moderation Strike 3", "$moderationreason. You have received a moderation strike & currently have $usermoderationstrikes strike(s)", isWhisper: true); }
public async Task <IChannelSettings> Create(ExpandedChannelModel channel, bool isStreamer) { IChannelSettings settings = new DesktopChannelSettings(channel, isStreamer); if (File.Exists(this.GetFilePath(settings))) { settings = await this.LoadSettings(this.GetFilePath(settings)); } string databaseFilePath = this.GetDatabaseFilePath(settings); if (!File.Exists(databaseFilePath)) { File.Copy(SettingsTemplateDatabaseFileName, databaseFilePath); } return(settings); }
private async static void Connect() { try { Plugin.Log("Connecting to Mixer"); DisConnect(); List <OAuthClientScopeEnum> scopes = new List <OAuthClientScopeEnum>() { OAuthClientScopeEnum.chat__bypass_links, OAuthClientScopeEnum.chat__bypass_slowchat, OAuthClientScopeEnum.chat__chat, OAuthClientScopeEnum.chat__connect, OAuthClientScopeEnum.channel__details__self, }; MixerConnection connection = await MixerConnection.ConnectViaLocalhostOAuthBrowser(ClientID, scopes).ConfigureAwait(false); Plugin.Log($"OAuth Mixerconnection successful? => {connection != null}"); if (connection != null) { Plugin.Log("Getting info"); MixerUser = await connection.Users.GetCurrentUser().ConfigureAwait(false); ExpandedChannelModel channel = await connection.Channels.GetChannel(MixerUser.username).ConfigureAwait(false); client = await ChatClient.CreateFromChannel(connection, channel).ConfigureAwait(false); client.OnDisconnectOccurred += ChatClient_OnDisconnectOccurred; client.OnDisconnectOccurred += ChatClient_DoReconnect; client.OnMessageOccurred += ChatClient_OnMessageOccurred; //client.OnUserJoinOccurred += ChatClient_OnUserJoinOccurred; //client.OnUserLeaveOccurred += ChatClient_OnUserLeaveOccurred; Plugin.Log("Connecting to Mixer chat"); if (await client.Connect().ConfigureAwait(false) && await client.Authenticate().ConfigureAwait(false)) { DoOnConnect(); } } } catch (Exception e) { Plugin.Log($"{e.GetType().Name}: {e.Message}"); } }
public DesktopChannelSettings(ExpandedChannelModel channel, bool isStreamer = true) : this() { this.Channel = channel; this.IsStreamer = isStreamer; this.GameQueueUserJoinedCommand = CustomCommand.BasicChatCommand("Game Queue Used Joined", "You are #$queueposition in the queue to play.", isWhisper: true); this.GameQueueUserSelectedCommand = CustomCommand.BasicChatCommand("Game Queue Used Selected", "It's time to play @$username! Listen carefully for instructions on how to join..."); this.GiveawayUserJoinedCommand = CustomCommand.BasicChatCommand("Giveaway User Joined", "You have been entered into the giveaway, stay tuned to see who wins!", isWhisper: true); this.GiveawayWinnerSelectedCommand = CustomCommand.BasicChatCommand("Giveaway Winner Selected", "Congratulations @$username, you won! Type \"!claim\" in chat in the next 60 seconds to claim your prize!", isWhisper: true); this.SongAddedCommand = CustomCommand.BasicChatCommand("Song Request Added", "$songtitle has been added to the queue", isWhisper: true); this.SongPlayedCommand = CustomCommand.BasicChatCommand("Song Request Played", "Now Playing: $songtitle"); this.ModerationStrike1Command = CustomCommand.BasicChatCommand("Moderation Strike 1", "$moderationreason. You have received a moderation strike & currently have $usermoderationstrikes strike(s)", isWhisper: true); this.ModerationStrike2Command = CustomCommand.BasicChatCommand("Moderation Strike 2", "$moderationreason. You have received a moderation strike & currently have $usermoderationstrikes strike(s)", isWhisper: true); this.ModerationStrike3Command = CustomCommand.BasicChatCommand("Moderation Strike 3", "$moderationreason. You have received a moderation strike & currently have $usermoderationstrikes strike(s)", isWhisper: true); }
public DesktopChannelSettings(ExpandedChannelModel channel, bool isStreamer = true) : this() { this.Channel = channel; this.IsStreamer = isStreamer; this.Version = DesktopChannelSettings.LatestVersion; this.DefaultStreamingSoftware = StreamingSoftwareTypeEnum.OBSStudio; this.TimerCommandsInterval = 10; this.TimerCommandsMinimumMessages = 10; this.GameQueueRequirements = new RequirementViewModel(); this.GiveawayCommand = "giveaway"; this.GiveawayTimer = 1; this.GiveawayMaximumEntries = 1; this.GiveawayRequirements = new RequirementViewModel(); this.GiveawayReminderInterval = 5; this.GiveawayRequireClaim = true; this.GiveawayUserJoinedCommand = CustomCommand.BasicChatCommand("Giveaway User Joined", "You have been entered into the giveaway, stay tuned to see who wins!", isWhisper: true); this.GiveawayWinnerSelectedCommand = CustomCommand.BasicChatCommand("Giveaway Winner Selected", "Congratulations @$username, you won! Type \"!claim\" in chat in the next 60 seconds to claim your prize!", isWhisper: true); this.MaxMessagesInChat = 100; this.ChatFontSize = 13; this.ChatUserJoinLeaveColorScheme = this.ChatEventAlertsColorScheme = this.ChatInteractiveAlertsColorScheme = ColorSchemes.DefaultColorScheme; this.OverlayWidgetRefreshTime = 5; this.ModerationFilteredWordsExcempt = MixerRoleEnum.Mod; this.ModerationFilteredWordsApplyStrikes = true; this.ModerationChatTextExcempt = MixerRoleEnum.Mod; this.ModerationChatTextApplyStrikes = true; this.ModerationBlockLinksExcempt = MixerRoleEnum.Mod; this.ModerationBlockLinksApplyStrikes = true; this.ModerationCapsBlockIsPercentage = true; this.ModerationPunctuationBlockIsPercentage = true; this.ModerationStrike1Command = CustomCommand.BasicChatCommand("Moderation Strike 1", "You have received a moderation strike, you currently have $usermoderationstrikes strike(s)", isWhisper: true); this.ModerationStrike2Command = CustomCommand.BasicChatCommand("Moderation Strike 2", "You have received a moderation strike, you currently have $usermoderationstrikes strike(s)", isWhisper: true); this.ModerationStrike3Command = CustomCommand.BasicChatCommand("Moderation Strike 3", "You have received a moderation strike, you currently have $usermoderationstrikes strike(s)", isWhisper: true); }
private async void Login_Click(object sender, RoutedEventArgs e) { Connection = await MixerConnection.ConnectViaLocalhostOAuthBrowser(Settings.Default.ClientId, GetScope()); if (Connection != null) { User = await Connection.Users.GetCurrentUser(); Channel = await Connection.Channels.GetChannel(Settings.Default.Channel); ChatClient = await ChatClient.CreateFromChannel(Connection, Channel); ChatClient.OnMessageOccurred += ChatClient_MessageOccurred; ChatClient.OnDisconnectOccurred += ChatClient_OnDisconnectOccurred; if (await ChatClient.Connect() && await ChatClient.Authenticate()) { Log("connected"); } } }
private async void LoginButton_Click(object sender, RoutedEventArgs e) { this.LoginGrid.Visibility = Visibility.Visible; this.MainGrid.Visibility = Visibility.Collapsed; List <OAuthClientScopeEnum> scopes = new List <OAuthClientScopeEnum>() { OAuthClientScopeEnum.channel__details__self, OAuthClientScopeEnum.channel__update__self, OAuthClientScopeEnum.interactive__manage__self, OAuthClientScopeEnum.interactive__robot__self, OAuthClientScopeEnum.user__details__self, OAuthClientScopeEnum.user__log__self, OAuthClientScopeEnum.user__notification__self, OAuthClientScopeEnum.user__update__self, }; this.connection = await MixerConnection.ConnectViaLocalhostOAuthBrowser(ConfigurationManager.AppSettings["ClientID"], scopes); if (this.connection != null) { this.user = await this.connection.Users.GetCurrentUser(); this.channel = await this.connection.Channels.GetChannel(this.user.username); this.games = new List <InteractiveGameListingModel>(await this.connection.Interactive.GetOwnedInteractiveGames(this.channel)); this.GameSelectComboBox.ItemsSource = this.games.Select(g => g.name); this.LoginGrid.Visibility = Visibility.Collapsed; this.GameSelectGrid.Visibility = Visibility.Visible; } }
private async Task HandleUserSpecialIdentifiers(UserViewModel user, string identifierHeader) { if (user != null && this.ContainsSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader)) { await user.RefreshDetails(); if (ChannelSession.Settings.UserData.ContainsKey(user.ID)) { UserDataViewModel userData = ChannelSession.Settings.UserData[user.ID]; foreach (UserCurrencyViewModel currency in ChannelSession.Settings.Currencies.Values.OrderByDescending(c => c.UserAmountSpecialIdentifier)) { UserCurrencyDataViewModel currencyData = userData.GetCurrency(currency); UserRankViewModel rank = currencyData.GetRank(); UserRankViewModel nextRank = currencyData.GetNextRank(); this.ReplaceSpecialIdentifier(identifierHeader + currency.UserRankNextNameSpecialIdentifier, nextRank.Name); this.ReplaceSpecialIdentifier(identifierHeader + currency.UserAmountNextSpecialIdentifier, nextRank.MinimumPoints.ToString()); this.ReplaceSpecialIdentifier(identifierHeader + currency.UserRankNameSpecialIdentifier, rank.Name); this.ReplaceSpecialIdentifier(identifierHeader + currency.UserAmountSpecialIdentifier, currencyData.Amount.ToString()); } foreach (UserInventoryViewModel inventory in ChannelSession.Settings.Inventories.Values.OrderByDescending(c => c.UserAmountSpecialIdentifierHeader)) { if (this.ContainsSpecialIdentifier(identifierHeader + inventory.UserAmountSpecialIdentifierHeader)) { UserInventoryDataViewModel inventoryData = userData.GetInventory(inventory); List <string> allItemsList = new List <string>(); foreach (UserInventoryItemViewModel item in inventory.Items.Values.OrderByDescending(i => i.Name)) { int amount = inventoryData.GetAmount(item); if (amount > 0) { allItemsList.Add(item.Name + " x" + amount); } string itemSpecialIdentifier = identifierHeader + inventory.UserAmountSpecialIdentifierHeader + item.SpecialIdentifier; this.ReplaceSpecialIdentifier(itemSpecialIdentifier, amount.ToString()); } if (allItemsList.Count > 0) { this.ReplaceSpecialIdentifier(identifierHeader + inventory.UserAllAmountSpecialIdentifier, string.Join(", ", allItemsList.OrderBy(i => i))); } else { this.ReplaceSpecialIdentifier(identifierHeader + inventory.UserAllAmountSpecialIdentifier, "Nothing"); } } } this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "time", userData.ViewingTimeString); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "hours", userData.ViewingHoursString); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "mins", userData.ViewingMinutesString); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "moderationstrikes", userData.ModerationStrikes.ToString()); } this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "primaryrole", user.PrimaryRoleString); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "avatar", user.AvatarLink); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "url", "https://www.mixer.com/" + user.UserName); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "name", user.UserName); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "id", user.ID.ToString()); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "sparks", user.Sparks.ToString()); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "mixerage", user.MixerAgeString); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "followage", user.FollowAgeString); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "subage", user.MixerSubscribeAgeString); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "submonths", user.SubscribeMonths.ToString()); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "title", user.Title); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "fanprogressionnext", user.FanProgression?.level?.nextLevelXp.ToString()); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "fanprogressionrank", user.FanProgression?.level?.level.ToString()); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "fanprogressioncolor", user.FanProgression?.level?.color?.ToString()); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "fanprogressionimage", user.FanProgression?.level?.LargeGIFAssetURL?.ToString()); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "fanprogression", user.FanProgression?.level?.currentXp.ToString()); if (this.ContainsSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "followers") || this.ContainsSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "game") || this.ContainsSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "channel")) { ExpandedChannelModel channel = await ChannelSession.Connection.GetChannel(user.UserName); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "followers", channel?.numFollowers.ToString() ?? "0"); if (channel.type != null) { this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "gameimage", channel.type.coverUrl); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "game", channel.type.name.ToString()); } this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "channelid", channel.id.ToString()); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "channellive", channel.online.ToString()); this.ReplaceSpecialIdentifier(identifierHeader + UserSpecialIdentifierHeader + "channelfeatured", channel.featured.ToString()); } } }
public static void Main(string[] args) { List <OAuthClientScopeEnum> scopes = new List <OAuthClientScopeEnum>() { OAuthClientScopeEnum.channel__details__self, OAuthClientScopeEnum.channel__update__self, OAuthClientScopeEnum.interactive__manage__self, OAuthClientScopeEnum.interactive__robot__self, OAuthClientScopeEnum.user__details__self, OAuthClientScopeEnum.user__log__self, OAuthClientScopeEnum.user__notification__self, OAuthClientScopeEnum.user__update__self, }; System.Console.WriteLine("Connecting to Mixer..."); MixerConnection connection = MixerConnection.ConnectViaLocalhostOAuthBrowser(ConfigurationManager.AppSettings["ClientID"], scopes).Result; if (connection != null) { System.Console.WriteLine("Mixer connection successful!"); UserModel user = connection.Users.GetCurrentUser().Result; ExpandedChannelModel channel = connection.Channels.GetChannel(user.username).Result; System.Console.WriteLine(string.Format("Logged in as: {0}", user.username)); List <InteractiveGameListingModel> games = new List <InteractiveGameListingModel>(connection.Interactive.GetOwnedInteractiveGames(channel).Result); InteractiveGameListingModel game = games.FirstOrDefault(); if (game != null) { System.Console.WriteLine(); System.Console.WriteLine(string.Format("Connecting to channel interactive using game {0}...", game.name)); Program.interactiveClient = InteractiveClient.CreateFromChannel(connection, channel, game).Result; if (Program.interactiveClient.Connect().Result&& Program.interactiveClient.Ready().Result) { InteractiveConnectedSceneGroupCollectionModel scenes = Program.interactiveClient.GetScenes().Result; if (scenes != null) { Program.scenes.AddRange(scenes.scenes); foreach (InteractiveConnectedSceneModel scene in Program.scenes) { foreach (InteractiveConnectedButtonControlModel button in scene.buttons) { Program.buttons.Add(button); } foreach (InteractiveConnectedJoystickControlModel joystick in scene.joysticks) { Program.joysticks.Add(joystick); } } Program.interactiveClient.OnDisconnectOccurred += InteractiveClient_OnDisconnectOccurred; Program.interactiveClient.OnParticipantJoin += InteractiveClient_OnParticipantJoin; Program.interactiveClient.OnParticipantLeave += InteractiveClient_OnParticipantLeave; Program.interactiveClient.OnGiveInput += InteractiveClient_OnGiveInput; while (true) { } } } } } }
private async void LoginButton_Click(object sender, RoutedEventArgs e) { this.LoginGrid.Visibility = Visibility.Visible; this.MainGrid.Visibility = Visibility.Collapsed; this.ChatListView.ItemsSource = this.chatMessages; this.UsersListView.ItemsSource = this.chatUsers; List <OAuthClientScopeEnum> scopes = new List <OAuthClientScopeEnum>() { OAuthClientScopeEnum.chat__bypass_links, OAuthClientScopeEnum.chat__bypass_slowchat, OAuthClientScopeEnum.chat__change_ban, OAuthClientScopeEnum.chat__change_role, OAuthClientScopeEnum.chat__chat, OAuthClientScopeEnum.chat__connect, OAuthClientScopeEnum.chat__clear_messages, OAuthClientScopeEnum.chat__edit_options, OAuthClientScopeEnum.chat__giveaway_start, OAuthClientScopeEnum.chat__poll_start, OAuthClientScopeEnum.chat__poll_vote, OAuthClientScopeEnum.chat__purge, OAuthClientScopeEnum.chat__remove_message, OAuthClientScopeEnum.chat__timeout, OAuthClientScopeEnum.chat__view_deleted, OAuthClientScopeEnum.chat__whisper, OAuthClientScopeEnum.channel__details__self, OAuthClientScopeEnum.channel__update__self, OAuthClientScopeEnum.user__details__self, OAuthClientScopeEnum.user__log__self, OAuthClientScopeEnum.user__notification__self, OAuthClientScopeEnum.user__update__self, }; this.connection = await MixerConnection.ConnectViaLocalhostOAuthBrowser(ConfigurationManager.AppSettings["ClientID"], scopes); if (this.connection != null) { this.user = await this.connection.Users.GetCurrentUser(); this.channel = await this.connection.Channels.GetChannel(this.user.username); this.chatClient = await ChatClient.CreateFromChannel(this.connection, this.channel); this.chatClient.OnMessageOccurred += ChatClient_MessageOccurred; this.chatClient.OnUserJoinOccurred += ChatClient_UserJoinOccurred; this.chatClient.OnUserLeaveOccurred += ChatClient_UserLeaveOccurred; this.chatClient.OnUserTimeoutOccurred += ChatClient_UserTimeoutOccurred; this.chatClient.OnUserUpdateOccurred += ChatClient_UserUpdateOccurred; this.chatClient.OnPollStartOccurred += ChatClient_PollStartOccurred; this.chatClient.OnPollEndOccurred += ChatClient_PollEndOccurred; this.chatClient.OnPurgeMessageOccurred += ChatClient_PurgeMessageOccurred; this.chatClient.OnDeleteMessageOccurred += ChatClient_DeleteMessageOccurred; this.chatClient.OnClearMessagesOccurred += ChatClient_ClearMessagesOccurred; if (await this.chatClient.Connect() && await this.chatClient.Authenticate()) { this.ChannelUserTextBlock.Text = this.user.username; this.StreamTitleTextBox.Text = this.channel.name; this.GameTitleTextBlock.Text = this.channel.type.name; foreach (ChatUserModel user in await this.connection.Chats.GetUsers(this.chatClient.Channel)) { this.chatUsers.Add(new ChatUser(user)); } this.LoginGrid.Visibility = Visibility.Collapsed; this.MainGrid.Visibility = Visibility.Visible; } } }
private static async Task <bool> InitializeInternal(string channelName = null) { PrivatePopulatedUserModel user = await ChannelSession.Connection.GetCurrentUser(); if (user != null) { ExpandedChannelModel channel = await ChannelSession.Connection.GetChannel((channelName == null)?user.username : channelName); if (channel != null) { ChannelSession.User = user; ChannelSession.Channel = channel; ChannelSession.PreMadeChatCommands = new List <PreMadeChatCommand>(); ChannelSession.GameQueue = new LockedList <UserViewModel>(); ChannelSession.Counters = new LockedDictionary <string, int>(); if (ChannelSession.Settings == null) { ChannelSession.Settings = ChannelSession.Services.Settings.Create(channel, (channelName == null)); } await ChannelSession.Services.Settings.Initialize(ChannelSession.Settings); ChannelSession.Connection.Initialize(); if (!await ChannelSession.Chat.Connect(connectionAttempts: 5) || !await ChannelSession.Constellation.Connect()) { return(false); } if (!string.IsNullOrEmpty(ChannelSession.Settings.OBSStudioServerIP)) { await ChannelSession.Services.InitializeOBSWebsocket(); } if (ChannelSession.Settings.EnableXSplitConnection) { await ChannelSession.Services.InitializeXSplitServer(); } if (ChannelSession.Settings.EnableOverlay) { await ChannelSession.Services.InitializeOverlayServer(); } if (ChannelSession.Settings.EnableDeveloperAPI) { await ChannelSession.Services.InitializeDeveloperAPI(); } GlobalEvents.OnRankChanged += GlobalEvents_OnRankChanged; await ChannelSession.SaveSettings(); await ChannelSession.Services.Settings.SaveBackup(ChannelSession.Settings); await Logger.LogAnalyticsUsage("LogIn", "Desktop"); return(true); } } return(false); }
private static async Task <bool> InitializeInternal(string channelName = null) { PrivatePopulatedUserModel user = await ChannelSession.Connection.GetCurrentUser(); if (user != null) { ExpandedChannelModel channel = await ChannelSession.Connection.GetChannel((channelName == null)?user.username : channelName); if (channel != null) { ChannelSession.User = user; ChannelSession.Channel = channel; if (ChannelSession.Settings == null) { ChannelSession.Settings = ChannelSession.Services.Settings.Create(channel, (channelName == null)); } await ChannelSession.Services.Settings.Initialize(ChannelSession.Settings); ChannelSession.Settings.Channel = channel; ChannelSession.Connection.Initialize(); if (!await ChannelSession.Chat.Connect() || !await ChannelSession.Constellation.Connect()) { return(false); } if (!string.IsNullOrEmpty(ChannelSession.Settings.OBSStudioServerIP)) { await ChannelSession.Services.InitializeOBSWebsocket(); } if (ChannelSession.Settings.EnableStreamlabsOBSConnection) { await ChannelSession.Services.InitializeStreamlabsOBSService(); } if (ChannelSession.Settings.EnableXSplitConnection) { await ChannelSession.Services.InitializeXSplitServer(); } if (ChannelSession.Settings.EnableOverlay) { await ChannelSession.Services.InitializeOverlayServer(); } if (ChannelSession.Settings.EnableDeveloperAPI) { await ChannelSession.Services.InitializeDeveloperAPI(); } if (ChannelSession.Settings.StreamlabsOAuthToken != null) { await ChannelSession.Services.InitializeStreamlabs(); } if (ChannelSession.Settings.GameWispOAuthToken != null) { await ChannelSession.Services.InitializeGameWisp(); } if (ChannelSession.Settings.GawkBoxOAuthToken != null) { await ChannelSession.Services.InitializeGawkBox(); } if (ChannelSession.Settings.TwitterOAuthToken != null) { await ChannelSession.Services.InitializeTwitter(); } if (ChannelSession.Settings.SpotifyOAuthToken != null) { await ChannelSession.Services.InitializeSpotify(); } if (ChannelSession.Settings.DiscordOAuthToken != null) { await ChannelSession.Services.InitializeDiscord(); } if (ChannelSession.Settings.TiltifyOAuthToken != null) { await ChannelSession.Services.InitializeTiltify(); } foreach (CommandBase command in ChannelSession.AllCommands) { foreach (ActionBase action in command.Actions) { if (action is CounterAction) { await((CounterAction)action).SetCounterValue(); } } } if (ChannelSession.Settings.DefaultInteractiveGame > 0) { IEnumerable <InteractiveGameListingModel> games = await ChannelSession.Connection.GetOwnedInteractiveGames(ChannelSession.Channel); InteractiveGameListingModel game = games.FirstOrDefault(g => g.id.Equals(ChannelSession.Settings.DefaultInteractiveGame)); if (game != null) { if (!await ChannelSession.Interactive.Connect(game)) { await ChannelSession.Interactive.Disconnect(); } } else { ChannelSession.Settings.DefaultInteractiveGame = 0; } } await ChannelSession.SaveSettings(); await ChannelSession.Services.Settings.SaveBackup(ChannelSession.Settings); if (!Util.Logger.IsDebug) { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Task.Run(async() => { await ChannelSession.Services.MixItUpService.SendLoginEvent(new LoginEvent(ChannelSession.Settings.IsStreamer.ToString())); }); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } GlobalEvents.OnRankChanged += GlobalEvents_OnRankChanged; return(true); } } return(false); }
private async void LoginButton_Click(object sender, RoutedEventArgs e) { this.LoginButton.IsEnabled = false; string clientID = ConfigurationManager.AppSettings["ClientID"]; if (string.IsNullOrEmpty(clientID)) { throw new ArgumentException("ClientID value isn't set in application configuration"); } this.connection = await MixerConnection.ConnectViaShortCode(clientID, new List <OAuthClientScopeEnum>() { OAuthClientScopeEnum.chat__chat, OAuthClientScopeEnum.chat__connect, OAuthClientScopeEnum.channel__details__self, OAuthClientScopeEnum.channel__update__self, OAuthClientScopeEnum.user__details__self, OAuthClientScopeEnum.user__log__self, OAuthClientScopeEnum.user__notification__self, OAuthClientScopeEnum.user__update__self, }, (OAuthShortCodeModel code) => { this.ShortCodeTextBox.Text = code.code; Process.Start("https://mixer.com/oauth/shortcode"); }); if (this.connection != null) { this.user = await this.connection.Users.GetCurrentUser(); this.channel = await this.connection.Channels.GetChannel(this.user.username); this.chatClient = await ChatClient.CreateFromChannel(this.connection, channel); this.chatClient.OnDisconnectOccurred += ChatClient_OnDisconnectOccurred; this.chatClient.OnMessageOccurred += ChatClient_MessageOccurred; this.chatClient.OnUserJoinOccurred += ChatClient_UserJoinOccurred; this.chatClient.OnUserLeaveOccurred += ChatClient_UserLeaveOccurred; this.chatClient.OnUserTimeoutOccurred += ChatClient_UserTimeoutOccurred; this.chatClient.OnUserUpdateOccurred += ChatClient_UserUpdateOccurred; this.chatClient.OnPollStartOccurred += ChatClient_PollStartOccurred; this.chatClient.OnPollEndOccurred += ChatClient_PollEndOccurred; this.chatClient.OnPurgeMessageOccurred += ChatClient_PurgeMessageOccurred; this.chatClient.OnDeleteMessageOccurred += ChatClient_DeleteMessageOccurred; this.chatClient.OnClearMessagesOccurred += ChatClient_ClearMessagesOccurred; IEnumerable <ChatUserModel> users = await this.connection.Chats.GetUsers(this.channel); this.viewerCount = users.Count(); this.CurrentViewersTextBlock.Text = this.viewerCount.ToString(); if (await this.chatClient.Connect() && await this.chatClient.Authenticate()) { this.LoginGrid.Visibility = Visibility.Collapsed; this.ChatGrid.Visibility = Visibility.Visible; } } this.LoginButton.IsEnabled = true; }
private async Task ShowUserDialog(UserViewModel user) { if (user != null && !user.IsAnonymous) { UserDialogResult result = await MessageBoxHelper.ShowUserDialog(user); switch (result) { case UserDialogResult.Purge: await ChannelSession.Chat.PurgeUser(user.UserName); break; case UserDialogResult.Timeout1: await ChannelSession.Chat.TimeoutUser(user.UserName, 60); break; case UserDialogResult.Timeout5: await ChannelSession.Chat.TimeoutUser(user.UserName, 300); break; case UserDialogResult.Ban: if (await MessageBoxHelper.ShowConfirmationDialog(string.Format("This will ban the user {0} from this channel. Are you sure?", user.UserName))) { await ChannelSession.Chat.BanUser(user); } break; case UserDialogResult.Unban: await ChannelSession.Chat.UnBanUser(user); break; case UserDialogResult.Follow: ExpandedChannelModel channelToFollow = await ChannelSession.Connection.GetChannel(user.UserName); await ChannelSession.Connection.Follow(channelToFollow, ChannelSession.User); break; case UserDialogResult.Unfollow: ExpandedChannelModel channelToUnfollow = await ChannelSession.Connection.GetChannel(user.UserName); await ChannelSession.Connection.Unfollow(channelToUnfollow, ChannelSession.User); break; case UserDialogResult.PromoteToMod: if (await MessageBoxHelper.ShowConfirmationDialog(string.Format("This will promote the user {0} to a moderator of this channel. Are you sure?", user.UserName))) { await ChannelSession.Chat.ModUser(user); } break; case UserDialogResult.DemoteFromMod: if (await MessageBoxHelper.ShowConfirmationDialog(string.Format("This will demote the user {0} from a moderator of this channel. Are you sure?", user.UserName))) { await ChannelSession.Chat.UnModUser(user); } break; case UserDialogResult.MixerPage: Process.Start($"https://mixer.com/{user.UserName}"); break; case UserDialogResult.EditUser: UserDataEditorWindow window = new UserDataEditorWindow(ChannelSession.Settings.UserData[user.ID]); await Task.Delay(100); window.Show(); await Task.Delay(100); window.Focus(); break; case UserDialogResult.Close: default: // Just close break; } } }
public static void Main(string[] args) { List <OAuthClientScopeEnum> scopes = new List <OAuthClientScopeEnum>() { OAuthClientScopeEnum.chat__bypass_links, OAuthClientScopeEnum.chat__bypass_slowchat, OAuthClientScopeEnum.chat__change_ban, OAuthClientScopeEnum.chat__change_role, OAuthClientScopeEnum.chat__chat, OAuthClientScopeEnum.chat__connect, OAuthClientScopeEnum.chat__clear_messages, OAuthClientScopeEnum.chat__edit_options, OAuthClientScopeEnum.chat__giveaway_start, OAuthClientScopeEnum.chat__poll_start, OAuthClientScopeEnum.chat__poll_vote, OAuthClientScopeEnum.chat__purge, OAuthClientScopeEnum.chat__remove_message, OAuthClientScopeEnum.chat__timeout, OAuthClientScopeEnum.chat__view_deleted, OAuthClientScopeEnum.chat__whisper, OAuthClientScopeEnum.channel__details__self, OAuthClientScopeEnum.channel__update__self, OAuthClientScopeEnum.user__details__self, OAuthClientScopeEnum.user__log__self, OAuthClientScopeEnum.user__notification__self, OAuthClientScopeEnum.user__update__self, }; System.Console.WriteLine("Connecting to Mixer..."); MixerConnection connection = MixerConnection.ConnectViaLocalhostOAuthBrowser(ConfigurationManager.AppSettings["ClientID"], scopes).Result; if (connection != null) { System.Console.WriteLine("Mixer connection successful!"); UserModel user = connection.Users.GetCurrentUser().Result; ExpandedChannelModel channel = connection.Channels.GetChannel(user.username).Result; System.Console.WriteLine(string.Format("Logged in as: {0}", user.username)); System.Console.WriteLine(); System.Console.WriteLine("Connecting to constellation..."); constellationClient = ConstellationClient.Create(connection).Result; constellationClient.OnDisconnectOccurred += ConstellationClient_OnDisconnectOccurred; constellationClient.OnSubscribedEventOccurred += ConstellationClient_OnSubscribedEventOccurred; if (constellationClient.Connect().Result) { System.Console.WriteLine("Constellation connection successful!"); List <ConstellationEventTypeEnum> eventsToSubscribeTo = new List <ConstellationEventTypeEnum>() { ConstellationEventTypeEnum.channel__id__followed, ConstellationEventTypeEnum.channel__id__hosted, ConstellationEventTypeEnum.channel__id__subscribed, ConstellationEventTypeEnum.channel__id__resubscribed, ConstellationEventTypeEnum.channel__id__resubShared, ConstellationEventTypeEnum.channel__id__subscriptionGifted, ConstellationEventTypeEnum.channel__id__update, ConstellationEventTypeEnum.channel__id__skill, ConstellationEventTypeEnum.channel__id__patronageUpdate, ConstellationEventTypeEnum.progression__id__levelup, }; List <ConstellationEventType> events = eventsToSubscribeTo.Select(e => new ConstellationEventType(e, channel.id)).ToList(); constellationClient.SubscribeToEvents(events).Wait(); System.Console.WriteLine("Subscribed to events successful!"); System.Console.WriteLine(); while (true) { } } } }
public static void Main(string[] args) { List <OAuthClientScopeEnum> scopes = new List <OAuthClientScopeEnum>() { OAuthClientScopeEnum.chat__bypass_links, OAuthClientScopeEnum.chat__bypass_slowchat, OAuthClientScopeEnum.chat__change_ban, OAuthClientScopeEnum.chat__change_role, OAuthClientScopeEnum.chat__chat, OAuthClientScopeEnum.chat__connect, OAuthClientScopeEnum.chat__clear_messages, OAuthClientScopeEnum.chat__edit_options, OAuthClientScopeEnum.chat__giveaway_start, OAuthClientScopeEnum.chat__poll_start, OAuthClientScopeEnum.chat__poll_vote, OAuthClientScopeEnum.chat__purge, OAuthClientScopeEnum.chat__remove_message, OAuthClientScopeEnum.chat__timeout, OAuthClientScopeEnum.chat__view_deleted, OAuthClientScopeEnum.chat__whisper, OAuthClientScopeEnum.channel__details__self, OAuthClientScopeEnum.channel__update__self, OAuthClientScopeEnum.user__details__self, OAuthClientScopeEnum.user__log__self, OAuthClientScopeEnum.user__notification__self, OAuthClientScopeEnum.user__update__self, }; System.Console.WriteLine("Connecting to Mixer..."); MixerConnection connection = MixerConnection.ConnectViaLocalhostOAuthBrowser(ConfigurationManager.AppSettings["ClientID"], scopes).Result; if (connection != null) { System.Console.WriteLine("Mixer connection successful!"); UserModel user = connection.Users.GetCurrentUser().Result; ExpandedChannelModel channel = connection.Channels.GetChannel(user.username).Result; System.Console.WriteLine(string.Format("Logged in as: {0}", user.username)); System.Console.WriteLine(); System.Console.WriteLine("Connecting to channel chat..."); chatClient = ChatClient.CreateFromChannel(connection, channel).Result; chatClient.OnDisconnectOccurred += ChatClient_OnDisconnectOccurred; chatClient.OnMessageOccurred += ChatClient_OnMessageOccurred; chatClient.OnUserJoinOccurred += ChatClient_OnUserJoinOccurred; chatClient.OnUserLeaveOccurred += ChatClient_OnUserLeaveOccurred; if (chatClient.Connect().Result&& chatClient.Authenticate().Result) { System.Console.WriteLine("Chat connection successful!"); IEnumerable <ChatUserModel> users = connection.Chats.GetUsers(chatClient.Channel).Result; System.Console.WriteLine(string.Format("There are {0} users currently in chat", users.Count())); System.Console.WriteLine(); while (true) { } } } }
public async Task Run() { IEnumerable <ChannelHostModel> channels = this.Channels.ToList(); HostingOrderEnum hostOrder = EnumHelper.GetEnumValueFromString <HostingOrderEnum>(this.HostingOrder); AgeRatingEnum ageRating = EnumHelper.GetEnumValueFromString <AgeRatingEnum>(this.AgeRating); PrivatePopulatedUserModel currentUser = await this.connection.Users.GetCurrentUser(); if (currentUser != null && !currentUser.channel.online) { bool keepCurrentHost = false; if (currentUser.channel.hosteeId != null) { ExpandedChannelModel channel = await this.connection.Channels.GetChannel(currentUser.channel.hosteeId.GetValueOrDefault()); if (channel != null) { AgeRatingEnum channelAgeRating = EnumHelper.GetEnumValueFromString <AgeRatingEnum>(channel.audience); if (channelAgeRating <= ageRating) { keepCurrentHost = true; this.CurrentlyHosting = new ChannelHostModel() { ID = channel.userId, Name = channel.user.username, }; } } } if (!keepCurrentHost) { this.CurrentlyHosting = null; } if (this.CurrentlyHosting != null) { await this.UpdateChannel(this.CurrentlyHosting); } if (this.IsAutoHostingEnabled && (this.CurrentlyHosting == null || !this.CurrentlyHosting.IsOnline)) { if (hostOrder == HostingOrderEnum.Random) { channels = channels.OrderBy(c => Guid.NewGuid()); } foreach (ChannelHostModel channel in channels) { if (channel.IsEnabled) { ChannelModel channelModel = await this.UpdateChannel(channel); AgeRatingEnum channelAgeRating = EnumHelper.GetEnumValueFromString <AgeRatingEnum>(channelModel.audience); if (channelModel != null && channel.IsOnline && channelAgeRating <= ageRating) { ChannelModel updatedChannel = await this.connection.Channels.SetHostChannel(currentUser.channel, channelModel); if (updatedChannel.hosteeId.GetValueOrDefault() == channelModel.id) { this.CurrentlyHosting = channel; break; } } } } } } await this.SaveData(); }
public async Task Run() { IEnumerable <ChannelHostModel> channels = this.Channels.ToList(); HostingOrderEnum hostOrder = this.settings.HostingOrder; AgeRatingEnum ageRating = this.settings.AgeRating; PrivatePopulatedUserModel currentUser = await this.connection.Users.GetCurrentUser(); if (currentUser != null && !currentUser.channel.online) { bool keepCurrentHost = false; if (currentUser.channel.hosteeId != null) { ExpandedChannelModel channel = await this.connection.Channels.GetChannel(currentUser.channel.hosteeId.GetValueOrDefault()); if (channel != null) { AgeRatingEnum channelAgeRating = EnumHelper.GetEnumValueFromString <AgeRatingEnum>(channel.audience); if (channelAgeRating <= ageRating) { keepCurrentHost = true; this.CurrentlyHosting = new ChannelHostModel() { ID = channel.userId, Name = channel.token, }; } } } if (!keepCurrentHost) { this.CurrentlyHosting = null; } if (this.CurrentlyHosting != null) { await this.UpdateChannel(this.CurrentlyHosting); this.totalMinutesHosted++; } if (this.IsAutoHostingEnabled && (this.CurrentlyHosting == null || !this.CurrentlyHosting.IsOnline || (this.settings.MaxHostLength > 0 && this.totalMinutesHosted >= this.settings.MaxHostLength))) { Base.Util.Logger.Log("Attempting to find new host..."); if (hostOrder == HostingOrderEnum.Random) { if (this.CurrentlyHosting != null) { channels = channels.Where(c => !c.ID.Equals(this.CurrentlyHosting.ID)); } channels = channels.OrderBy(c => Guid.NewGuid()); } foreach (ChannelHostModel channel in channels) { if (channel.IsEnabled) { ChannelModel channelModel = await this.UpdateChannel(channel); AgeRatingEnum channelAgeRating = EnumHelper.GetEnumValueFromString <AgeRatingEnum>(channelModel.audience); if (channelModel != null && channel.IsOnline && channelAgeRating <= ageRating) { if (this.CurrentlyHosting != null && channelModel.id.Equals(this.CurrentlyHosting.ID)) { this.totalMinutesHosted = 0; break; } else { ChannelModel updatedChannel = await this.connection.Channels.SetHostChannel(currentUser.channel, channelModel); if (updatedChannel.hosteeId.GetValueOrDefault() == channelModel.id) { Base.Util.Logger.Log("Now hosting " + channelModel.token); await this.SaveData(); this.CurrentlyHosting = channel; this.totalMinutesHosted = 0; if (!string.IsNullOrEmpty(this.WhisperMessage)) { ChatClient chatClient = ChatClient.CreateFromChannel(connection, channelModel).Result; if (chatClient.Connect().Result&& chatClient.Authenticate().Result) { await Task.Delay(3000); await chatClient.Whisper(channelModel.token, this.WhisperMessage); await Task.Delay(3000); } await chatClient.Disconnect(); } break; } } } } } } } else { this.totalMinutesHosted = 0; } }
private async void LoginButton_Click(object sender, RoutedEventArgs e) { this.LoginButton.IsEnabled = false; string clientID = ConfigurationManager.AppSettings["ClientID"]; if (string.IsNullOrEmpty(clientID)) { throw new ArgumentException("ClientID value isn't set in application configuration"); } this.client = await MixerClient.ConnectViaShortCode(clientID, new List <ClientScopeEnum>() { ClientScopeEnum.chat__chat, ClientScopeEnum.chat__connect, ClientScopeEnum.channel__details__self, ClientScopeEnum.channel__update__self, ClientScopeEnum.user__details__self, ClientScopeEnum.user__log__self, ClientScopeEnum.user__notification__self, ClientScopeEnum.user__update__self, }, (string code) => { this.ShortCodeTextBox.Text = code; Process.Start("https://mixer.com/oauth/shortcode"); }); if (this.client != null) { this.user = await this.client.Users.GetCurrentUser(); this.channel = await this.client.Channels.GetChannel(this.user.username); this.chatClient = await ChatClient.CreateFromChannel(this.client, this.user.channel); this.chatClient.MessageOccurred += ChatClient_MessageOccurred; this.chatClient.UserJoinOccurred += ChatClient_UserJoinOccurred; this.chatClient.UserLeaveOccurred += ChatClient_UserLeaveOccurred; this.chatClient.UserTimeoutOccurred += ChatClient_UserTimeoutOccurred; this.chatClient.UserUpdateOccurred += ChatClient_UserUpdateOccurred; this.chatClient.PollStartOccurred += ChatClient_PollStartOccurred; this.chatClient.PollEndOccurred += ChatClient_PollEndOccurred; this.chatClient.PurgeMessageOccurred += ChatClient_PurgeMessageOccurred; this.chatClient.DeleteMessageOccurred += ChatClient_DeleteMessageOccurred; this.chatClient.ClearMessagesOccurred += ChatClient_ClearMessagesOccurred; if (await this.chatClient.Connect() && await this.chatClient.Authenticate()) { this.ChannelUserTextBlock.Text = this.user.username; this.StreamTitleTextBox.Text = this.channel.name; this.GameTitleTextBlock.Text = this.channel.type.name; foreach (ChatUserModel user in await this.client.Chats.GetUsers(this.chatClient.Channel)) { this.chatUsers.Add(new ChatUser(user)); } this.LoginGrid.Visibility = Visibility.Collapsed; this.MainGrid.Visibility = Visibility.Visible; } } this.LoginButton.IsEnabled = true; }
private async void LoginButton_Click(object sender, RoutedEventArgs e) { this.LoginGrid.Visibility = Visibility.Visible; this.MainGrid.Visibility = Visibility.Collapsed; List <OAuthClientScopeEnum> scopes = new List <OAuthClientScopeEnum>() { OAuthClientScopeEnum.channel__details__self, OAuthClientScopeEnum.channel__update__self, OAuthClientScopeEnum.chat__bypass_links, OAuthClientScopeEnum.chat__bypass_slowchat, OAuthClientScopeEnum.chat__change_ban, OAuthClientScopeEnum.chat__change_role, OAuthClientScopeEnum.chat__chat, OAuthClientScopeEnum.chat__connect, OAuthClientScopeEnum.chat__clear_messages, OAuthClientScopeEnum.chat__edit_options, OAuthClientScopeEnum.chat__giveaway_start, OAuthClientScopeEnum.chat__poll_start, OAuthClientScopeEnum.chat__poll_vote, OAuthClientScopeEnum.chat__purge, OAuthClientScopeEnum.chat__remove_message, OAuthClientScopeEnum.chat__timeout, OAuthClientScopeEnum.chat__view_deleted, OAuthClientScopeEnum.chat__whisper, OAuthClientScopeEnum.channel__details__self, OAuthClientScopeEnum.channel__update__self, OAuthClientScopeEnum.user__details__self, OAuthClientScopeEnum.user__log__self, OAuthClientScopeEnum.user__notification__self, OAuthClientScopeEnum.user__update__self, OAuthClientScopeEnum.interactive__manage__self, OAuthClientScopeEnum.interactive__robot__self, OAuthClientScopeEnum.user__details__self, OAuthClientScopeEnum.user__log__self, OAuthClientScopeEnum.user__notification__self, OAuthClientScopeEnum.user__update__self, }; this.connection = await MixerConnection.ConnectViaLocalhostOAuthBrowser(ConfigurationManager.AppSettings["ClientID"], scopes); if (this.connection != null) { this.user = await this.connection.Users.GetCurrentUser(); this.channel = await this.connection.Channels.GetChannel(this.user.username); this.games = new List <InteractiveGameListingModel>(await this.connection.Interactive.GetOwnedInteractiveGames(this.channel)); this.GameSelectComboBox.ItemsSource = this.games.Select(g => g.name); this.LoginGrid.Visibility = Visibility.Collapsed; this.GameSelectGrid.Visibility = Visibility.Visible; this.chatClient = await ChatClient.CreateFromChannel(this.connection, this.channel); if (await this.chatClient.Connect() && await this.chatClient.Authenticate()) { this.InteractiveDataTextBlock.Text += "Connected to the chat." + Environment.NewLine; } } }
private static async Task <bool> InitializeInternal(bool isStreamer, string channelName = null) { await ChannelSession.Services.InitializeTelemetryService(); PrivatePopulatedUserModel user = await ChannelSession.Connection.GetCurrentUser(); if (user != null) { ExpandedChannelModel channel = await ChannelSession.Connection.GetChannel((channelName == null)?user.username : channelName); if (channel != null) { ChannelSession.User = user; ChannelSession.Channel = channel; if (ChannelSession.Settings == null) { ChannelSession.Settings = await ChannelSession.Services.Settings.Create(channel, isStreamer); } await ChannelSession.Services.Settings.Initialize(ChannelSession.Settings); if (isStreamer && ChannelSession.Settings.Channel != null && ChannelSession.User.id != ChannelSession.Settings.Channel.userId) { GlobalEvents.ShowMessageBox("The account you are logged in as on Mixer does not match the account for this settings. Please log in as the correct account on Mixer."); ChannelSession.Settings.OAuthToken.accessToken = string.Empty; ChannelSession.Settings.OAuthToken.refreshToken = string.Empty; ChannelSession.Settings.OAuthToken.expiresIn = 0; return(false); } ChannelSession.Settings.Channel = channel; ChannelSession.Services.Telemetry.SetUserId(ChannelSession.Settings.TelemetryUserId); ChannelSession.Connection.Initialize(); if (!await ChannelSession.Chat.Connect() || !await ChannelSession.Constellation.Connect()) { return(false); } if (!string.IsNullOrEmpty(ChannelSession.Settings.OBSStudioServerIP)) { await ChannelSession.Services.InitializeOBSWebsocket(); } if (ChannelSession.Settings.EnableStreamlabsOBSConnection) { await ChannelSession.Services.InitializeStreamlabsOBSService(); } if (ChannelSession.Settings.EnableXSplitConnection) { await ChannelSession.Services.InitializeXSplitServer(); } if (ChannelSession.Settings.EnableOverlay) { await ChannelSession.Services.InitializeOverlayServer(); } if (ChannelSession.Settings.EnableDeveloperAPI) { await ChannelSession.Services.InitializeDeveloperAPI(); } if (ChannelSession.Settings.StreamlabsOAuthToken != null) { await ChannelSession.Services.InitializeStreamlabs(); } if (ChannelSession.Settings.GameWispOAuthToken != null) { await ChannelSession.Services.InitializeGameWisp(); } if (ChannelSession.Settings.GawkBoxOAuthToken != null) { await ChannelSession.Services.InitializeGawkBox(); } if (ChannelSession.Settings.TwitterOAuthToken != null) { await ChannelSession.Services.InitializeTwitter(); } if (ChannelSession.Settings.SpotifyOAuthToken != null) { await ChannelSession.Services.InitializeSpotify(); } if (ChannelSession.Settings.DiscordOAuthToken != null) { await ChannelSession.Services.InitializeDiscord(); } if (ChannelSession.Settings.TiltifyOAuthToken != null) { await ChannelSession.Services.InitializeTiltify(); } if (ChannelSession.Settings.TipeeeStreamOAuthToken != null) { await ChannelSession.Services.InitializeTipeeeStream(); } if (ChannelSession.Settings.TreatStreamOAuthToken != null) { await ChannelSession.Services.InitializeTreatStream(); } if (ChannelSession.Settings.StreamJarOAuthToken != null) { await ChannelSession.Services.InitializeStreamJar(); } if (ChannelSession.Settings.PatreonOAuthToken != null) { await ChannelSession.Services.InitializePatreon(); } foreach (CommandBase command in ChannelSession.AllEnabledCommands) { foreach (ActionBase action in command.Actions) { if (action is CounterAction) { await((CounterAction)action).SetCounterValue(); } } } if (ChannelSession.Settings.DefaultInteractiveGame > 0) { IEnumerable <InteractiveGameListingModel> games = await ChannelSession.Connection.GetOwnedInteractiveGames(ChannelSession.Channel); InteractiveGameListingModel game = games.FirstOrDefault(g => g.id.Equals(ChannelSession.Settings.DefaultInteractiveGame)); if (game != null) { if (!await ChannelSession.Interactive.Connect(game)) { await ChannelSession.Interactive.Disconnect(); } } else { ChannelSession.Settings.DefaultInteractiveGame = 0; } } foreach (UserCurrencyViewModel currency in ChannelSession.Settings.Currencies.Values) { if (currency.ShouldBeReset()) { await currency.Reset(); } } if (ChannelSession.Settings.ModerationResetStrikesOnLaunch) { foreach (UserDataViewModel userData in ChannelSession.Settings.UserData.Values) { userData.ModerationStrikes = 0; ChannelSession.Settings.UserData.ManualValueChanged(userData.ID); } } await ChannelSession.LoadUserEmoticons(); await ChannelSession.SaveSettings(); await ChannelSession.Services.Settings.SaveBackup(ChannelSession.Settings); await ChannelSession.Services.Settings.PerformBackupIfApplicable(ChannelSession.Settings); ChannelSession.Services.Telemetry.TrackLogin(); if (ChannelSession.Settings.IsStreamer) { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Task.Run(async() => { await ChannelSession.Services.MixItUpService.SendUserFeatureEvent(new UserFeatureEvent(ChannelSession.User.id)); }); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } GlobalEvents.OnRankChanged += GlobalEvents_OnRankChanged; return(true); } } return(false); }
public static void Main(string[] args) { List <OAuthClientScopeEnum> scopes = new List <OAuthClientScopeEnum>() { OAuthClientScopeEnum.channel__details__self, OAuthClientScopeEnum.channel__update__self, OAuthClientScopeEnum.interactive__manage__self, OAuthClientScopeEnum.interactive__robot__self, OAuthClientScopeEnum.user__details__self, OAuthClientScopeEnum.user__log__self, OAuthClientScopeEnum.user__notification__self, OAuthClientScopeEnum.user__update__self, }; System.Console.WriteLine("Connecting to Mixer..."); MixerConnection connection = MixerConnection.ConnectViaLocalhostOAuthBrowser(ConfigurationManager.AppSettings["ClientID"], scopes).Result; if (connection != null) { System.Console.WriteLine("Mixer connection successful!"); UserModel user = connection.Users.GetCurrentUser().Result; ExpandedChannelModel channel = connection.Channels.GetChannel(user.username).Result; System.Console.WriteLine(string.Format("Logged in as: {0}", user.username)); //List<InteractiveGameListingModel> games = new List<InteractiveGameListingModel>(connection.Interactive.GetOwnedInteractiveGames(channel).Result); //InteractiveGameListingModel game = games[4]; var gameVersion = connection.Interactive.GetInteractiveGameVersion(185683).Result; var game = connection.Interactive.GetInteractiveGame(gameVersion.gameId).Result; if (gameVersion != null) { System.Console.WriteLine(); System.Console.WriteLine(string.Format("Connecting to channel interactive using game {0}...", game.name)); interactiveClient = InteractiveClient.CreateFromChannel(connection, channel, game, gameVersion).Result; if (interactiveClient.Connect().Result&& interactiveClient.Ready().Result) { InteractiveConnectedSceneGroupCollectionModel scenes = interactiveClient.GetScenes().Result; if (scenes != null) { Program.scenes.AddRange(scenes.scenes); foreach (InteractiveConnectedSceneModel scene in Program.scenes) { foreach (InteractiveConnectedButtonControlModel button in scene.buttons) { buttons.Add(button); } foreach (InteractiveConnectedJoystickControlModel joystick in scene.joysticks) { joysticks.Add(joystick); } foreach (InteractiveConnectedLabelControlModel label in scene.labels) { labels.Add(label); } foreach (InteractiveConnectedTextBoxControlModel textBox in scene.textBoxes) { textBoxes.Add(textBox); } foreach (InteractiveControlModel control in scene.allControls) { control.disabled = false; } interactiveClient.UpdateControls(scene, scene.allControls).Wait(); } interactiveClient.OnDisconnectOccurred += InteractiveClient_OnDisconnectOccurred; interactiveClient.OnParticipantJoin += InteractiveClient_OnParticipantJoin; interactiveClient.OnParticipantLeave += InteractiveClient_OnParticipantLeave; interactiveClient.OnGiveInput += InteractiveClient_OnGiveInput; interactiveClient.OnEventOccurred += InteractiveClient_OnEventOccurred; interactiveClient.OnPacketReceivedOccurred += InteractiveClient_OnPacketReceivedOccurred; interactiveClient.OnMethodOccurred += InteractiveClient_OnMethodOccurred; while (true) { } } } } } }