stefan2200 / TWB

Python based bot for Tribal Wars
GNU General Public License v3.0
104 stars 55 forks source link

Question #34

Closed leopoliveira closed 2 years ago

leopoliveira commented 2 years ago

I am trying to undestand how the bot works and I have a question:

Some other bots use Selenium or something like that to make actions.

But I didn't see anything like that on this bot. How can you make actions on game without these tools ?

stefan2200 commented 2 years ago

Well pretty simple, Selenium emulates a browser, this bot only emulates the requests sent by the browser :)

leopoliveira commented 2 years ago

That is awesome. Emulating requests is better than emulate a browser, like selenium does?

I started to read your code, especially where you send attacks and can't find where you send the request :S.

stefan2200 commented 2 years ago

Well better is a bold statement but easier, yes. Using direct requests allowed me to create a generic wrapper for all requests to TW. This, in relation to Selenium, is a lot harder to detect because the browser session remains valid.

All requests are sent from this file core/request.py. It uses the Python requests library to "fake" the browser's requests.

leopoliveira commented 2 years ago

Got it. I think that the only issue you have now is about captcha, isn't it ? This situation require manually action to let bot keeping its job. This is some feature that can be done or it is impossible throght requests?

stefan2200 commented 2 years ago

Well that is not an issue of the bot. The only proper way to solve the captcha issue is to pay someone to solve them for you (a lot of commercial bots do it this way) but that totally defeats the purpose of open source :)

Right now, the only proper way to deal with them is just check-in every hour or enable the remote logger so you can check if the bot runs into a captcha using a database/web interface. Or just limit the amount of actions because from what I've observed, the amount of captchas is based on hours of activity + amount of actions.

leopoliveira commented 2 years ago

You are right, Thank you for the answers.