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

How to highlight all @ #4272

Closed
mcprat opened this issue Dec 12, 2020 · 8 comments
Closed

How to highlight all @ #4272

mcprat opened this issue Dec 12, 2020 · 8 comments

Comments

@mcprat
Copy link

mcprat commented Dec 12, 2020

I was just wondering if there was a way to highlight all mentions, any chat line with the @ symbol in it

@Nareese
Copy link
Contributor

Nareese commented Dec 12, 2020

To the best of my ability to determine based on personal experience, testing, and reading the code, this is not possible.

Twitch messages, internally, are not simple text... they are made up of "fragments" of specific purposes... some is just plain text, but there are also mentions (the current user and other users treated separately), links, emotes, etc... all of these are processed separately. When BTTV sees a mention fragment, it strips the username only out of the fragment data and matches against that, Hence, the "@" of a mention fragment is not part of the text that can be matched against... so it is not possible to do things like "@*".

@mcprat
Copy link
Author

mcprat commented Dec 12, 2020

so matching by the character is not possible, but what about a systematic way to identify whether a chat entry has a username / mention in it?

@Nareese
Copy link
Contributor

Nareese commented Dec 12, 2020

No, there is no way to achieve any kind of "selective" matching, not of mentions, anyway. The fragments are all converted to something "plain text ish", emotes to their code, links to plain text, mentions to the username only, etc, and then merged together with the plain text fragments, and then your keywords are matched against that merged text. The only type based matching the highlight system supports is matching the username of the sender (with the () syntax). and again, that's not a text match, but a match against the actual sender username from the internal message data.

@mcprat
Copy link
Author

mcprat commented Dec 12, 2020

can you link me where matching happens in the code, im just curious

@Nareese
Copy link
Contributor

Nareese commented Dec 12, 2020

The high level match occurs in onMessage at

if (fromContainsKeyword(highlightUsers, from) || messageContainsKeyword(highlightKeywords, from, message)) {
, the conversion from fragments to text happens at
function messageTextFromAST(ast) {
and there are various other supporting functions throughout that file.

@mcprat
Copy link
Author

mcprat commented Dec 13, 2020

Yeah I can see how it's not possible at the moment

looks like there would have to be a new function like isReply that gets called a similar way with a new setting

function isMention($message) {
    return $message.parent().hasClass('some_class');
}
        if (fromContainsKeyword(highlightUsers, from) || messageContainsKeyword(highlightKeywords, from, message)
            || (isMention($message) && settings.get('highlightMentions')) {
            this.markHighlighted($message);

im not a programmer so idk if theres a cleaner way
maybe ill try this if i have the time

@mcprat
Copy link
Author

mcprat commented Dec 13, 2020

following from this

https://www.w3schools.com/jquery/traversing_find.asp

I think the function would be

function isMention($message) {
    return $message.find("span").hasClass('mention-fragment');
}

and maybe it would be better to have a separate if before the rest but idk

mcprat added a commit to mcprat/betterttv that referenced this issue Dec 16, 2020
Closes night#4272

Thanks to @Nareese for guidance

Signed-off-by: Michael Pratt <mcpratt@pm.me>
mcprat added a commit to mcprat/betterttv that referenced this issue Dec 18, 2020
using the strings '$@' for mentions and '$#' for links
for the current message matching system instead of an independent setting

Closes night#4272

Thanks to @Nareese for guidance

Signed-off-by: Michael Pratt <mcpratt@pm.me>
mcprat added a commit to mcprat/betterttv that referenced this issue Dec 19, 2020
using the strings '$@' for mentions and '$#' for links
for the current message matching system instead of an independent setting
forming one multiline if statement to cover all related features

Closes night#4272

Thanks to @Nareese for guidance

Signed-off-by: Michael Pratt <mcpratt@pm.me>
mcprat added a commit to mcprat/betterttv that referenced this issue Dec 19, 2020
using the strings '$@' for mentions and '$#' for links
for the current message matching system instead of an independent setting
forming one multiline if statement to cover all related features

Closes night#4272

Thanks to @Nareese for guidance

Signed-off-by: Michael Pratt <mcpratt@pm.me>
mcprat added a commit to mcprat/betterttv that referenced this issue Mar 15, 2021
using the strings '$@' for mentions and '$#' for emotes
for the current message matching system instead of an independent setting
forming one multiline if statement to cover all related features

Closes night#4272

Thanks to @Nareese for guidance

Signed-off-by: Michael Pratt <mcpratt@pm.me>
@night night closed this as completed in 42edee8 Dec 30, 2022
dclstn pushed a commit to dclstn/betterttv that referenced this issue Jan 3, 2023
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related issues or feature requests.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants