Пример #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();
        }
Пример #2
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).");
     }
 }
Пример #3
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).");
            }
        }