private static async Task Version31Upgrade(int version, string filePath) { if (version < 31) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); settings.GiveawayStartedReminderCommand = CustomCommand.BasicChatCommand("Giveaway Started/Reminder", "A giveaway has started for $giveawayitem! Type $giveawaycommand in chat in the next $giveawaytimelimit minute(s) to enter!"); foreach (GameCommandBase command in settings.GameCommands) { if (command is GroupGameCommand) { GroupGameCommand groupCommand = (GroupGameCommand)command; groupCommand.NotEnoughPlayersCommand = CustomCommand.BasicChatCommand("Game Sub-Command", "@$username couldn't get enough users to join in..."); } else if (command is DuelGameCommand) { DuelGameCommand duelCommand = (DuelGameCommand)command; duelCommand.NotAcceptedCommand = CustomCommand.BasicChatCommand("Game Sub-Command", "@$targetusername did not respond in time..."); } } await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version35Upgrade(int version, string filePath) { if (version < 35) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); foreach (CommandBase command in GetAllCommands(settings)) { StoreCommandUpgrader.RestructureNewerOverlayActions(command.Actions); } #pragma warning disable CS0612 // Type or member is obsolete foreach (OverlayWidget widget in settings.overlayWidgetsInternal) { OverlayItemModelBase newItem = StoreCommandUpgrader.ConvertOverlayItem(widget.Item); newItem.ID = widget.Item.ID; newItem.Position = new OverlayItemPositionModel((OverlayItemPositionType)widget.Position.PositionType, widget.Position.Horizontal, widget.Position.Vertical, 0); OverlayWidgetModel newWidget = new OverlayWidgetModel(widget.Name, widget.OverlayName, newItem, 0); settings.OverlayWidgets.Add(newWidget); if (newWidget.SupportsRefreshUpdating && !widget.DontRefresh) { newWidget.RefreshTime = settings.OverlayWidgetRefreshTime; } } settings.overlayWidgetsInternal.Clear(); #pragma warning restore CS0612 // Type or member is obsolete await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version15Upgrade(int version, string filePath) { if (version < 15) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); #pragma warning disable CS0612 // Type or member is obsolete EventCommand donationCommand = settings.EventCommands.FirstOrDefault(c => c.MatchesEvent(EnumHelper.GetEnumName(OtherEventTypeEnum.Donation))); #pragma warning restore CS0612 // Type or member is obsolete if (donationCommand != null) { string donationCommandJson = SerializerHelper.SerializeToString(donationCommand); EventCommand streamlabsCommand = SerializerHelper.DeserializeFromString <EventCommand>(donationCommandJson); streamlabsCommand.OtherEventType = OtherEventTypeEnum.StreamlabsDonation; settings.EventCommands.Add(streamlabsCommand); EventCommand gawkBoxCommand = SerializerHelper.DeserializeFromString <EventCommand>(donationCommandJson); gawkBoxCommand.OtherEventType = OtherEventTypeEnum.GawkBoxDonation; settings.EventCommands.Add(gawkBoxCommand); settings.EventCommands.Remove(donationCommand); } await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version34Upgrade(int version, string filePath) { if (version < 34) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); string defaultColor = "Default Color"; if (settings.ChatUserJoinLeaveColorScheme.Equals(defaultColor)) { settings.ChatUserJoinLeaveColorScheme = ColorSchemes.DefaultColorScheme; } if (settings.ChatEventAlertsColorScheme.Equals(defaultColor)) { settings.ChatEventAlertsColorScheme = ColorSchemes.DefaultColorScheme; } if (settings.ChatInteractiveAlertsColorScheme.Equals(defaultColor)) { settings.ChatInteractiveAlertsColorScheme = ColorSchemes.DefaultColorScheme; } await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version22Upgrade(int version, string filePath) { if (version < 22) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); PreMadeChatCommandSettings cSetting = settings.PreMadeChatCommandSettings.FirstOrDefault(c => c.Name.Equals("Ban")); if (cSetting != null) { cSetting.IsEnabled = false; } List <CommandBase> commands = new List <CommandBase>(); commands.AddRange(settings.ChatCommands); commands.AddRange(settings.EventCommands); commands.AddRange(settings.InteractiveCommands); commands.AddRange(settings.TimerCommands); commands.AddRange(settings.ActionGroupCommands); commands.AddRange(settings.GameCommands); foreach (CommandBase command in commands) { StoreCommandUpgrader.ChangeCounterActionsToUseSpecialIdentifiers(command.Actions); } await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version27Upgrade(int version, string filePath) { if (version < 27) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); try { SQLiteDatabaseWrapper databaseWrapper = new SQLiteDatabaseWrapper(((DesktopSettingsService)ChannelSession.Services.Settings).GetDatabaseFilePath(settings)); await databaseWrapper.RunWriteCommand("ALTER TABLE Users ADD COLUMN InventoryAmounts TEXT"); await databaseWrapper.RunWriteCommand("UPDATE Users SET InventoryAmounts = '{ }'"); } catch (Exception ex) { Logger.Log(ex); } foreach (UserCurrencyViewModel currency in settings.Currencies.Values) { currency.ModeratorBonus = currency.SubscriberBonus; } await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version28Upgrade(int version, string filePath) { if (version < 28) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); foreach (InteractiveCommand command in settings.InteractiveCommands) { if (command is InteractiveButtonCommand) { InteractiveButtonCommand buttonCommand = (InteractiveButtonCommand)command; int triggerNumber = (int)buttonCommand.Trigger; if (triggerNumber == 0 || triggerNumber == 3) { buttonCommand.Trigger = InteractiveButtonCommandTriggerType.MouseKeyDown; } else { buttonCommand.Trigger = InteractiveButtonCommandTriggerType.MouseKeyUp; } buttonCommand.Commands = new List <string>() { EnumHelper.GetEnumName(buttonCommand.Trigger) }; } } await ChannelSession.Services.Settings.Save(settings); } }
internal static async Task UpgradeSettingsToLatest(int version, string filePath) { await DesktopSettingsUpgrader.Version16Upgrade(version, filePath); await DesktopSettingsUpgrader.Version17Upgrade(version, filePath); await DesktopSettingsUpgrader.Version18Upgrade(version, filePath); await DesktopSettingsUpgrader.Version19Upgrade(version, filePath); await DesktopSettingsUpgrader.Version20Upgrade(version, filePath); await DesktopSettingsUpgrader.Version21Upgrade(version, filePath); await DesktopSettingsUpgrader.Version22Upgrade(version, filePath); await DesktopSettingsUpgrader.Version23Upgrade(version, filePath); await DesktopSettingsUpgrader.Version24Upgrade(version, filePath); await DesktopSettingsUpgrader.Version25Upgrade(version, filePath); await DesktopSettingsUpgrader.Version26Upgrade(version, filePath); await DesktopSettingsUpgrader.Version27Upgrade(version, filePath); DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); settings.InitializeDB = false; await ChannelSession.Services.Settings.Initialize(settings); settings.Version = DesktopChannelSettings.LatestVersion; await ChannelSession.Services.Settings.Save(settings); }
/// <summary> /// /// </summary> /// <returns></returns> public Setting GetSeting() { string settingFilePath = Path.Combine(GetApplicationPath(), Settings.Default.SettingFileName); var setting = File.Exists(settingFilePath) ? SerializerHelper.DeserializeFromFile <Setting>(settingFilePath) : new Setting(); if (string.IsNullOrEmpty(setting.ReportingParameter.TemplatePath)) { setting.ReportingParameter.TemplatePath = Path.Combine(GetApplicationPath(), Settings.Default.TemplateDirectory); } return(setting); }
private static async Task Version17Upgrade(int version, string filePath) { if (version < 17) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); settings.GiveawayTimer = Math.Max(settings.GiveawayTimer / 60, 1); await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version21Upgrade(int version, string filePath) { if (version < 21) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); settings.GameCommands.Clear(); await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version25Upgrade(int version, string filePath) { if (version < 25) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); settings.OverlayWidgetRefreshTime = 5; await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version12Upgrade(int version, string filePath) { if (version < 12) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); SQLiteDatabaseWrapper databaseWrapper = new SQLiteDatabaseWrapper(((DesktopSettingsService)ChannelSession.Services.Settings).GetDatabaseFilePath(settings)); await databaseWrapper.RunWriteCommand("ALTER TABLE Users ADD COLUMN CustomCommands TEXT"); await databaseWrapper.RunWriteCommand("ALTER TABLE Users ADD COLUMN Options TEXT"); } }
private static async Task Version30Upgrade(int version, string filePath) { if (version < 30) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); settings.GameQueueUserJoinedCommand = CustomCommand.BasicChatCommand("Game Queue Used Joined", "You are #$queueposition in the queue to play.", isWhisper: true); settings.GameQueueUserSelectedCommand = CustomCommand.BasicChatCommand("Game Queue Used Selected", "It's time to play @$username! Listen carefully for instructions on how to join..."); await ChannelSession.Services.Settings.Save(settings); } }
private async Task <IChannelSettings> LoadSettings(string filePath) { string fileData = await ChannelSession.Services.FileService.ReadFile(filePath); JObject settingsJObj = JObject.Parse(fileData); int currentVersion = (int)settingsJObj["Version"]; if (currentVersion < DesktopChannelSettings.LatestVersion) { await DesktopSettingsUpgrader.UpgradeSettingsToLatest(currentVersion, filePath); } return(await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath)); }
private static async Task Version29Upgrade(int version, string filePath) { if (version < 29) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); settings.SongAddedCommand = CustomCommand.BasicChatCommand("Song Request Added", "$songtitle has been added to the queue", isWhisper: true); settings.SongPlayedCommand = CustomCommand.BasicChatCommand("Song Request Played", "Now Playing: $songtitle"); await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version26Upgrade(int version, string filePath) { if (version < 26) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); settings.ModerationFilteredWordsApplyStrikes = true; settings.ModerationChatTextApplyStrikes = true; settings.ModerationBlockLinksApplyStrikes = true; await ChannelSession.Services.Settings.Save(settings); } }
public async Task <bool> Initialize() { if (!Directory.Exists("Settings")) { Directory.CreateDirectory("Settings"); } this.settings = await SerializerHelper.DeserializeFromFile <AutoHosterSettingsModel>(SettingsFileName); if (this.settings != null) { try { this.connection = await MixerConnection.ConnectViaOAuthToken(this.settings.OAuthToken); } catch (Exception ex) { Base.Util.Logger.Log(ex); } } else { this.settings = new AutoHosterSettingsModel(); } if (this.connection == null) { try { this.connection = await MixerConnection.ConnectViaLocalhostOAuthBrowser(ClientID, new List <OAuthClientScopeEnum>() { OAuthClientScopeEnum.channel__details__self, OAuthClientScopeEnum.channel__update__self, OAuthClientScopeEnum.chat__connect, OAuthClientScopeEnum.chat__chat, OAuthClientScopeEnum.chat__whisper }, loginSuccessHtmlPageFilePath : "LoginRedirectPage.html"); } catch (Exception ex) { Base.Util.Logger.Log(ex); } if (this.connection == null) { return(false); } } foreach (ChannelHostModel host in this.settings.Channels) { this.Channels.Add(host); } this.NotifyPropertyChanged("HostingOrderName"); this.NotifyPropertyChanged("AgeRatingName"); this.NotifyPropertyChanged("MaxHostLength"); this.NotifyPropertyChanged("WhisperMessage"); return(true); }
private static async Task Version24Upgrade(int version, string filePath) { if (version < 24) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); foreach (CommandBase command in DesktopSettingsUpgrader.GetAllCommands(settings)) { StoreCommandUpgrader.RestructureNewOverlayActions(command.Actions); } await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version36Upgrade(int version, string filePath) { if (version < 36) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); foreach (CommandBase command in GetAllCommands(settings)) { StoreCommandUpgrader.ReplaceActionGroupAction(command.Actions); } await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version20Upgrade(int version, string filePath) { if (version < 20) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); settings.ChatCommands.RemoveAll(c => c == null); settings.EventCommands.RemoveAll(c => c == null); settings.InteractiveCommands.RemoveAll(c => c == null); settings.TimerCommands.RemoveAll(c => c == null); settings.ActionGroupCommands.RemoveAll(c => c == null); settings.GameCommands.RemoveAll(c => c == null); await ChannelSession.Services.Settings.Save(settings); } }
private async Task <IChannelSettings> LoadSettings(string filePath) { string data = File.ReadAllText(filePath); if (!data.Contains("\"Version\":")) { await DesktopSettingsUpgrader.UpgradeSettingsToLatest(0, filePath); } DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); if (settings.ShouldBeUpgraded()) { await DesktopSettingsUpgrader.UpgradeSettingsToLatest(settings.Version, filePath); settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); } return(settings); }
private static async Task Version23Upgrade(int version, string filePath) { if (version < 23) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); settings.GiveawayMaximumEntries = 1; settings.GiveawayUserJoinedCommand = CustomCommand.BasicChatCommand("Giveaway User Joined", "You have been entered into the giveaway, stay tuned to see who wins!", isWhisper: true); settings.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); settings.ModerationStrike1Command = CustomCommand.BasicChatCommand("Moderation Strike 1", "You have received a moderation strike, you currently have $usermoderationstrikes strike(s)", isWhisper: true); settings.ModerationStrike2Command = CustomCommand.BasicChatCommand("Moderation Strike 2", "You have received a moderation strike, you currently have $usermoderationstrikes strike(s)", isWhisper: true); settings.ModerationStrike3Command = CustomCommand.BasicChatCommand("Moderation Strike 3", "You have received a moderation strike, you currently have $usermoderationstrikes strike(s)", isWhisper: true); await ChannelSession.Services.Settings.Save(settings); } }
public void Init() { _view.VideoTitleList = new BindingList <Video>(); _view.WebBrowser.ScriptErrorsSuppressed = true; FiddlerApplication.BeforeRequest += FiddlerApplicationBeforeRequest; CONFIG.IgnoreServerCertErrors = false; FiddlerApplication.Startup(0, true, true); var resumeVideos = _serializerHelper.DeserializeFromFile <List <Video> >(); if (resumeVideos != null) { var currentVideoIndex = resumeVideos.Count(video => video.IsComplated); _currentVideoIndex = currentVideoIndex; _videoList = resumeVideos; _view.WebBrowser.Navigate(_videoList[_currentVideoIndex].PageUrl); return; } _view.WebBrowser.Navigate(ConfigurationManager.AppSettings.Get("StartupUrl")); }
private async Task GatherSoundwaveSettings() { if (Directory.Exists(SoundwaveInteractiveAppDataSettingsFolder)) { string interactiveFilePath = Path.Combine(SoundwaveInteractiveAppDataSettingsFolder, "interactive.json"); string profilesFilePath = Path.Combine(SoundwaveInteractiveAppDataSettingsFolder, "profiles.json"); string soundsFilePath = Path.Combine(SoundwaveInteractiveAppDataSettingsFolder, "sounds.json"); if (File.Exists(interactiveFilePath) && File.Exists(profilesFilePath) && File.Exists(soundsFilePath)) { JObject interactive = await SerializerHelper.DeserializeFromFile <JObject>(interactiveFilePath); JObject profiles = await SerializerHelper.DeserializeFromFile <JObject>(profilesFilePath); JObject sounds = await SerializerHelper.DeserializeFromFile <JObject>(soundsFilePath); this.soundwaveData = new SoundwaveSettings(interactive, profiles, sounds); } } }
private static async Task Version13Upgrade(int version, string filePath) { if (version < 13) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <LegacyDesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); List <PermissionsCommandBase> commands = new List <PermissionsCommandBase>(); commands.AddRange(settings.ChatCommands); commands.AddRange(settings.GameCommands); foreach (PermissionsCommandBase command in commands) { #pragma warning disable CS0612 // Type or member is obsolete command.Requirements.Role.MixerRole = command.Requirements.UserRole; #pragma warning restore CS0612 // Type or member is obsolete } foreach (InteractiveCommand command in settings.InteractiveCommands) { if (command is InteractiveButtonCommand) { InteractiveButtonCommand bCommand = (InteractiveButtonCommand)command; #pragma warning disable CS0612 // Type or member is obsolete if (!string.IsNullOrEmpty(bCommand.CooldownGroup) && settings.interactiveCooldownGroupsInternal.ContainsKey(bCommand.CooldownGroup)) { bCommand.Requirements.Cooldown = new CooldownRequirementViewModel(CooldownTypeEnum.Group, bCommand.CooldownGroup, settings.interactiveCooldownGroupsInternal[bCommand.CooldownGroup]); settings.CooldownGroups[bCommand.CooldownGroup] = settings.interactiveCooldownGroupsInternal[bCommand.CooldownGroup]; } else { bCommand.Requirements.Cooldown = new CooldownRequirementViewModel(CooldownTypeEnum.Individual, bCommand.IndividualCooldown); } #pragma warning restore CS0612 // Type or member is obsolete } } await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version32Upgrade(int version, string filePath) { if (version < 32) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); settings.SongRemovedCommand = CustomCommand.BasicChatCommand("Song Request Removed", "$songtitle has been removed from the queue", isWhisper: true); foreach (GameCommandBase command in settings.GameCommands.ToList()) { if (command is BetGameCommand) { settings.GameCommands.Remove(command); } } await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version33Upgrade(int version, string filePath) { if (version < 33) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); #pragma warning disable CS0612 // Type or member is obsolete foreach (OverlayWidget widget in settings.overlayWidgetsInternal.ToList()) { if (widget.Item is OverlayGameStats) { settings.overlayWidgetsInternal.Remove(widget); } } #pragma warning restore CS0612 // Type or member is obsolete await ChannelSession.Services.Settings.Save(settings); } }
private async Task <IChannelSettings> LoadSettings(string filePath) { int currentVersion = await GetSettingsVersion(filePath); if (currentVersion == -1) { // Settings file is invalid, we can't use this return(null); } else if (currentVersion > DesktopChannelSettings.LatestVersion) { // Future build, like a preview build, we can't load this return(null); } else if (currentVersion < DesktopChannelSettings.LatestVersion) { await DesktopSettingsUpgrader.UpgradeSettingsToLatest(currentVersion, filePath); } return(await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath)); }
private static async Task Version18Upgrade(int version, string filePath) { if (version < 18) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); List <CommandBase> commands = new List <CommandBase>(); commands.AddRange(settings.ChatCommands); commands.AddRange(settings.EventCommands); commands.AddRange(settings.InteractiveCommands); commands.AddRange(settings.TimerCommands); commands.AddRange(settings.ActionGroupCommands); commands.AddRange(settings.GameCommands); foreach (CommandBase command in commands) { StoreCommandUpgrader.SeperateChatFromCurrencyActions(command.Actions); } await ChannelSession.Services.Settings.Save(settings); } }