From 1d67e9d1ed15405e610adf101500f517f04fa7e9 Mon Sep 17 00:00:00 2001 From: cauuchy <75664176+cauuchy@users.noreply.github.com> Date: Sat, 12 Jun 2021 16:22:34 +0900 Subject: [PATCH] =?UTF-8?q?HTML5=E3=82=B3=E3=83=A1=E3=82=B8=E3=82=A7?= =?UTF-8?q?=E3=83=8D=E4=B8=8A=E3=81=A7=E3=83=A6=E3=83=BC=E3=82=B6=E3=82=A2?= =?UTF-8?q?=E3=82=A4=E3=82=B3=E3=83=B3=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=83=91=E3=83=A9?= =?UTF-8?q?=E3=83=A1=E3=83=BC=E3=82=BF=E3=82=92=E8=BF=BD=E5=8A=A0=E3=83=BB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CommentGeneratorPlugin/main.cs | 94 +++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/CommentGeneratorPlugin/main.cs b/CommentGeneratorPlugin/main.cs index 73549104..51cb3845 100644 --- a/CommentGeneratorPlugin/main.cs +++ b/CommentGeneratorPlugin/main.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -40,6 +40,7 @@ public string Description public IPluginHost Host { get; set; } class Data { + public string IconUrl { get; internal set; } public string Comment { get; internal set; } public string SiteName { get; internal set; } public string Nickname { get; internal set; } @@ -82,6 +83,10 @@ public void OnMessageReceived(ISiteMessage message, IMessageMetadata messageMeta { name = messageMetadata.User.Nickname; } + + // 2021/06/12 HTML5コメジェネ上でアイコンを表示できるパラメータを追加 + var iconUrl = EmbedIconUrl(message); + //var data = new Data //{ // Comment = comment.CommentItems.ToText(), @@ -90,6 +95,7 @@ public void OnMessageReceived(ISiteMessage message, IMessageMetadata messageMeta //}; var data = new Data { + IconUrl = iconUrl, Comment = comment, Nickname = name, SiteName = siteName, @@ -235,6 +241,7 @@ public void Write() foreach (var data in arr) { var item = new XElement("comment", data.Comment); + item.SetAttributeValue("icon_url", data.IconUrl); item.SetAttributeValue("no", "0"); item.SetAttributeValue("time", ToUnixTime(GetCurrentDateTime())); item.SetAttributeValue("owner", 0); @@ -334,5 +341,90 @@ public void OnTopmostChanged(bool isTopmost) _settingsView.Topmost = isTopmost; } } + + private string EmbedIconUrl(ISiteMessage message) + { + string str = ""; + + if (message is YouTubeLiveSitePlugin.IYouTubeLiveMessage youtubeMessage) + { + if (youtubeMessage is YouTubeLiveSitePlugin.IYouTubeLiveComment simpleComment) + { + str = simpleComment.UserIcon.Url; + } + } + else if (message is TwitchSitePlugin.ITwitchMessage twitchMessage) + { + if (twitchMessage is TwitchSitePlugin.ITwitchComment simpleComment) + { + str = simpleComment.UserIcon.Url; + } + } + else if (message is OpenrecSitePlugin.IOpenrecMessage openrecMessage) + { + if (openrecMessage is OpenrecSitePlugin.IOpenrecComment simpleComment) + { + str = "https://dqd0jw5gvbchn.cloudfront.net/tv/v9.18.0/static/images/favicons/favicon.ico"; + } + } + else if (message is NicoSitePlugin.INicoMessage nicoMessage) + { + if (nicoMessage is NicoSitePlugin.INicoComment simpleComment) + { + str = simpleComment.ThumbnailUrl; + } + } + else if (message is TwicasSitePlugin.ITwicasMessage twicasMessage) + { + if (twicasMessage is TwicasSitePlugin.ITwicasComment simpleComment) + { + str = simpleComment.UserIcon.Url; + } + } + else if (message is MildomSitePlugin.IMildomMessage mildomMessage) + { + if (mildomMessage is MildomSitePlugin.IMildomComment simpleComment) + { + str = "https://wia.mildom.com/assets/static/default_avatar.png"; + } + } + else if (message is WhowatchSitePlugin.IWhowatchMessage whowatchMessage) + { + if (whowatchMessage is WhowatchSitePlugin.IWhowatchComment simpleComment) + { + str = simpleComment.UserIcon.Url; + } + } + else if (message is MirrativSitePlugin.IMirrativMessage mirrativMessage) + { + if (mirrativMessage is MirrativSitePlugin.IMirrativComment simpleComment) + { + str = "https://www.mirrativ.co.jp/images/favicon.ico"; + } + } + else if (message is LineLiveSitePlugin.ILineLiveMessage lineliveMessage) + { + if (lineliveMessage is LineLiveSitePlugin.ILineLiveComment simpleComment) + { + str = simpleComment.UserIconUrl; + } + } + else if (message is ShowRoomSitePlugin.IShowRoomMessage showRoomMessage) + { + if (showRoomMessage is ShowRoomSitePlugin.IShowRoomComment simpleComment) + { + str = "https://www.showroom-live.com/assets/img/v3/apple-touch-icon.png"; + } + } + else if (message is BigoSitePlugin.IBigoMessage bigoMessage) + { + if (bigoMessage is BigoSitePlugin.IBigoComment simpleComment) + { + str = "https://www.bigo.tv/favicon.ico"; + } + } + + return str; + } } }