public RequestBotConfig()
        {
            Instance = this;

            _configWatcher = new FileSystemWatcher();

            Task.Run(() =>
            {
                while (!Directory.Exists(Path.GetDirectoryName(FilePath)))
                {
                    Thread.Sleep(100);
                }

                Plugin.Log("FilePath exists! Continuing initialization!");

                if (File.Exists(FilePath))
                {
                    Load();
                }
                Save();

                _configWatcher.Path                = Path.GetDirectoryName(FilePath);
                _configWatcher.NotifyFilter        = NotifyFilters.LastWrite;
                _configWatcher.Filter              = $"RequestBotSettings.ini";
                _configWatcher.EnableRaisingEvents = true;

                _configWatcher.Changed += ConfigWatcherOnChanged;
            });
        }
Example #2
0
        public void OnStart()
        {
            if (Instance != null)
            {
                return;
            }
            Instance = this;

            // create SRM UserDataFolder folder if needed, or rename old streamcore folder
            if (!Directory.Exists(DataPath))
            {
                if (Directory.Exists(OldDataPath))
                {
                    Directory.Move(OldDataPath, DataPath);
                }
                else
                {
                    Directory.CreateDirectory(DataPath);
                }
            }

            // initialize config
            RequestBotConfig = new RequestBotConfig();

            Dispatcher.Initialize();

            // create our internal webclient
            WebClient = new WebClient();

            // create udp listener
            UdpListener = new UdpListener();

            SongBrowserPluginPresent = IPA.Loader.PluginManager.GetPlugin("Song Browser") != null;
            ChatCorePluginPresent    = IPA.Loader.PluginManager.GetPlugin("ChatCore") != null;

            // setup handle for fresh menu scene changes
            BS_Utils.Utilities.BSEvents.OnLoad();
            BS_Utils.Utilities.BSEvents.lateMenuSceneLoadedFresh += OnLateMenuSceneLoadedFresh;

            // init sprites
            Base64Sprites.Init();
        }
        //public bool MyChatMessageHandler(TwitchMessage msg)
        //{
        //    string excludefilename = "chatexclude.users";
        //    return RequestBot.Instance && RequestBot.listcollection.contains(ref excludefilename, msg.user.displayName.ToLower(), RequestBot.ListFlags.Uncached);
        //}

        private void OnConfigChangedEvent(RequestBotConfig config)
        {
            _configChanged = true;
        }