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

Correctly handle twitch subscriber emotes #591

Merged
merged 4 commits into from
Jun 10, 2024

Conversation

Nogesma
Copy link
Contributor

@Nogesma Nogesma commented May 4, 2024

This PR switches to parsing the emotes irc tag to find twitch emotes to display, to actually correctly display emotes from people that are subbed to a channel.
Users subscribed to a channel can use emotes from this channel into other channels chat, this enables detection of such emotes.

There's still a bit of work to do to detect emotes that the current user can use, to display them in the emote picker, and I need to clean up the code and do some tests, so this is why this is a draft PR.

This also reverts the change that added the '-animated' string at the end of animated twitch emotes (#587), as I found it complicates stuff a bit. (ie. I would need to check the cache for both the animated and normal version if they had different name). The only issue is that users would need to delete the cache to switch to the animated version of the twitch emotes, if they had the static one already in cache.
If you would prefer to not need user intervention, I can try to think of a way to avoid this, but clearing the cache is definitely the easier option.

Copy link

codecov bot commented May 4, 2024

Codecov Report

Attention: Patch coverage is 9.51220% with 371 lines in your changes missing coverage. Please review.

Project coverage is 18.21%. Comparing base (c3fa4fe) to head (0ceeda2).

Files Patch % Lines
src/handlers/data.rs 5.43% 174 Missing ⚠️
src/emotes/downloader.rs 0.00% 90 Missing ⚠️
src/twitch/mod.rs 0.00% 44 Missing ⚠️
src/terminal.rs 0.00% 19 Missing ⚠️
src/ui/components/emote_picker.rs 0.00% 18 Missing ⚠️
src/twitch/oauth.rs 0.00% 12 Missing ⚠️
src/emotes/mod.rs 0.00% 11 Missing ⚠️
src/twitch/channels.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #591      +/-   ##
==========================================
- Coverage   19.20%   18.21%   -1.00%     
==========================================
  Files          41       41              
  Lines        5102     5310     +208     
==========================================
- Hits          980      967      -13     
- Misses       4122     4343     +221     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Nogesma
Copy link
Contributor Author

Nogesma commented May 4, 2024

Seems like rust 1.78 added a bunch of clippy lints. How do you want to proceed with those?

@Xithrius
Copy link
Owner

Xithrius commented May 4, 2024

You can ignore them if you want. As long as it builds and actually functions, all is good.

@Xithrius
Copy link
Owner

Xithrius commented May 4, 2024

If you would prefer to not need user intervention, I can try to think of a way to avoid this, but clearing the cache is definitely the easier option.

Having the user clear the cache sounds good to me. I'll put a note in the next release that includes a note saying to do so.

@pull-request-size pull-request-size bot added size/XL and removed size/L labels May 6, 2024
@Nogesma
Copy link
Contributor Author

Nogesma commented May 6, 2024

Okay this should be feature complete now, feel free to test.

I am not subscribed to any twitch channel, so I'm not really able to test the emote picker nor sending messages that contains subscriber only emotes, but receiving them works nicely on my end.

I ended up moving the code around a bit in the message parsing, as the message can be now parsed 3 different ways depending on where it came from. (This is mostly why the diff is so large)

  • If it came from twitch, then it needs to be parsed using both the emotes provided in the irc tags, and the global emotes.
  • If it came from the current user, it needs to be parsed using the user emotes, and the global emotes.
  • When the emotes finish downloading, the previous messages will have already been parsed with the twitch irc tag emotes, but not with the global ones, so they will need to be reparsed with that.

I also now cache the twitch user id when the first request is made, so getting the following list should be a bit quicker now.

I still need to document this stuff somewhere and maybe cleanup a few things, but this should be ready to merge soon.

@Nogesma Nogesma force-pushed the feature/twitch-sub-emotes branch from 23f22e0 to ee2bb7b Compare May 6, 2024 14:38
@Nogesma
Copy link
Contributor Author

Nogesma commented May 6, 2024

This should now be ready to merge once #595 is merged. I rebased on top of this PR so that checks pass.

@Nogesma Nogesma marked this pull request as ready for review May 6, 2024 14:39
@Xithrius
Copy link
Owner

Xithrius commented May 6, 2024

#595 has been merged.

@Nogesma Nogesma force-pushed the feature/twitch-sub-emotes branch from ee2bb7b to bc12fca Compare May 6, 2024 17:10
@Nogesma
Copy link
Contributor Author

Nogesma commented May 6, 2024

Just rebased on top of main

@Nogesma Nogesma force-pushed the feature/twitch-sub-emotes branch from bc12fca to 9f340bd Compare May 6, 2024 20:40
@Nogesma
Copy link
Contributor Author

Nogesma commented May 6, 2024

I had committed my cargo.toml by mistake, fixed that

@Xithrius Xithrius self-requested a review May 6, 2024 21:01
@Nogesma Nogesma force-pushed the feature/twitch-sub-emotes branch 2 times, most recently from ef84cf6 to df368d7 Compare May 6, 2024 22:13
@Nogesma Nogesma force-pushed the feature/twitch-sub-emotes branch from df368d7 to 4189ff4 Compare May 15, 2024 02:20
@Nogesma
Copy link
Contributor Author

Nogesma commented May 15, 2024

I fixed a few issues I found while testing this some more. Hopefully everything should be good now. Also rebased on top of main.

EDIT: I also noticed that you need the user:read:emotes scope in the token to be able to query all the emotes that a user can use, it should probably be mentioned in the release notes.
If the scope is not there, the emotes that you can access (that are not twitch global emotes) wont show in the emote picker, nor in the messages you send (only on the client side).

@Nogesma Nogesma force-pushed the feature/twitch-sub-emotes branch from 4189ff4 to b2c61bf Compare May 15, 2024 02:29
@Nogesma
Copy link
Contributor Author

Nogesma commented May 15, 2024

Oops broke the tests, should be good now.

@Xithrius
Copy link
Owner

Xithrius commented Jun 4, 2024

Sorry I haven't been able to review this, been focusing on a couple other projects. Hope to review in the next week or so.

Copy link
Owner

@Xithrius Xithrius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran it after clearing cache, works perfectly. Just making sure, should I still warn users about a non-cleared cache in the release, or is that unnecessary? Thanks!

@Nogesma
Copy link
Contributor Author

Nogesma commented Jun 8, 2024

Yes, clearing cache is still needed, but not clearing it will just make twt use the static images for already downloaded animated twitch emotes.
You should probably also mention the user:read:emotes scope that is needed to display the subscriber only-emotes that someone can use.

Thanks for the review!

@Nogesma Nogesma force-pushed the feature/twitch-sub-emotes branch from b2c61bf to 0ceeda2 Compare June 8, 2024 22:58
@Nogesma
Copy link
Contributor Author

Nogesma commented Jun 8, 2024

Just rebased on top of main

@Xithrius Xithrius merged commit 384e838 into Xithrius:main Jun 10, 2024
6 of 8 checks passed
@Xithrius
Copy link
Owner

Thank you again!

@Nogesma Nogesma deleted the feature/twitch-sub-emotes branch June 10, 2024 21:06
@Xithrius
Copy link
Owner

I'll put this in a release once #611 is resolved.

@Xithrius
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants