public void UnsubscribeToChannel(int count)
        {
            var signInUrl          = "https://accounts.google.com/signin/v2/identifier?service=youtube&uilel=3&passive=true&continue=https://www.youtube.com/signin?action_handle_signin=true&app=desktop&hl=en&next=%2F&hl=en&flowName=GlifWebSignIn&flowEntry=ServiceLogin";
            var subscribedAccounts = _context.Accounts.Where(i => i.SubscribedChannels.Where(x => x.ChannelId == _channel.Id).Any()).Take(count);

            OnProcessing?.Invoke($"Starting unsubscription process", new EventArgs());
            int unsubscribedAccountsCount = 0;
        }
Пример #2
0
        private async void btn_Save_Click(object sender, RoutedEventArgs e)
        {
            OnProcessing?.Invoke();
            await Task.Delay(5000);

            await _db.SaveChangesAsync();

            OnProcessed?.Invoke(_mission, _isNew);
        }
Пример #3
0
        public CustomAction WaitNewGambling(IEnumerator <CustomAction> customActions)
        {
            try
            {
                while (true)
                {
                    if (ControllerCancelToken.IsCancellationRequested)
                    {
                        ControllerCancelToken = ControllerCancelToken.Reset();
                        return(null);
                    }

                    var picBuffer = ((ITakesScreenshot)Instance).GetScreenshot().AsByteArray;

                    var bitmap_Cut = PictureHelper.ProcessImage(_trackingArea, picBuffer);
                    //bitmap_Cut.Save($@"C:\Users\NGPONG\Desktop\SmartTools\SmartTools\SmartTools\bin\Release\image\image_{(index++).ToString()}.png");
                    var page      = Tesseract.Process(bitmap_Cut, PageSegMode.SingleBlock);
                    var readByPic = page.GetText();

                    // Dispose Unmanaged variable because of the calling recursive functions
                    Array.Clear(picBuffer, 0, picBuffer.Length);
                    page.Dispose();

                    if (Regex.IsMatch(readByPic, "开局"))
                    {
                        double balance;
                        var    response = Config.GetBalanceAsync();
                        var    isMatch  = double.TryParse(response.Result, out balance); // Return HTML code maybe.
                        if (isMatch)
                        {
                            OnProcessing.Invoke(balance.ToString()); // Update GUI balance display.
                        }
                        // To call back function.
                        break;
                    }

                    GC.Collect();
                }

                return(customActions.MoveNext <CustomAction>());
            }
            catch (Exception e)
            {
                LogHelper.Error(e);
                return(null);
            }
        }
        public override void Execute()
        {
            if (_tryingToUnload != null && UnloadProduce(_tryingToUnload))
            {
                SuccessfullyUnloaded();
            }

            if (IsProcessing)
            {
                bool finished = JustFinishedProcess();
                OnProcessing?.Invoke(this);

                if (finished)
                {
                    _tryingToUnload = new ItemStack(_processing.ItemProduced.Item, _processing.ItemProduced.Count);
                    if (UnloadProduce(_tryingToUnload))
                    {
                        SuccessfullyUnloaded();
                    }
                }
            }
        }
        public bool VerifyAccount()
        {
            var isVerifiedAccount = false;

            _driver.Navigate().GoToUrl("https://accounts.google.com/login");

            WaitForReady(By.Id("identifierNext"));
            _driver.FindElement(By.Id("identifierId")).SendKeys(_account.Email);
            _driver.FindElement(By.Id("identifierNext")).Click();
            Thread.Sleep(1500);

            if (IsElementPresent(By.XPath("//div[@aria-live='assertive' and @aria-atomic='true']/div")))
            {
                var errorMsg = $"Unregistered email, couldn't find Google account {_account.Email}";
                OnProcessing?.Invoke(errorMsg, new EventArgs());
                return(false);
            }

            WaitForReady(By.Id("passwordNext"));
            _driver.FindElement(By.Name("password")).SendKeys(_account.Password);
            _driver.FindElement(By.Id("passwordNext")).Click();
            Thread.Sleep(1500);

            if (IsElementPresent(By.XPath("//div[@aria-live='assertive']/div[2]")))
            {
                var errorMsg = $"Wrong password for account {_account.Email}";
                OnProcessing?.Invoke(errorMsg, new EventArgs());
                return(false);
            }
            else
            {
                isVerifiedAccount = true;
            }

            return(isVerifiedAccount);
        }
        public void SubscribeToChannel(int count)
        {
            var signInUrl            = "https://accounts.google.com/signin/v2/identifier?service=youtube&uilel=3&passive=true&continue=https://www.youtube.com/signin?action_handle_signin=true&app=desktop&hl=en&next=%2F&hl=en&flowName=GlifWebSignIn&flowEntry=ServiceLogin";
            var unsubscribedAccounts = _context.Accounts.Where(i => !i.SubscribedChannels.Where(x => x.ChannelId == _channel.Id).Any()).Take(count);

            OnProcessing?.Invoke($"Starting subscription process", new EventArgs());
            int subscribedAccountsCount = 0;

            foreach (var unsubscribedAccount in unsubscribedAccounts)
            {
                OnProcessing?.Invoke($"Trying to login account {unsubscribedAccount.Email}", new EventArgs());

                Thread.Sleep(500);
                _driver.Navigate().GoToUrl(signInUrl);
                WaitForReady(By.Id("identifierNext"));
                _driver.FindElement(By.Id("identifierId")).SendKeys(unsubscribedAccount.Email);
                _driver.FindElement(By.Id("identifierNext")).Click();
                Thread.Sleep(1500);

                if (IsElementPresent(By.XPath("//div[@aria-live='assertive' and @aria-atomic='true']/div")))
                {
                    var errorMsg = $"Unregistered email, couldn't find Google account {unsubscribedAccount.Email}";
                    OnProcessing?.Invoke(errorMsg, new EventArgs());
                    continue;
                    //throw new Exception(errorMsg);
                }

                WaitForReady(By.Id("passwordNext"));
                _driver.FindElement(By.Name("password")).SendKeys(unsubscribedAccount.Password);
                _driver.FindElement(By.Id("passwordNext")).Click();
                Thread.Sleep(1500);

                if (IsElementPresent(By.XPath("//div[@aria-live='assertive']/div[2]")))
                {
                    var errorMsg = $"Wrong password for account {unsubscribedAccount.Email}";
                    OnProcessing?.Invoke(errorMsg, new EventArgs());
                    continue;
                    //throw new Exception(errorMsg);
                }

                if (!unsubscribedAccount.IsVerified)
                {
                    unsubscribedAccount.IsVerified = true;
                }

                WaitForReady(By.Id("content"));

                if (IsElementPresent(By.Id("identity-prompt-confirm-button")))
                {
                    _driver.FindElement(By.Id("dont_ask_again")).Click();
                    Thread.Sleep(500);
                    _driver.FindElement(By.Id("identity-prompt-confirm-button")).Click();
                }

                _driver.Navigate().GoToUrl(_channel.Url);
                WaitForReady(By.Id("subscribe-button"));

                if (IsElementPresent(By.XPath("//*[@id='subscribe-button']/.//paper-button[@subscribed]")))
                {
                    OnProcessing?.Invoke($"Already subscribed account {unsubscribedAccount.Email}", new EventArgs());
                    continue;
                }
                else
                {
                    _driver.FindElement(By.Id("subscribe-button")).Click();
                    OnProcessing?.Invoke($"Successfully subscribed account {unsubscribedAccount.Email} #{++subscribedAccountsCount}", new EventArgs());
                    var channelAccount = new ChannelAccount()
                    {
                        AccountId = unsubscribedAccount.Id,
                        Account   = unsubscribedAccount,
                        ChannelId = _channel.Id,
                        Channel   = _channel
                    };
                    unsubscribedAccount.SubscribedChannels.Add(channelAccount);
                }

                _context.SaveChanges();
            }

            OnProcessing?.Invoke($"Finished subscription process", new EventArgs());
        }