Esempio n. 1
0
        private void LoadData()
        {
            //Load the info for the guilds and the users they want reported.
            string guildInfoResult = SaveLoadService.Load(twitchGuildInfoFilename);

            if (guildInfoResult != null)
            {
                guilds = JsonConvert.DeserializeObject <List <TwitchGuildDefinition> >(guildInfoResult);
            }

            UpdateMonitoredChannels();
        }
Esempio n. 2
0
        private void UpdateMonitoredChannels()
        {
            // Get all channels we should report on.
            List <string> users = new List <string>();

            foreach (var guild in guilds)
            {
                users.AddRange(guild.users);
            }

            monitorService.AddTrackedUsers(users.Distinct().ToArray());

            SaveLoadService.Save(twitchGuildInfoFilename, guilds);
        }
Esempio n. 3
0
        public TwitchService(DiscordSocketClient client)
        {
            if (!serviceEnabled)
            {
                Console.WriteLine("Twitch service disabled.");
                return;
            }
            this.client = client;
            api         = new TwitchAPI();
            TwitchKeys twitchKeys = SaveLoadService.Load <TwitchKeys>(twitchKeysFilename);

            if (twitchKeys == null)
            {
                twitchKeys = new TwitchKeys();
                SaveLoadService.Save(twitchKeysFilename, twitchKeys);
            }
            api.Settings.AccessToken        = twitchKeys.accessToken;
            api.Settings.ClientId           = twitchKeys.clientID;
            api.Settings.Secret             = twitchKeys.secret;
            monitorService                  = new LiveStreamMonitorService(api, 240);
            monitorService.OnStreamOnline  += OnStreamOnline;
            monitorService.OnStreamOffline += OnStreamOffline;
            LoadData();
        }
Esempio n. 4
0
 public void Save()
 {
     SaveLoadService.Save(monitoredUsersFilename, autoRoles);
 }