Ejemplo n.º 1
0
        private static async Task UpdateStatus(LCUProvider lcu)
        {
            if (Stopping)
            {
                Log.Verborse("App", "Updating LoL status with initial message");
                await lcu.StatusMessage(InitStatus);

                Abort();
                return;
            }

            Log.Verborse("App", "Updating LoL status");

            string song = ExternalProvider.ReadStatusFile();

            if (song != "")
            {
                Log.Verborse("App", "Updating LoL status with External Provider");
            }
            else
            {
                song = SpotifyProvider.Song();
                if (song != "")
                {
                    Log.Verborse("App", "Updating LoL status with Spotify Provider");
                    if (song.Length > (LIMIT_STATUS - 2))
                    {
                        song = SpotifyProvider.Track();
                    }
                }
                else
                {
                    Log.Verborse("App", "Spotify is close or stopped?");
                }
            }


            if (song.Length > (LIMIT_STATUS - 2))
            {
                song = song.Substring(0, LIMIT_STATUS - 3) + "…";
            }
            else if (song.Length > (LIMIT_STATUS - 2))
            {
                song = song.Substring(0, LIMIT_STATUS - 2);
            }

            if (song.Equals("") || string.IsNullOrEmpty(song))
            {
                Log.Verborse("App", "Empty current song, updating LoL status with initial message");
                await lcu.StatusMessage(InitStatus);
            }
            else if (LastSong == null || !LastSong.Equals(song))
            {
                Log.Verborse("App", "Updating LoL status with " + song);
                await lcu.StatusMessage(string.Format("🎶 {0}", song));

                LastSong = song;
            }
            else
            {
                Log.Verborse("App", "LoL status not update");
            }
        }