Git Product home page Git Product logo

twb's Introduction

Hi

I'm Stefan, A security enthusiast and Python developer.

  • 🔭 Part of SecuraBV
  • Likes web application testing, Android security and Python development
  • Python, PHP, [A-Z]+SQL, .NET, c++, Go, Java, Perl, anything *nix related and basic web development (bootstrap yayy)
  • Probably forgot a lot in the list above
  • 🌱 I’m currently learning Dart and React
  • 📫 Feel free to hmu on Discord: kipjns or connect on LinkedIn
  • ⚡ Fun fact: I probably have more birds than you do

Enjoy your day!

twb's People

Contributors

acroticguy avatar ait-olpe avatar davidakachaos avatar delyro avatar linovlo avatar maartenpeels avatar oscyp33 avatar pizzalord22 avatar stefan2200 avatar suchencjusz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twb's Issues

Snob recrutation

Hi
reservation resources and recrutation of snob seems to not working. I've set needed snobs to 2 and enabled prioritize snob but nothing happend.

2022-01-07 09:34:56 - Requests - DEBUG - GET https://pl171.plemiona.pl/game.php?village=******&screen=snob [200] 2022-01-07 09:35:19 - Requests - DEBUG - GET https://pl171.plemiona.pl/game.php?village=******&screen=snob&action=train&h=2b762ca7 [200] 2022-01-07 09:35:19 - Recruitment: **** - INFO - barracks still busy for 1:24:43
there is run log

Webmanager not work

Hello Stefan, first I would like to thank you for the work you did on this BOT, it was very good, I tried to make the webmanager work, but it doesn’t execute, it just opens and closes very fast, which may be I don’t understand much about phyton.
Thanks!!!

ready-made voids

Cool bot. I would like to add to project a few voids parsing data from:
screen=overview_villages&mode=combined
screen=overview_villages&mode=prod
screen=overview_villages&mode=trader
screen=overview_villages&mode=commands
screen=overview_villages&mode=incomings

I have it written in c # if that's not a problem?

Villages not added to the config

Hi,
I have an issue because villages are not being added to the config - I'm just getting:
2022-03-28 22:32:50 - Requests - DEBUG - GET https://pl175.plemiona.pl/game.php?screen=overview [200]
2022-03-28 22:32:57 - Requests - DEBUG - GET https://pl175.plemiona.pl/game.php?screen=overview_villages [200]
2022-03-28 22:32:57 - FarmManager - INFO - Villages: 0
2022-03-28 22:32:57 - FarmManager - INFO - Reports: 0
2022-03-28 22:32:57 - FarmManager - INFO - Farms: 0
2022-03-28 22:32:57 - FarmManager - INFO - Total loot: {'wood': 0, 'iron': 0, 'stone': 0}
Dead for 4.566667.2 minutes (next run at: 22:37:31.998917)

I looked around but to be honest I feel a little bit stuck. Do you have any ideas what could've gone wrong?

German Server

Hey is it possible to use the bot on a German server?

Cant load anything

image

Even if I had the village manually on config file, it will show (1 village) but dont load anything else.

Stupid question

Hi,

Maybe a stupid question but where/how do I use the command from "Install the requirements (pip install -r requirements.txt)"? I never did anything with python.

Thanks <3

Forced peace time question

Great job with the script,works well.
2 issues that i have :)
What is the correct format for peace time?Anything ive tried ends in breaking the code
"forced_peace_times": []
My other issue is the web interface,always shows always inactive,even when bot is running,but i can leave with that!

Does work

I turn on the bot and the webserver but it doesn't do anything in the game

Work on Linux

Traceback (most recent call last):
File "twb.py", line 12, in
import coloredlogs
ImportError: No module named coloredlogs

Already install...
pip install coloredlogs

