Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!game command behaving weirdly #144

Open
melon-ggenkov opened this issue Aug 2, 2022 · 4 comments
Open

!game command behaving weirdly #144

melon-ggenkov opened this issue Aug 2, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@melon-ggenkov
Copy link

melon-ggenkov commented Aug 2, 2022

The !game command seems to pick weird categories. I'm not sure if this is the bot's fault or Twitch's. It doesn't seem to follow neither closest match nor the way the search results are ranked when using Twitch's searchbar.

image
ArtRageous! isn't even on the list on Twitch's searchbar.

image
Self explanatory

image
I would expect it to potentially confuse it with GTA Vice City here (like Twitch search does) but III is even weirder.

image
Twitch's searchbar correctly shows Grand Theft Auto V here

@pavelpilar
Copy link
Contributor

It looks like the Search Categories API endpoint does not make any guarantees about the order of returned results. I haven't verified but it's possible they are sorted by id instead of by relevance which is what the searchbar does.

Right now the bot simply takes the first result, I'm not sure if there's something we can reasonably do to figure out the best match ourselves. We could hardcode some inputs to resolve to the correct category name before the request gets sent (e.g. transforming "GTA 5" into "Grand Theft Auto V"), which is a very hacky way around the issue, but it's the best I came up with on the spot.

let stream = self.twitch.new_search_categories(rest);
tokio::pin!(stream);
let first = if let Some(first) = stream.next().await {
first?
} else {
respond!(ctx, "No category found matching `{}`", rest);
return Ok(());
};

@udoprog udoprog added the bug Something isn't working label Aug 3, 2022
@pavelpilar
Copy link
Contributor

I have now checked and the API call results are sorted by ID. Unless someone at Twitch feels like making an endpoint that would search by relevance, the best option is probably to hack together something to dig through the results.

  1. For queries like "GTA 5", put together a mapping to the correct category name
  2. For "Art", loop through all of the results and look for an exact match
  3. For the rest, either take the first result like now or let the universe decide and pick a random one

@udoprog
Copy link
Owner

udoprog commented Aug 4, 2022

Hm. How about presenting alternatives to the user?

!game GTA V
udoprog -> Your request matches more than one category;
1) GTA III,
2) GTA V. 
udoprog -> Please type !game followed by the number of the category you want, like !game 1 for "GTA V" above.

@pavelpilar
Copy link
Contributor

I'd be worried about this polluting the chat too much. For something like "GTA 5" there are already 7 results, for "Art" it is over 20 (I didn't bother paging through all of them). Some can also get really long like "Grand Theft Auto: Vice City – The Definitive Edition" which doesn't even fit on one line.

A good compromise might be to look for the exact match first and if there isn't one either give the user some alternatives or an error message in case there are too many. The unfortunate thing in that case is that doing !game GTA 5 still wouldn't give the desired result, but that's something we might have to live with considering the Twitch API doesn't support our use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants