Tillerino / Tillerinobot

346 stars 112 forks source link

Move to apiv2 #231

Open vladislavsss1 opened 7 months ago

vladislavsss1 commented 7 months ago

I have 1.5k play count, but the bot tells me to play a few games and it keeps telling me this even after I've played a few times. How to solve this problem?

spookybear0 commented 7 months ago

i've noticed this too in my own bot, it seems that if a player only has played on lazer, it's not possible to acquire their best plays through apiv1.

To fix this issue Tillerino must use apiv2.

Tillerino commented 6 months ago

Oh no :laughing:

It was a matter of time before we move to v2. I guess I'll rename this issue, then.

Ameobea commented 6 months ago

I recently added support for lazer scores to osutrack. Rather than do surgery on the horrible 10-year-old codebase, I created a little API proxy that handles doing the OAuth and stuff required by v2 and then exposing the hiscores in the old v1 format (as closely as possible): https://github.com/ameobea/osu-api-bridge

Idk if it will be useful as-is to you, but I did reverse engineer their currently undocumented format for v2 hiscores. It's not too complicated, but there is some nuance about when to use legacy fields or not and stuff like that. You also have to set an x-api-version header to indicate that you want lazer scores and the new response format. If you don't set it, the default behavior is to give only classic scores.

As for real docs on the v2 score stuff, there isn't much but I've heard that it's planned after talking to other devs and seems to be being worked on: https://github.com/ppy/osu-web/pull/11035

Anyway, I just wanted to share that info in case it might be helpful. I've gotten back into osu recently, inspired by working on osutrack again, and I'd love to see Tillerino bot pick up my new shiny lazer hiscores :)

Tillerino commented 6 months ago

You had me at Cargo.toml

This looks amazing. You don't have the docker image pushed somewhere by chance?

Ameobea commented 6 months ago

I just pushed it up here: us-central1-docker.pkg.dev/free-tier-164405/ameo/osu-api-bridge:latest

I'm running it with this command:

docker run \
  --name osu-api-bridge \
  --restart=always \
  -d \
  -p 4510:4510 \
  -p 4511:4511 \
  -v /opt/conf/osutrack/api-bridge-conf.yml:/opt/conf.yml \
  -e RUST_LOG=info \
 us-central1-docker.pkg.dev/free-tier-164405/ameo/osu-api-bridge:latest \
  /usr/local/bin/osu-api-bridge --config /opt/conf.yml

The config file can be the same as the default-config.yml from the repo; you just have to set your OAuth token and secret at the bottom and the rest can be left as-is.

The main service listens on port 4510; 4511 is prometheus metrics. There's only one endpoint: GET http://localhost:4510/users/4093752/hiscores?mode=0&limit=20&offset=10

It returns data as close to the format from https://osu.ppy.sh/api/get_user_best as I could get. As far as I've seen, everything matches except some 50/100/300/geki/etc. counts don't seem to exist in the same way, so those don't line up perfectly.

Lmk if you want help getting it set up or running; feel free to ping me on Discord as well.

I will say, though, that the core of this code really is quite minimal. I think there's a decent chance you'd be able to modify your bot's code to talk to the v2 API natively for hiscores without a ton of effort tbh