Cannot do more

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\sivet\OneDrive\Pulpit\TWB-master> python twb.py
2022-03-11 15:59:13 - Requests - DEBUG - GET https://pl175.plemiona.pl/game.php?screen=overview [200]
2022-03-11 15:59:13 - Requests - DEBUG - Set CSRF token
2022-03-11 15:59:13 - Requests - WARNING - Current session cache not valid
Enter browser cookie string> https://pl175.plemiona.pl/game.php?village=17376&screen=overview
2022-03-11 15:59:52 - Requests - INFO - Game Endpoint: https://pl175.plemiona.pl/game.php
2022-03-11 16:00:00 - Requests - DEBUG - GET https://pl175.plemiona.pl/game.php?screen=overview_villages [200]
2022-03-11 16:00:00 - Requests - DEBUG - Set CSRF token
2022-03-11 16:00:00 - FarmManager - INFO - Villages: 0
2022-03-11 16:00:00 - FarmManager - INFO - Reports: 0
2022-03-11 16:00:00 - FarmManager - INFO - Farms: 0
2022-03-11 16:00:00 - FarmManager - INFO - Total loot: {'wood': 0, 'iron': 0, 'stone': 0}
Dead for 3.666667.2 minutes (next run at: 16:03:40.255302)
2022-03-11 16:03:44 - Requests - DEBUG - GET https://pl175.plemiona.pl/game.php?screen=overview_villages [200]
2022-03-11 16:03:44 - Requests - DEBUG - Set CSRF token
2022-03-11 16:03:44 - FarmManager - INFO - Villages: 0
2022-03-11 16:03:44 - FarmManager - INFO - Reports: 0
2022-03-11 16:03:44 - FarmManager - INFO - Farms: 0
2022-03-11 16:03:44 - FarmManager - INFO - Total loot: {'wood': 0, 'iron': 0, 'stone': 0}
Dead for 4.683333.2 minutes (next run at: 16:08:25.898313)
2022-03-11 16:08:31 - Requests - DEBUG - GET https://pl175.plemiona.pl/game.php?screen=overview_villages [200]
2022-03-11 16:08:31 - Requests - DEBUG - Set CSRF token
2022-03-11 16:08:31 - FarmManager - INFO - Villages: 0
2022-03-11 16:08:31 - FarmManager - INFO - Reports: 0
2022-03-11 16:08:31 - FarmManager - INFO - Farms: 0
2022-03-11 16:08:31 - FarmManager - INFO - Total loot: {'wood': 0, 'iron': 0, 'stone': 0}
Dead for 4.500000.2 minutes (next run at: 16:13:01.560954)

insufficient resources

my bot does not build anything. it says not building anything because insufficient resources even though I have enough resources.

Farm.

Hi, great bot, but farm isn't work... Maybe only if I had send farm manually, but it keeps sending 20 spears alone to the vill in reportd, even if lost one or two in process because lucky it send again same num.

What does "Max_lookahead" mean?

Hi,
I don't understand, what Max_lookahead actually means. When I have Max_queued_items at 5, what value should I use for Max_lookahead?

Thanks!

About resource reallocation

Hello, I have been using the bot and I really liked it. I would like to know if you intend to add a system for relocating resources between the villages that the player owns. I realized that in terms of general functionality, this is the only thing that is "missing" to make gameplay better in the mid/late game.

Attack planner

Hi, great work you have done there, thanks for that!

Are there any plans to release the Attack planner? :)

Best

prioritizing certain village to farm?| attacking players villages

Hi stefan, thanks for your great bot
how can i prioritze certain villages to farm? i tried to put the villages id in "additional_farms": ["667","986"] like that but the bot didn't really start to attack them
and if i magaged to use the additional farms method will it work on players villages id?
is there a method to make the bot save resources for unit upgrade instade of a building?

Question

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 ?

DOESNT WORK

I DONT UNDERSTEND HOW TO ACTIVITE THE BOT

Scavenging/Gathering

Hey,

I have another question: How exactly does the scavenging work? Because when 3 of 4 are not in use and I have around 2000 troops around it does not send any troops to scavenge, but tells me this in the console:

log

and what does the "gather_selection" in my config file do?

Thanks in advance!

Bans and Captcha

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/

Manage Buildings

Hello, stefan, i'm new in pyhton world and i'm trying to get this bot to work.

I already logged in and it found the village normally. But it keeps showing this:

Dead for 4.983333.2 minutes (next run at: 07:43:27.735093)
2022-08-03 07:38:28 - Requests - DEBUG - GET https://br112.tribalwars.com.br/game.php?screen=overview_villages [200]
2022-08-03 07:38:28 - FarmManager - INFO - Villages: 1
2022-08-03 07:38:28 - FarmManager - INFO - Reports: 0
2022-08-03 07:38:28 - FarmManager - INFO - Farms: 0
2022-08-03 07:38:28 - FarmManager - INFO - Total loot: {'wood': 0, 'iron': 0, 'stone': 0}

