Is it possible to know when someone hops online - Page 2 | API…

Is it possible to know when someone hops online

    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 4 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 00:51:44 - 03/02/24 (8 months ago)
    Post link copied to clipboard Copy post link

    Ixw [3143585]

    would you happen to know when the csv is updated? sorta just wanna have a quick hey grab if its out of date call

    Omanpx [1906686]

    I set the job to run at 15 and 3 tct, update takes up to an hour or so, should be around that time.
    awesome thanks
    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 4 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 14:30:33 - 06/02/24 (7 months ago)
    Post link copied to clipboard Copy post link
    Is the list using territory wars and raid as well? Haven't comved thru the list extensively but I have used it for updating caches for a map of names of people and factions
    • Omanpx [1906686]
    • Role: Civilian
    • Level: 100
    • Posts: 2,035
    • Karma: 11,949
    • Last Action: 2 hours
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 14:36:37 - 06/02/24 (7 months ago)
    Post link copied to clipboard Copy post link
    What do you mean? I went through all possible faction IDs and check up to 100 new IDs on each update to include any factions that have been created since the last update. The IDs are sequential, so it's easy to gather them all, just takes time and API keys.

    Toolbox - a collection of my tools and spreadsheets made for Torn.

    Guidebook - a collection of guides i made for Torn.

    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 4 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 20:58:56 - 06/02/24 (7 months ago)
    Post link copied to clipboard Copy post link
    Ahhh okay sweet so then my check for something is pointless lol, that is great so my initialization based off active factions should be all factions I think is there like a runtime error you get from the API if you go over 100 calls a minute or the daily number of calls? That will be fun to randomly run into later lol
    • Omanpx [1906686]
    • Role: Civilian
    • Level: 100
    • Posts: 2,035
    • Karma: 11,949
    • Last Action: 2 hours
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 21:04:15 - 06/02/24 (7 months ago)
    Post link copied to clipboard Copy post link
    There are several limits, most ties to api key owner. If you want to grab all factions, you might not be able to do it with a single key. My list includes all non-dead factions, you can filter them for activity, member count, rank etc. to trim that list even more.

    Toolbox - a collection of my tools and spreadsheets made for Torn.

    Guidebook - a collection of guides i made for Torn.

    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 4 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 14:04:13 - 10/02/24 (7 months ago)
    Post link copied to clipboard Copy post link
    does the api return something not equal to 200 when getting an error, because i occasionally have it return with a 200 status code but it still has an error in the json()[key]
    • DeKleineKobini [2114440]
    • Role: Committee
    • Level: 100
    • Posts: 3,751
    • Karma: 5,375
    • Last Action: 5 hours
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 14:34:28 - 10/02/24 (7 months ago)
    Post link copied to clipboard Copy post link

    Ixw [3143585]

    does the api return something not equal to 200 when getting an error, because i occasionally have it return with a 200 status code but it still has an error in the json()[key]
    Torn itself does not use HTTP status codes as part of the response. You might sometimes get something else like an HTTP 502, but then it's a CloudFlare response and not from Torn.
    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 4 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 17:07:21 - 10/02/24 (7 months ago)
    Post link copied to clipboard Copy post link
    hmmmm the most annoying part is that when the error happens it is v inconsistent so fixing it is rough, i guess ill add debug code for outputting values for when the error happens
    • Kwack [2190604]
    • Role: Civilian
    • Level: 15
    • Posts: 1,928
    • Karma: 2,906
    • Last Action: 49 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 08:52:39 - 11/02/24 (7 months ago)
    Post link copied to clipboard Copy post link

    Ixw [3143585]

    hmmmm the most annoying part is that when the error happens it is v inconsistent so fixing it is rough, i guess ill add debug code for outputting values for when the error happens
    How is it inconsistent? Just check if the json response includes the `error` key with a non-nullish value
    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 4 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 15:38:21 - 11/02/24 (7 months ago)
    Post link copied to clipboard Copy post link
    my saying it is inconsistent means that it rarely happens and the error is sort of vague when the error happens it is at the json decode level but for now its not a major issue but replicating the error is out of my hands sadly so im not sure exactly with the site returns
    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 4 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 00:23:08 - 12/02/24 (7 months ago)
    Post link copied to clipboard Copy post link
    the status code was indeed 503 so should be sorted now
    • Nexus [105937]
    • Role: Civilian
    • Level: 100
    • Posts: 4,698
    • Karma: 14,383
    • Last Action: 9 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 08:16:48 - 29/02/24 (7 months ago)
    Post link copied to clipboard Copy post link

    0xHemlock [2662912]

    This is probably better suited for the userscript forum, but yes I think you're on the right track. When I watch a faction I first find a way to grab the faction ID, usually through a query on the leader. Then send that ID to query for the faction and get the list of members. Then, very simply a periodic check on each member to get their information, which in this case is their status. Adding a factionmate's API key to the rotation helps avoid the API rate limits, and having all of this in a Google Sheet means other war leaders can reference the sheet and act accordingly. Of course, you can make a watchlist to send a ping/text/email if specific people come online, and that's up to you for how you want to set it up.

    Sounds like quite the useful project! Good luck!

    Ixw [3143585]

    so for that query on the faction leader, i had a way were i was using rankedwars then going thru all those to check each faction and then find the id for the leader or the faction, however its annoying to do that since its a nested loop, so i figure i could just cache the ids for factions and users to save time. tho i am curious if rankedwars shows all factions i think it just shows factions currently in a war
    I know this is ages ago now, but just for your own knowledge... there is actually nothing wrong per say with a nested loop as long as it is performant. Don't fall into the hole of "this is bad sometimes, so I should never use it". For a small script/application like a Discord Bot or something, as long as you're not querying a huge endpoint, the time performance of most functions/patterns isn't a huge issue.

    If there is a better way you can think of, then sure do it that way. But otherwise, don't let it block you actually making something. Can always be replaced later if your knowledge improves/you find a better way.

    That said, I wouldn't probably go deeper than one level with it, but you can also deserialize most of the API calls to a Map/Dict structure (depending on language) which can speed up processing in many situations too by allowing a key-value lookup instead of iterating across a list.
    Last edited by Nexus on 08:18:15 - 29/02/24

    [img]https://i.ibb.co/vh8Bcmr/image.png[/img]

Reply
Thread Title: