Skip to content
This repository has been archived by the owner on Dec 24, 2022. It is now read-only.

Why is the bot not working? #3

Open
sunshinecool opened this issue Dec 8, 2015 · 20 comments
Open

Why is the bot not working? #3

sunshinecool opened this issue Dec 8, 2015 · 20 comments

Comments

@sunshinecool
Copy link

Hey jos,
Can you tell me for what reasons this bot is not working? I would like to contribute and get it working. What updates did the grepo do that this bot stopped working?

@josdemmers
Copy link
Owner

The most problems are caused by the updateGameData response (See updateGameDataResponse in Controller.cs).

Some important data is no longer available in the response send by Grepolis. Like a list of all your towns with some basic information for each town, including a town id which is required for all further http requests.
Luckily the server response contains a number of collections that contain the town ids as well so you can use that to create a list of towns.

I suggest to debug the updateGameDataResponse method to check the missing data. Also saving the response from updateGameData in text file helps a lot to get familiar with the available data. The data of the response uses the json format.

Furthermore, there is one new problem since this week. Grepolis changed the login page so the bot is not able to login at the moment. The related methods for this are loginP1(), loginP2(), and loginP3() in GrepolisBot2.cs

There are probably more issues but if you solve those two most features will work again I think.

@josdemmers
Copy link
Owner

For loginP2() use the following

HtmlElement l_Name = webBrowserGrepo.Document.GetElementById("login_userid");
l_Name.Focus();
l_Name.InnerText = l_Settings.GenUserName;
HtmlElement l_Password = webBrowserGrepo.Document.GetElementById("login_password");
l_Password.Focus();
l_Password.InnerText = l_Settings.GenPassword;

HtmlElement l_Button = webBrowserGrepo.Document.GetElementById("login_Login");
l_Button.Focus();
l_Button.InvokeMember("click");

For loginP3() check the http request. The post data now only contains the world you want to login to. In additon the url is changed. All server are using world 0 to login. So for example:

[before] https://en80.grepolis.com/start?action=login_to_game_world
[after] https://en0.grepolis.com/start?action=login_to_game_world

@BrandonWill
Copy link

Have you tested the loginP2 code? The new login system is written in AngularJS and it doesn't work the same way.

Here's how I managed to get mine working: BrandonWill/GrepolisBot@674a78b#diff-73d69ccffc12ac7298de6126c5c79befR165

@josdemmers
Copy link
Owner

Yes I did the above method works fine. The important part of the change is to focus on the html elements first otherwise your input is not registered by javascript code. The login page uses a few javacript functions that are called when you click (gain focus) on the username/password fields.
(bindOnFocusEvent and bindOnBlurEvent)

Good to see you found a working alternative as well.

@BrandonWill
Copy link

Hmm, interesting. When I attempted to grab the focus in chrome and even my webview browser neither would become focused. However, they become focused in Internet Explorer.

Another thing that occured is this error: DOMException: Failed to set the 'innerText' property on 'HTMLElement': The 'input' element does not support text insertion.

Ah the fun of different browser interactions!

@josdemmers
Copy link
Owner

Yes each browser has it advantages/disadvantages, most of the time though it is internet explorer that is having problems :)
I also did not have any issues using the 'innerText' property in IE.

@shajan-a
Copy link

shajan-a commented Feb 3, 2016

did any of you guys fixed the issue

@shajan-a
Copy link

shajan-a commented Feb 3, 2016

there is an exception got , index is out of range should be non negative and less than collection

@RobinReinecke
Copy link

I dont know if anyone cares anymore. But i fixed the login problem and now discovered, that the updateGameData request getting less usefull and contains less information. You have to use the "frontend_bridge" requests to get all needed information.

@josdemmers
Copy link
Owner

Thanks for the heads up. Should be useful for others that are interested in the project.

@RobinReinecke
Copy link

Hey wow. Never expected someone read my post :D do you still care about this project or is it "dead" for you?

@josdemmers
Copy link
Owner

I still do get notifications when something happens on github :)
But yes, I'm no longer working on this project. It's just here for others to use and learn from.

@RobinReinecke
Copy link

Okay.. thats sad, because i like your project. I started reworking the hole bot but its a lot to do.. Some help would be so nice :D
Can I ask you a fun question? How many times you got banned while working on this?:D

@josdemmers
Copy link
Owner

Not that much, maybe 3 times in total near the end. There weren't any detection mechanisms when I started this project.
But good luck with the project!

@RobinReinecke
Copy link

Thank you! Can I ask you some questions about your code :)? A big questionmark came up when I saw the "stateManager". Can you explain it to me?

@josdemmers
Copy link
Owner

Sure, no problem. In short, it manages the state of the program.
To be more precise, the bot uses a timer and on each tick it executes an action. Depending on the state the bot is currently in a specific action is executed. The stateManager is responsible to execute the correct action.

@RobinReinecke
Copy link

This is a nice solution :D i cant even replicate this with all the events and stateManager1 and 2 and so on...
I have the idee of a "requestQueue" which gets emptied with random delay.

@josdemmers
Copy link
Owner

As a start it might be better to use stateManager1 only. The 2nd and 3th do exactly the same but in a different order. The bot switches between the different stateManagers to make the requests to the server more random (to prevent detection).

If you first focus on just 1 stateManager to get the bot working again you can start working on randomizing requests after that.

@RobinReinecke
Copy link

Yeah thats a good idea. One last question for today : after "startbotfirstrun" which method calls all the requests in an inverall? is it just a simple timer or your custom jdTimer? what is this jdTimer class for by the way?

@josdemmers
Copy link
Owner

josdemmers commented Feb 15, 2017

startbotFirstRun() starts a number of timers, the one you are looking for is the m_RefreshTimer.
The jdTimer class adds some extra functionality around the standard timer class.

Check the method initEventHandlers() for the event handler of m_RefreshTimer.

For further questions you can use ***, then we don't bother the other users with mail notifications.

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

No branches or pull requests

5 participants