I already disabled the farm and enable the building management, but it wont build anything. What should I do?

farm system is not working

Hello Stefan, first I would like to thank you for the work you did on this BOT, but there is a problem. I see the request of attacks in the console but they don't do much in the actual game
I belive that is a cache problem in the cookies. that is because I copied the post request send and used in postman.

and the response was: {"error":"A sua sess\u00e3o expirou. Por favor, acesse novamente."}

Auto User-Agent Fetch Issue If 2 Browser Opened

You already explained in readme to edit User-agent on core/request.py. It is not a bug. I am using firefox mostly and chrome sometime. If both browser opened and in both browser tribal wars is opened, user-agent will be parsed wrong. Just FYI.

I ll close after sometime

Scout

Hey, what do I have to set exactly so that the bot other players spy?
He never says enough Spy.

Only BB are attacked.

Changing amount of light cavalaray for farm

Hello Stafan,

Great bot, but could you point where can i change amount of LC for farm? it is sending 100 LC for 100 point barbarian farm. I would like to change it to 3-5. Where is config for that? Thanks in advance!

Error during attack

Log shows

2022-01-03 19:56:17 - Reports - DEBUG - This is the newest? 2022-01-03 17:57:01
I crashed :(   cannot unpack non-iterable NoneType object
Traceback (most recent call last):
  File "twb.py", line 380, in <module>
    t.start()
  File "twb.py", line 374, in start
    self.run()
  File "twb.py", line 315, in run
    vil.run(config=config, first_run=vnum == 1)
  File "/home/main/twb/game/village.py", line 441, in run
    self.attack.run()
  File "/home/main/twb/game/attack.py", line 63, in run
    out_res = self.send_farm(target, template)
  File "/home/main/twb/game/attack.py", line 80, in send_farm
    cached = self.can_attack(vid=target["id"], clear=False)
  File "/home/main/twb/game/attack.py", line 280, in can_attack
    res_left, res = self.repman.has_resources_left(vid)
TypeError: cannot unpack non-iterable NoneType object

After 3 times, scripts is stopping

Error About Browser

What is that error? How can I start this bot?
"No custom user agent was supplied, this will likely get you banned.Please set the bot -> user_agent parameter to your browsers one. Just google what is my user agent"

Support messes up troop count

I realized that when I have support on my village, the scavenging gets all weird. After some digging some more, I found out that the program "assumes" every unit that doesn't come from my village IS my village's troop count. Here's an example:

I have received 1 spear and 1 sword.

I have 500 spear, 200 sword, 100 axe.

The program will think I have 1 spear, 1 sword, 100 axe (It was my first assumption, confirmed with debug logs).

I haven't yet toyed with the extractors.py file, but I intend to figure out a fix. A simple idea would be to have the bot count. On the "units_home" table, the 2nd row corresponds to units "From this village", and the units count starts from the 4th column.

I'll update this issue once I have more information on the problem. If I do end up fixing it fast, I'll simply request a PR

FileNotFoundError

FileNotFoundError: [WinError 3] System could not find path '../cache\reports'. This issue just popped in when I tried to run the server.py, and opened the "http://127.0.0.1:5000/" site. I don't really know why. I also tried pasting the folder in diff locations to see if that would help, like python dictionary, the TWB main dictionary etc. Same thing happened when I tried to run the server from "webmanager". It gave me a screaming error, that there is no file called "webmanager" (lol), but I managed to fix this just by moving over the server.py to main dir.

Now I tried just removing the "reports" from the code overall, that just ended up giving me an error over "villages" in cache, that it could not find that file too. There seems to be a problem with finding the "cache" files, or I'm just retarded and can't see a easy solution

Not doing anything - web view shows 0 vilages

Hey there, so I got this up and running on a remote VPS and on localhost (WSL), to test it's not caused by my server, did not run simultaneously.

The problem I got is that it even tells me it found my villages in the bot output, but then does nothing.
The web server also shows nothing when I click on village configuration.

Editing the config through web does edit the config in the bot.

Playing on CS server

Any help would be appreciated.

Scavenging units

Is there a way to prevent some units from scavenging? Or locking maximum units on scaveneging?

Maybe a User-Problem.

hey, and sorry for this Noob-Question, but how can i start thenew website with the Link http://127.0.0.1:5000/ This link is not working in my Browser (Chrome). maybe i just didnt understand something.
The bot is to use in the Virtual Studio Programm, so did i use him.
again, sorry for the issue, maybe it will be very easy to answer it.
Also i cant see if the bot is realy working, just like in an issue that was closed is there only the output of the Troop manager.
And the Queue isnt growing.

thank you very much!
Levy

Issues after restarting

Traceback (most recent call last):
File "C:\Users\mee\OneDrive\Pulpit\TWB-master\twb.py", line 374, in
t.start()
File "C:\Users\mee\OneDrive\Pulpit\TWB-master\twb.py", line 368, in start
self.run()
File "C:\Users\mee\OneDrive\Pulpit\TWB-master\twb.py", line 215, in run
config = self.config()
File "C:\Users\mee\OneDrive\Pulpit\TWB-master\twb.py", line 118, in config
config = json.load(f, object_pairs_hook=collections.OrderedDict)
File "C:\Users\mee\AppData\Local\Programs\Python\Python310\lib\json_init_.py", line 293, in load
return loads(fp.read(),
File "C:\Users\mee\AppData\Local\Programs\Python\Python310\lib\json_init_.py", line 359, in loads
return cls(**kw).decode(s)
File "C:\Users\mee\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\mee\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 109 column 5 (char 2984)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\mee\OneDrive\Pulpit\TWB-master\twb.py", line 376, in
t.wrapper.reporter.report(0, "TWB_EXCEPTION", str(e))
AttributeError: 'NoneType' object has no attribute 'reporter'

Obtain Cookie automatically?

I am wondering if I can obtain the cookie automatically once it expires. Will make a pull request when its done and implemented. This bot works very well.

feature: force research

I think there should be force research option, forcing gathering resources for next research instead of spending them on buildings or troops. This would be very helpful when playing offensive, since we can research light cavalry asap.

Quest rewards

Seems to be broken for now in two places.

I managed to make it "almost working"

        get_rewards = re.search(r'RewardSystem\.setRewards\((\[\{.+?\}\]),', res) 
        ->
        get_rewards = re.search(r'RewardSystem\.setRewards\([\n\r\s]+(\[\{.+?\}\]),', res)

2nd broken part is everything that refers to self.resman.actual - which is being used to check if storage can hold the rewards amount. With commenting out checking for storage ( for t_resource in reward["reward"]: ) and self.logger.info("Got quest reward: %s" % str(reward)) part, everything else seems to work.

Maybe you can fix it easily. (it says something like self.resman.actual is not defined).

I can't provide a valid cookie string.

When I run 'twb.py' it prompts me for a browser cookie string, but when I go to the browser, copy the string, paste it and press Enter, it doesn't return anything.

2023-01-16 14:26:20 - Requests - DEBUG - GET https://br117.tribalwars.com.br/game.php?village=112119&screen=overview [200]
2023-01-16 14:26:20 - Requests - DEBUG - Set CSRF token
2023-01-16 14:26:20 - Requests - WARNING - Current session cache not valid
Enter browser cookie string>

after this I dont have return

Farm with loses

Can you make something that will allow to skip attacking barbs with losses? Either array like for an "additional_farms": [], but doing opposite or skip attacking barb with losses for like 3 days?

Bot does not queue buildings/recruit troops...

Hi,

I just started using your bot and I have to say that I am really impressed by your work!
I started a new world to test it out for the first time and the problem now is that it does not seem to do anything. The only console log I get is:
log
So in my understanding the only thing working is the FarmManager, which obviously doesn't do much at the start of a new world...
I also checked the configurations if something may be set to false, but as the picture shows,
building
e.g. the building manager is set to true (that is also the case in my config.py).

I guess there is just a small change to be done that would fix this...

Thanks in advance for the answer and above all for the tremendious work you did!

Greetings from Austria,

Konstantin

Status: Inactive

the BOT status just returns me inactive, can you tell me what I'm doing wrong so I can activate the bot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.