From 06ef5fc43b52fa22810df39abe9d12e922c4d0fc Mon Sep 17 00:00:00 2001 From: Sheldan <5037282+Sheldan@users.noreply.github.com> Date: Sat, 19 Jul 2025 23:57:43 +0200 Subject: [PATCH] [AB-xxx] adding avatar to message embed adding avatar to starboard post adding possibility to define a color for the starboard container fixing attachment logic for starboard post fixing streamer went offline message not using components v2 --- .../default/listener/message_embed_embed.ftl | 20 ++++++++- .../config/starboard_post_container_color.ftl | 0 .../default/listener/starboard_post_embed.ftl | 42 +++++++++++++++---- ...ch_streamer_went_offline_message_embed.ftl | 41 +++++++++++++----- ...tarboard_post_embed_additional_message.ftl | 3 +- ...ent_offline_notification_past_sections.ftl | 2 +- 6 files changed, 84 insertions(+), 24 deletions(-) create mode 100644 abstracto-modules/starboard/src/main/resources/default/config/starboard_post_container_color.ftl diff --git a/abstracto-modules/link-embed/src/main/resources/default/listener/message_embed_embed.ftl b/abstracto-modules/link-embed/src/main/resources/default/listener/message_embed_embed.ftl index 9fe5177e..f49f4fc2 100644 --- a/abstracto-modules/link-embed/src/main/resources/default/listener/message_embed_embed.ftl +++ b/abstracto-modules/link-embed/src/main/resources/default/listener/message_embed_embed.ftl @@ -1,12 +1,28 @@ { "components": [ { - "type": "textDisplay", + <#assign userFound=author??> <#include "user_user_name"> <#assign userText><#if author??><@user_user_name user=author/><#else><@safe_include "delete_user_name"/> <#include "member_user_name"> <#assign embeddingUserText><@member_user_name member=embeddingUser/> - "content": "<@safe_include "message_embed_meta_info"/>" + <#assign userAvatar><#if author??>${author.effectiveAvatarUrl} + <#if userFound> + "type": "section", + "components": [ + { + "type": "textDisplay", + "content": "<@safe_include "message_embed_meta_info"/>" + } + ], + "accessory": { + "type": "thumbnail", + "url": "${userAvatar}" + } + <#else> + "type": "textDisplay", + "content": "<@safe_include "message_embed_meta_info"/>" + }, { "type": "container", diff --git a/abstracto-modules/starboard/src/main/resources/default/config/starboard_post_container_color.ftl b/abstracto-modules/starboard/src/main/resources/default/config/starboard_post_container_color.ftl new file mode 100644 index 00000000..e69de29b diff --git a/abstracto-modules/starboard/src/main/resources/default/listener/starboard_post_embed.ftl b/abstracto-modules/starboard/src/main/resources/default/listener/starboard_post_embed.ftl index 09760ea9..941f8ed3 100644 --- a/abstracto-modules/starboard/src/main/resources/default/listener/starboard_post_embed.ftl +++ b/abstracto-modules/starboard/src/main/resources/default/listener/starboard_post_embed.ftl @@ -1,21 +1,40 @@ { "components": [ { - "type": "textDisplay", + <#assign userFound=author??> <#assign emote>${starLevelEmote} <#assign count>${starCount} <#assign messageId>${message.messageId?c} <#assign userText><#if author??><#include "user_user_name"><@user_user_name user=author/><#else><@safe_include "delete_user_name"/> - <#if channel?has_content> - <#assign channelMention>${channel.asMention?json_string} - "content": "<@safe_include "starboard_post_embed_additional_message"/>" + <#assign userAvatar><#if author??>${author.effectiveAvatarUrl} + <#assign userComponent> + "type": "textDisplay", + <#if channel?has_content> + <#assign channelMention>${channel.asMention?json_string} + "content": "<@safe_include "starboard_post_embed_additional_message"/> ${(starCount >= 15)?string('yes', 'no')} ${(starCount >= 15)?string('yes', 'no')} ${(starCount >= 10)?string('yes', 'no')} ${(starCount >= 2)?string('yes', 'no')} ${(starCount >= 1)?string('yes', 'no')}" + <#else> + <#assign channelMention>${sourceChannelId?c} + "content": "<@safe_include "starboard_post_embed_additional_message"/>" + + + <#if userFound> + "type": "section", + "components": [ + { + ${userComponent} + } + ], + "accessory": { + "type": "thumbnail", + "url": "${userAvatar}" + } <#else> - <#assign channelMention>${sourceChannelId?c} - "content": "<@safe_include "starboard_post_embed_additional_message"/>" + ${userComponent} } ,{ "type": "container", + <#include "starboard_post_container_color"> "components": [ <#assign hasContent=false> <#if message.content?has_content> @@ -26,8 +45,15 @@ } <#list message.embeds as embed> - <#if embed.description?has_content> + <#if embed.description?has_content && !((embed.cachedImageInfo?has_content && embed.cachedImageInfo.proxyUrl?has_content) || (embed.cachedThumbnail?has_content && embed.cachedThumbnail.proxyUrl?has_content))> <#assign hasContent=true> + { + "type": "textDisplay", + "content": "${embed.description?json_string}" + } + <#elseif embed.description?has_content && (embed.cachedImageInfo?has_content && embed.cachedImageInfo.proxyUrl?has_content && embed.cachedImageInfo.width gt 0) + || (embed.cachedThumbnail?has_content && embed.cachedThumbnail.proxyUrl?has_content && embed.cachedThumbnail.width gt 0)> + <#assign hasContent=true> ,{ "type": "section", "components": [ @@ -36,12 +62,10 @@ "content": "${embed.description?json_string}" } ] - <#if (embed.cachedImageInfo?has_content && embed.cachedImageInfo.proxyUrl?has_content) || (embed.cachedThumbnail?has_content && embed.cachedThumbnail.proxyUrl?has_content)> ,"accessory": { "type": "thumbnail", "url": "${(embed.cachedImageInfo.proxyUrl)!embed.cachedThumbnail.proxyUrl}" } - } <#elseif (embed.cachedImageInfo?has_content && embed.cachedImageInfo.proxyUrl?has_content && embed.cachedImageInfo.width gt 0) || (embed.cachedThumbnail?has_content && embed.cachedThumbnail.proxyUrl?has_content && embed.cachedThumbnail.width gt 0)> diff --git a/abstracto-modules/twitch/src/main/resources/default/general/twitch_streamer_went_offline_message_embed.ftl b/abstracto-modules/twitch/src/main/resources/default/general/twitch_streamer_went_offline_message_embed.ftl index b30ca868..4cc73798 100644 --- a/abstracto-modules/twitch/src/main/resources/default/general/twitch_streamer_went_offline_message_embed.ftl +++ b/abstracto-modules/twitch/src/main/resources/default/general/twitch_streamer_went_offline_message_embed.ftl @@ -1,18 +1,37 @@ <#include "format_instant"> { - "embeds": [ + "components": [ { - <#include "twitch_color">, <#assign channelName=channelName> <#assign avatarURL=avatarURL> - "title": { - "title": "<@safe_include "twitch_streamer_went_offline_notification_title"/>" - }, - "author": { "name": "${channelName}", "avatar": "${avatarURL}"}, - "description": "<@safe_include "twitch_streamer_went_offline_notification_past_sections"/>" - <#if offlineImageURL??>, - <#assign offlineImageURL=offlineImageURL> - "imageUrl": "${offlineImageURL}" + "type": "section", + "components": [ + { + "type": "textDisplay", + "content": "<@safe_include "twitch_streamer_went_offline_notification_title"/>" + }, + { + "type": "textDisplay", + "content": "<@safe_include "twitch_streamer_went_offline_notification_past_sections"/>" + } + ] + ,"accessory": { + "type": "thumbnail", + "url": "${avatarURL}" + } } - ] + <#if offlineImageURL??>, + { + "type": "mediaGallery", + "images": [ + { + "url": "${offlineImageURL}" + } + ] + } + + ], + "messageConfig": { + "useComponentsV2": true + } } \ No newline at end of file diff --git a/translations/starboard/src/main/resources/default/listener/starboard_post_embed_additional_message.ftl b/translations/starboard/src/main/resources/default/listener/starboard_post_embed_additional_message.ftl index 17253ba8..7c37eca4 100644 --- a/translations/starboard/src/main/resources/default/listener/starboard_post_embed_additional_message.ftl +++ b/translations/starboard/src/main/resources/default/listener/starboard_post_embed_additional_message.ftl @@ -1 +1,2 @@ -${emote} ${count} by ${userText} in ${channelMention} ID: ${messageId} \ No newline at end of file +-# ${emote} ${count} by ${userText} in ${channelMention} +-# ID: ${messageId} \ No newline at end of file diff --git a/translations/twitch/src/main/resources/default/general/twitch_streamer_went_offline_notification_past_sections.ftl b/translations/twitch/src/main/resources/default/general/twitch_streamer_went_offline_notification_past_sections.ftl index 92459617..7e063c39 100644 --- a/translations/twitch/src/main/resources/default/general/twitch_streamer_went_offline_notification_past_sections.ftl +++ b/translations/twitch/src/main/resources/default/general/twitch_streamer_went_offline_notification_past_sections.ftl @@ -1,4 +1,4 @@ They played: <#list pastSections as section> - <@format_instant_date_time instant=section.startedAt/> `${section.gameName}` - `${section.title}` +<@format_instant_date_time instant=section.startedAt/> `${section.gameName}` - `${section.title}` \ No newline at end of file