Skip to content

Conversation

Mm2PL
Copy link
Collaborator

@Mm2PL Mm2PL commented Aug 11, 2025

Gives plugins the ability to add links to message elements

image

@Mm2PL Mm2PL requested a review from pajlada August 11, 2025 01:28
@Mm2PL
Copy link
Collaborator Author

Mm2PL commented Aug 11, 2025

@Nerixyz I'd like your review on this PR.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Copy link
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

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

Additionally, would be nice with a test for this functionality showing some example usages

@Mm2PL
Copy link
Collaborator Author

Mm2PL commented Aug 17, 2025

I'd prefer if we wait with plugin-provided tooltips for Links until we have a safe interface for it (i.e. a way to set a tooltip that only allows for plaintext stuff)

The tooltip data is now ignored when using links.

I can't mark your comment as resolved

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

@Mm2PL Mm2PL requested review from pajlada and Nerixyz August 18, 2025 20:56
Copy link
Contributor

@Nerixyz Nerixyz left a comment

Choose a reason for hiding this comment

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

I haven't tested this yet but the code looks fine except the clang-tidy suggestion.

@Nerixyz
Copy link
Contributor

Nerixyz commented Aug 19, 2025

From testing:

  • Links on timestamp elements don't work because they create a text element without passing the link/tooltip
  • Links on reply curves don't work because it doesn't have a hitbox - its height is 0
Test
c2.register_command("/links", function(ctx)
    local chan = ctx.channel
    chan:add_message(c2.Message.new({
        id = "testing42",
        elements = { { type = "text", text = "testing" } },
    }))
    local lb = { type = "linebreak", flags = c2.MessageElementFlag.Text };
    chan:add_message(c2.Message.new({
        elements = {
            {
                type = "text",
                text = "Text Element",
                link = { type = c2.LinkType.Url, value = "https://twitch.com/forsen" },
            },
            {
                type = "single-line-text",
                text = "single-line-text",
                link = { type = c2.LinkType.UserInfo, value = "id:141981764" },
            },
            {
                type = "mention",
                display_name = "display_name[Mention]",
                login_name = "twitchdev",
                user_color = "link",
                fallback_color = "link",
            },
            {
                type = "timestamp",
                link = { type = c2.LinkType.JumpToChannel, value = "twitchdev" }
            },
            lb,
            {
                type = "reply-curve",
                link = { type = c2.LinkType.CopyToClipboard, value = "hello world" }
            },
            {
                type = "text",
                text = "some text",
            }
        }
    }))
    chan:add_message(c2.Message.new({
        flags = c2.MessageFlag.Centered,
        elements = {
            {
                type = "text",
                text = "Available Links",
                style = c2.FontStyle.ChatVeryLarge,
            },
            lb,
            {
                type = "text",
                text = "JumpToChannel",
                link = { type = c2.LinkType.JumpToChannel, value = "twitchdev" },
            },
            lb,
            {
                type = "text",
                text = "JumpToMessage",
                link = { type = c2.LinkType.JumpToMessage, value = "testing42" },
            },
            lb,
            {
                type = "text",
                text = "CopyToClipboard",
                link = { type = c2.LinkType.CopyToClipboard, value = "Hello, World!" },
            },
            lb,
            {
                type = "text",
                text = "Url",
                link = { type = c2.LinkType.Url, value = "https://example.com" },
            },
            lb,
            {
                type = "text",
                text = "UserAction",
                link = { type = c2.LinkType.UserAction, value = "My user action" },
            },
            lb,
            {
                type = "text",
                text = "UserInfo",
                link = { type = c2.LinkType.UserInfo, value = "twitchdev" },
            }
        }
    }))
end)

@Mm2PL Mm2PL requested a review from Nerixyz August 20, 2025 00:19
Copy link
Contributor

@Nerixyz Nerixyz left a comment

Choose a reason for hiding this comment

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

Works fine for me now.

@pajlada
Copy link
Member

pajlada commented Aug 23, 2025

this pr changes the way the curve element renders. I'm ok with either re-breaking curve element links in this PR, or ensuring they look the same.

new:
unsorted_20250823_12h15m46s

old:
unsorted_20250823_12h15m45s

@Mm2PL
Copy link
Collaborator Author

Mm2PL commented Aug 29, 2025

@pajlada I have re-broken reply-curves, they now should render the same as before.

@Mm2PL Mm2PL force-pushed the feature/plugin-message-construction-link branch from 60872f4 to 995bf0b Compare September 13, 2025 10:46
@Mm2PL
Copy link
Collaborator Author

Mm2PL commented Sep 23, 2025

@pajlada could you review this when you have time?

@pajlada
Copy link
Member

pajlada commented Sep 23, 2025

@pajlada could you review this when you have time?

I'll start taking a look at these leftover PRs this weekend

Copy link
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

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

Just fix the changelog entry and you can merge this in

- Minor: Allow for themes to set transparent values for window background on Linux. (#6137)
- Minor: Popup overlay now only draws an outline when being interacted with. (#6140)
- Minor: Added basic message API to plugins. (#5754)
- Minor: Added basic message API to plugins. (#5754, #6386)
Copy link
Member

@pajlada pajlada Sep 27, 2025

Choose a reason for hiding this comment

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

fix the changelog entry (move it to the right place)

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

Successfully merging this pull request may close these issues.

3 participants