Beispiel #1
0
        private async Task TryEnterMeet(string?link)
        {
            if (MeetExists(link))
            {
                bool langClass = activeMessage != null?IsLanguageClass(activeMessage) : false;

                int peopleNeeded = GetPeopleNeeded(langClass);

                if (meetBot.CanJoin())
                {
                    int peopleInOverview = meetBot.PeopleInMeetOverview();

                    int seconds = 3;
                    // Wait two minutes
                    for (int i = 0; i < (60 * 2 / seconds) && peopleInOverview < peopleNeeded; i++)
                    {
                        await Task.Delay(new TimeSpan(0, 0, seconds), token);

                        peopleInOverview = meetBot.PeopleInMeetOverview();
                    }

                    if (peopleInOverview >= peopleNeeded)
                    {
                        // Pop
                        lastMessage   = activeMessage;
                        activeMessage = null;

                        logger.Info("Entering meet");
                        logger.Debug("with {0} people", peopleInOverview);
                        meetBot.EnterMeet();

                        await WaitForPeopleToLeave(minimumPeople : peopleNeeded);

                        logger.Info("Leaving meet");
                        meetBot.LeaveMeet();
                    }
                    logger.Debug("Back to meet loop");
                }
            }
        }
Beispiel #2
0
        private static void MeetTest()
        {
            if (!File.Exists("config.json"))
            {
                MeetBot.CreateEmpty <Config>();
                Console.WriteLine("Created sample config.");
                return;
            }
            Config  config = JsonConvert.DeserializeObject <Config>(File.ReadAllText(Path.GetFullPath(".") + "/config.json"));
            MeetBot bot    = new MeetBot(config);

            try
            {
                bool loggedIn = bot.Login();
                if (!loggedIn)
                {
                    Console.WriteLine("Retrying login");
                    for (int i = 0; i < 3 && !loggedIn; i++)
                    {
                        loggedIn = bot.Login();
                    }
                    Console.WriteLine("Logged in: " + loggedIn);
                }
                bot.EnterMeetOverview("https://meet.google.com/rje-zpyi-jcg");
                Console.WriteLine(bot.PeopleInMeetOverview());
                bot.EnterMeet();
                Task wait = WaitFor(10);
                while (!wait.IsCompleted)
                {
                    Console.WriteLine(bot.PeopleInMeet());
                }
                bot.LeaveMeet();
            }
            finally
            {
                bot.Dispose();
            }
        }