ircv3-ideas
ircv3-ideas copied to clipboard
Message attachments
As mentioned in ircv3/ircv3-specifications#302
I've started experimenting with a tag for attaching richer data to a message, similar to https://api.slack.com/docs/message-attachments
It's basically a JSON blob with fields like this:
{
"from_url": "http://ircv3.net",
"service_icon": "http://ircv3.net/apple-touch-icon.png",
"service_name": "ircv3.net",
"text": "Welcome to the IRCv3 Working Group. We're a group of IRC client and server software authors working to improve the IRC protocol.",
"title": "Welcome - IRCv3",
"title_link": "http://ircv3.net"
}
@+draft/attachments=[{"title_link":"http://ircv3.net","title":"Welcome\s-\sIRCv3","text":"Welcome\sto\sthe\sIRCv3\sWorking\sGroup.\sWe're\sa\sgroup\sof\sIRC\sclient\sand\sserver\ssoftware\sauthors\sworking\sto\simprove\sthe\sIRC\sprotocol.","service_name":"ircv3.net","service_icon":"http://ircv3.net/apple-touch-icon.png","from_url":"http://ircv3.net"}] :[email protected] PRIVMSG #test :check out this cool website http://ircv3.net/
Rendering might look like this:

Many of the fields in slack's version are pretty generic, here's the subset I've been using:
author_icon
author_link
author_name
author_subname
author_url
color
fields
file_url
footer
footer_icon
from_url
image_bytes
image_height
image_url
image_width
pretext
pretext_emoji
service_icon
service_name
service_url
snippet_bytes
snippet_filename
snippet_lines
snippet_preview
snippet_preview_lines
snippet_raw
snippet_type
text
text_emoji
thumb_height
thumb_url
thumb_width
title
title_link
ts
One thing to bear in mind is how this falls back for legacy clients. Usually the attached data is additional information that isn't crucial to the message, but in some cases it might be more important. For those cases I've been trying an attachment-fallback boolean tag that lets you send a followup PRIVMSG with the "fallback" text for legacy clients, while clients that support attachments can just ignore that message:
So e.g. the above example could be followed up with this message:
@+draft/attachment-fallback :[email protected] PRIVMSG #test :Welcome to the IRCv3 Working Group. We're a group of IRC client and server software authors working to improve the IRC protocol.