Ikabot-Collective / ikabot

A Python-based bot designed for automating tasks in the game Ikariam
https://discord.com/invite/3hyxPRj
MIT License
89 stars 62 forks source link

Bugfix for autoconvert crew strength #230

Closed Rakkuzan closed 5 months ago

Rakkuzan commented 5 months ago

Seems like the request changed since this function was written. It is POST request now with 2 more parameters - "actionRequest" and "ajax"

susikaman commented 5 months ago

This function has been reported to not function properly for as long as I can remember lol. No-one has bothered to fix it though, so this is an excellent PR!

ikagod commented 5 months ago

I just tested sending this request without ajax=1 and actionRequest on my browser and it seems like it was working fine. capturePoints was found in the resulting HTML.

Are you sure there is certainly even an issue with the current autoconvert crew strength code? And does this PR certainly fix it? I don't see how adding actionRequest and ajax parameters will help.

Rakkuzan commented 5 months ago

I just tested sending this request without ajax=1 and actionRequest on my browser and it seems like it was working fine. capturePoints was found in the resulting HTML.

Are you sure there is certainly even an issue with the current autoconvert crew strength code? And does this PR certainly fix it? I don't see how adding actionRequest and ajax parameters will help.

Before this commit i got following error every time I tried to use autoconvert. Cause: Traceback (most recent call last): File "/ikabot/ikabot/function/autoPirate.py", line 205, in autoPirate convertCapturePoints(session, piracyCities, convertPerMission) File "/ikabot/ikabot/function/autoPirate.py", line 288, in convertCapturePoints capturePoints = int(rta.group(1)) ^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'group'

After this commit the bot autoconverted the points for me. When I try without ajax=1 and actionRequest on my browser I get "access denied" not sure why we got diffrent results.

Edit: Tested it now with both chrome and firefox. ajax=1 is required to get response which contains capturePoints. actionRequest is not required however when I looked at the network traffic when clicking the "crew strength" tab this parameter also shows up so I think it's best to leave it.

ikagod commented 5 months ago

Alright, I suppose having the extra parameters won't hurt, although I am still skeptical about this actually fixing anything.

Rakkuzan commented 5 months ago

Alright, I suppose having the extra parameters won't hurt, although I am still skeptical about this actually fixing anything.

It's easy to test. You can try it yourself if you don't believe. Set the head before this commit, start pirating and enable auto-convert crew strength. You should get telegram message with an error immidiately and crew conversion won't happen. Then try it again with code that includes this commit.