Esempio n. 1
0
        public FollowerBot(string[] configArgs, ILogger logger)
        {
            Log = logger;

            Log.LogInformation("## LOADING...");
            LoadConfig(configArgs);

            LoadData();

            string w = PseudoRand.Next(Config.SeleniumWindowMinW, Config.SeleniumWindowMaxW).ToString(CultureInfo.InvariantCulture);
            string h = PseudoRand.Next(Config.SeleniumWindowMinH, Config.SeleniumWindowMaxH).ToString(CultureInfo.InvariantCulture);

            if (string.IsNullOrWhiteSpace(Config.SeleniumRemoteServer))
            {
                Log.LogDebug("NewChromeSeleniumWrapper({0}, {1}, {2})", ExecPath, w, h);
                Selenium = SeleniumWrapper.NewChromeSeleniumWrapper(ExecPath, w, h, Config.SeleniumBrowserArguments, Config.BotSeleniumTimeoutSec);
            }
            else
            {
                if (Config.SeleniumRemoteServerWarmUpWaitMs > 0)
                {
                    Task.Delay(Config.SeleniumRemoteServerWarmUpWaitMs)
                    .Wait();
                }
                Log.LogDebug("NewRemoteSeleniumWrapper({0}, {1}, {2})", Config.SeleniumRemoteServer, w, h);
                Selenium = SeleniumWrapper.NewRemoteSeleniumWrapper(Config.SeleniumRemoteServer, w, h, Config.SeleniumBrowserArguments, Config.BotSeleniumTimeoutSec);
            }
        }
Esempio n. 2
0
        private void DoContactsFollow()
        {
            int todo = PseudoRand.Next(Config.BotFollowTaskBatchMinLimit, Config.BotFollowTaskBatchMaxLimit);
            int c    = Data.ContactsToFollow.Count;

            while (Data.ContactsToFollow.TryDequeue(out string uri) && todo > 0)
            {
                if (!MoveTo(uri))
                {
                    Log.LogWarning("ACTION STOPED : FLICKR RETURN ERROR 500 ON ({0})", uri);
                    break; // no retry
                }
                try
                {
                    MyContactsInTryout.Add(uri);
                    if (Selenium.GetElements(Config.CssContactFollow).Any()) // manage the already followed like this
                    {
                        Selenium.Click(Config.CssContactFollow);
                        Data.MyContacts.Add(uri);
                        WaitHumanizer();// the url relad may break a waiting ball

                        // issue detection : Manage limit to 20 follow on a new account : https://www.flickr.com/help/forum/en-us/72157651299881165/  Then there seem to be another limit
                        if (Selenium.GetElements(Config.CssContactFollow).Any()) // may be slow so will wait if required
                        {
                            WaitHumanizer();                                     // give a last chance
                            if (Selenium.GetElements(Config.CssContactFollow, true, true).Any())
                            {
                                Log.LogWarning("ACTION STOPED : SEEMS USER CAN'T FOLLOW ({0}) ANYMORE", uri);
                                break; // no retry
                            }
                        }
                        // hang issue detection
                        if (Selenium.GetElements(Config.CssModalWaiterBalls, true, true).Any())     // will not wait
                        {
                            WaitHumanizer();                                                        // give a last chance...
                            if (Selenium.GetElements(Config.CssModalWaiterBalls, true, true).Any()) // will not wait
                            {
                                Log.LogWarning("ACTION STOPED : SEEMS FLICKR HANG ON THIS CONTACT ({0})", uri);
                                break; // no retry
                            }
                        }
                        todo--;
                    }
                }
                catch (Exception ex)
                {
                    Log.LogWarning(default, ex, "ACTION STOPED : {0}", ex.GetBaseException().Message);
Esempio n. 3
0
        public void Run()
        {
            Log.LogInformation("## LOGGING...");

            if (Data.UserContactUrl == null ||
                !TryAuthCookies())
            {
                AuthLogin();
            }
            Log.LogInformation("Logged user :  {0}", Data.UserContactUrl);
            PostAuthInit();
            SaveData(); // save cookies at last

            Log.LogInformation("## RUNNING...");

            foreach (string curTask in GetTasks(Config.BotTasks, Config.BotSaveAfterEachAction, Config.BotSaveOnEnd, Config.BotSaveOnLoop, Config.BotLoopTaskLimit))
            {
                Log.LogInformation("# {0}...", curTask);
                switch (curTask)
                {
                case DetectContactsFollowBackStr:
                    DetectContactsFollowBack();
                    break;

                case DetectExploredStr:
                    DetectExplored();
                    break;

                case DetectExploredContactsOnlyStr:
                    DetectExplored(true, false);
                    break;

                case DetectExploredPhotosOnlyStr:
                    DetectExplored(false, true);
                    break;

                case SearchKeywordsStr:
                    SearchKeywords();
                    break;

                case SearchKeywordsContactsOnlyStr:
                    SearchKeywords(true, false);
                    break;

                case SearchKeywordsPhotosOnlyStr:
                    SearchKeywords(false, true);
                    break;

                case DoContactsFollowStr:
                    DoContactsFollow();
                    break;

                case DoContactsFavStr:
                    DoContactsFav();
                    break;

                case DoPhotosFavStr:
                    DoPhotosFav();
                    break;

                case DetectContactsUnfollowBackStr:
                    DetectContactsUnfollowBack();
                    break;

                case DoContactsUnfollowStr:
                    DoContactsUnfollow();
                    break;

                case DetectRecentContactPhotosStr:
                    DetectRecentContactPhotos();
                    break;

                case SaveStr:
                    SaveData();
                    break;

                case PauseStr:
                case WaitStr:
                    Task.Delay(PseudoRand.Next(Config.BotWaitTaskMinWaitMs, Config.BotWaitTaskMaxWaitMs))
                    .Wait();
                    break;

                default:
                    Log.LogError("Unknown BotTask : {0}", curTask);
                    break;
                }
            }
            Log.LogInformation("## ENDED OK");
        }