Skip to content

[Feature Request] Reply to messages #7

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

Closed
NicolasDerumigny opened this issue Oct 27, 2021 · 3 comments
Closed

[Feature Request] Reply to messages #7

NicolasDerumigny opened this issue Oct 27, 2021 · 3 comments

Comments

@NicolasDerumigny
Copy link

Reactions are nice, but it would be great to have a way to reply by quoting original matched user message, as well as an example illustrating it.

@HarHarLinks
Copy link

there isn't an example, but you can easily send replies by just following the spec of a reply. You can generate an example by sending what you want in a client and then inspecting the message json. E.g. this is a very generic template for a media event that is a reply at the same time.

    replymedia:
        type: m.room.message
        variables:
            react_to_event: '{{event.content.get_reply_to() or event.event_id}}'
        content:
            msgtype: $${type}
            body: $${description}
            url: $${media}
            info:
                mimetype: $${mime}
                w: $${width}
                h: $${height}}
                size: $${size}
            m.relates_to:
                rel_type: m.reply
                m.in_reply_to:
                    event_id: $${react_to_event}

@spaetz
Copy link

spaetz commented Feb 4, 2022

Possible,
here are my templates for both plaintext replies and markdown replies. Perhaps it would make sense to add those to the sample docs somewhere. (apologies if my reply is too close to the previous one, which provides an excellent and a bit more generic template.

    plaintext_reply:
        type: m.room.message
        variables:
            react_to_event: '{{event.content.get_reply_to() or event.event_id}}'
        content:
            m.relates_to:
                m.in_reply_to:
                    event_id: $${react_to_event}
            msgtype: m.text
            body: $${message}
    md_reply:
        type: m.room.message
        variables:
            react_to_event: '{{event.content.get_reply_to() or event.event_id}}'
        content:
            m.relates_to:
                m.in_reply_to:
                    event_id: $${react_to_event}
            msgtype: m.text
            body: $${message}
            format: org.matrix.custom.html
            formatted_body: $${formatted_body}

@HarHarLinks
Copy link

HarHarLinks commented Feb 4, 2022

I am currently using these 4 templates:

    reply:
        type: m.room.message
        variables:
            react_to_event: '{{event.content.get_edit() or event.event_id}}'
        content:
            msgtype: $${type}
            body: $${body}
            m.relates_to:
                rel_type: m.reply
                m.in_reply_to:
                    event_id: $${react_to_event}

    replyhtml:
        type: m.room.message
        variables:
            react_to_event: '{{event.content.get_edit() or event.event_id}}'
        content:
            msgtype: $${type}
            body: $${body}
            format: org.matrix.custom.html
            formatted_body: $${formattedbody}
            m.relates_to:
                rel_type: m.reply
                m.in_reply_to:
                    event_id: $${react_to_event}

    replymedia:
        type: m.room.message
        variables:
            react_to_event: '{{event.content.get_edit() or event.event_id}}'
        content:
            msgtype: $${type}
            body: $${description}
            url: $${media}
            info:
                mimetype: $${mime}
                w: $${width}
                h: $${height}
                size: $${size}
            m.relates_to:
                rel_type: m.reply
                m.in_reply_to:
                    event_id: $${react_to_event}

    replysticker:
        type: m.sticker
        variables:
            react_to_event: '{{event.content.get_edit() or event.event_id}}'
        content:
            url: $${sticker}
            info:
                w: $${width}
                h: $${height}
                size: $${size}
                mimetype: $${mime}
            body: $${description}
            m.relates_to:
                rel_type: m.reply
                m.in_reply_to:
                    event_id: $${react_to_event}

I suppose with some jinja magic that detects what values are set and switches based on that it might even be possible to merge them.

Please note especially that I have changed

- react_to_event: '{{event.content.get_reply_to() or event.event_id}}'
+ react_to_event: '{{event.content.get_edit() or event.event_id}}'

The old version is based on the current templates, but in case the reaction gets triggered by a reply, then maubot will also react/reply to the original message instead of the message that triggered it. It would also not work great with edited messages. The updated version fixes both of those issues.

If extensible events are coming along shortly, all these schemes will need some updates.

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

No branches or pull requests

4 participants