Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bans and Captcha #41

Open
realstrings opened this issue Feb 26, 2023 · 2 comments
Open

Bans and Captcha #41

realstrings opened this issue Feb 26, 2023 · 2 comments

Comments

@realstrings
Copy link

realstrings commented Feb 26, 2023

Hey, i have been getting few temp bans using this bot, am using only features that were not marked as ban risk.

Also i have been getting a lot of captchas so i figured why not to use 2captcha its cheap as it gets.

here is some code

            if 'data-bot-protect="forced"' in res.text:
                if not self.captcha_solve:
                    self.logger.warning("Bot protection hit! cannot continue")
                    self.reporter.report(0, "TWB_RECAPTCHA", "Stopping bot, press any key once captcha has been solved")
                    input("Press any key...")
                    return self.get_url(url, headers)
                else:
                    self.logger.warning("Bot protection hit! Trying to solve captcha")
                    solver = TwoCaptcha(self.twocaptcha_key)
                    result = solver.hcaptcha(sitekey='b413369f-bb15-4015-bacd-dd180021827c',url=self.endpoint)
                    xsrf = re.search('"csrf":"(.+?)"', res.text)
                    vill_id = re.search('"village":{"id":(.+?),', res.text)
                    request_data = {"response": result['code'],"h": xsrf.group(1)}
                    response = self.web.post(url=self.endpoint+"game.php?village="+vill_id.group(1)+"&screen=botcheck&ajaxaction=verify",headers=headers,data=request_data)
                    print(response.text)
                    if 'true' in response.text:
                        self.logger.warning("Captcha solved, trying last action again")
                        return self.get_url(url, headers)
                    else:
                        self.reporter.report(0, "TWB_RECAPTCHA", "Captcha failed. Stopping bot, press any key once captcha has been solved")
                        input("Press any key after you solved captcha...")
                        return self.get_url(url, headers)

            return res
        except Exception as e:

i sadly cant create pull request as i dont quite understand few things from config and dont have the time to go tru it.

https://pypi.org/project/2captcha-python/

@realstrings
Copy link
Author

realstrings commented Mar 4, 2023

Bans come from either farming or being on the same session for too long

@Legion-81
Copy link

hmm never had any problems yet with captcha ever using cookie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants