hldh214 / lok_bot

Yet another League of Kingdoms farming bot
MIT License
39 stars 37 forks source link

Can you help me about error: not_online? #24

Closed anhntsi closed 2 years ago

anhntsi commented 2 years ago

Hi,

The project is great. I referenced it a lot to write my own bot. I have problem about API: api/field/march/start alway response error: not_online.

Do you have suggestion about it? This is flow I use to farming:

  1. Get kingdom info: api/kingdom/enter
  2. Call api/chat/logs and api/auth/setDeviceInfo
  3. Using socket API to query field object
  4. Get field info: api/field/march/info
  5. Start farm: api/field/march/start
hldh214 commented 2 years ago

Based on my experience, you need to connect to both kingdoms and fields websockets to make it work.

{
    "api": "https://api-lok-live.leagueofkingdoms.com/api",
    "kingdoms": ["https://sock-lok-live.leagueofkingdoms.com/socket.io/"],  // required
    "fields": ["https://socf-lok-live.leagueofkingdoms.com/socket.io/"],  // required
    "chats": ["https://socc-lok-live.leagueofkingdoms.com/socket.io/"]  // optional
}
anhntsi commented 2 years ago

Thank. I will try using kingdoms websocket.

anhntsi commented 2 years ago

@hldh214 sorry to bother you, i've been investigating for a few days but it not work. I have emit /field/enter and /kingdom/enter when start bot but call API api/field/march/start still error: not_online.

If I open play.leagueofkingdoms.com that api call ok. So I think I sent something missing. I also tried debugging networking and what I send and play.leagueofkingdoms.com send are the same. I don't know where the problem? :(

Can you suggest me? Thanks.

hldh214 commented 2 years ago

Try to make these requests before your main logic start

https://github.com/hldh214/lok_bot/blob/e8b4b11ffc85aad61bcd1d0373e8adf7acc29cfb/lokbot/farmer.py#L919-L930

anhntsi commented 2 years ago

Thank, i will try to call it.

anhntsi commented 2 years ago

@hldh214 Thanks, it work.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.