Beispiel #1
0
        public static void Run()
        {
            stop  = false;
            pause = false;

            Console.WriteLine("Scaning for anime every {0} miliseconds...", Config.program.ScanInterval);
            while (!stop)
            {
                if (!pause)
                {
                    AnimeName.Anime anime = AnimeName.GetAnime();
                    if (anime == null)
                    {
                        if (lastAnime != null)
                        {
                            Log("No anime detected.");
                            DiscordActivity.Clear();
                        }
                    }
                    else
                    {
                        if (lastAnime == null)
                        {
                            Log("Anime detected.");
                            DiscordActivity.Set(anime);
                        }
                        else if (lastAnime.name != anime.name)
                        {
                            Log("New anime detected.");
                            DiscordActivity.Set(anime);
                        }
                        else if (lastAnime.episode != anime.episode)
                        {
                            Log("New episode detected.");
                            DiscordActivity.Set(anime);
                        }
                    }
                    lastAnime = anime;
                }

                int sleepTime = Config.program.ScanInterval;
                do
                {
                    DiscordActivity.Update();
                    if (sleepTime <= 0 || stop)
                    {
                        break;
                    }
                    else
                    {
                        Thread.Sleep(Math.Min(200, sleepTime));
                    }
                    sleepTime -= 200;
                }while (sleepTime > 0);
            }
            DiscordActivity.Clear();
        }
Beispiel #2
0
 public static void Pause()
 {
     Log("Anime detection paused.");
     pause = true;
     if (lastAnime != null)
     {
         lastAnime = null;
         DiscordActivity.Clear();
     }
 }
Beispiel #3
0
 public static void ForceUpdate()
 {
     lastAnime = AnimeName.GetAnime();
     if (lastAnime != null)
     {
         Log("Force update anime to discord.");
         DiscordActivity.Set(lastAnime);
     }
     else
     {
         Log("Cannot force update. (No anime detected).");
     }
 }
Beispiel #4
0
        public static void ForceReconnect()
        {
            DiscordActivity.Clear();

            lastAnime = AnimeName.GetAnime();
            if (lastAnime != null)
            {
                Log("Force reconnect discord.");
                DiscordActivity.Set(lastAnime);
            }
            else
            {
                Log("Cannot force reconnect. (No anime detected).");
            }
        }