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
Improved emote parsing in PrivateMessage #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
It looks good but I would like some fixes/improvements.
I've left some comments.
} | ||
|
||
/// Try and retrieve the parts and add them to our list of emotes | ||
if let lastID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot use this kind of variable binding because we need to support older swift versions than 5.7.
change this to let lastID = lastID,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! That's my bad, I could only run the tests on Xcode 14 :)
I made the changes, thank you for taking the time to review the PR. However, I feel like Cheers 😃 |
Thanks for the changes, I'll take a look. I do agree that the automatic synthesized conformance for |
Thanks again. This looks good. |
This will be tagged in a few days. This also contains a breaking change, so hopefully its worth it. |
Yes, I can see that. It's really not a big problem, and "keeping it simple" is a good argument for it. If only the compiler could auto-synthesize from an extension 😄.
I've been using it in my own app with good success to load up the emotes. The only thing I am missing now is getting emote sets that are not global or the room's. I will look into that and perhaps send another PR.
Understood 👍🏽 |
Hi there!
I've been using your package for a personal project and it is great! Thank you very much for all the work. Since it has been very helpful, I thought I'd give back by improving something I found was not as straight forward as other aspects of the message.
Up to now, the parsing of the emotes in the message was a bit odd, specially for handling messages where the same emote repeats multiple times.
I made a small utility function that takes care of better parsing the information from the message into an array containing a new struct
EmoteReference
. This struct includes the id of the emote, the name (aka the text used to represent the emote), and the indices in the message that correspond to the emote. The idea is that having all this information it is easier for a user of the package to handle emotes.Please, let me know if there's anything out of place or if I should include some more test cases (although I feel like the one included already handles all cases).
Cheers!