diff --git a/TwitchSitePlugin/CommentProvider.cs b/TwitchSitePlugin/CommentProvider.cs index 43f26a8d..2896e4c1 100644 --- a/TwitchSitePlugin/CommentProvider.cs +++ b/TwitchSitePlugin/CommentProvider.cs @@ -325,17 +325,22 @@ private void OnMessageReceived(Result result) { var commentData = ParsePrivMsg(result); var userId = commentData.UserId; + var displayName = commentData.DisplayName; var isFirstComment = _commentCounter.UpdateCount(userId); var user = GetUser(userId); if (_siteOptions.NeedAutoSubNickname) { SitePluginCommon.Utils.SetNickname(commentData.Message, user, _siteOptions.NeedAutoSubNicknameStr); } + if (displayName != commentData.Username) + { + displayName += " (" + commentData.Username + ")"; + } var message = new TwitchComment(result.Raw) { CommentItems = Tools.GetMessageItems(result), Id = commentData.Id, - NameItems = new List { MessagePartFactory.CreateMessageText(commentData.Username) }, + NameItems = new List { MessagePartFactory.CreateMessageText(displayName) }, PostTime = commentData.SentAt.ToString("HH:mm:ss"), UserId = commentData.UserId, }; @@ -497,6 +502,7 @@ class CommentData : ICommentData { public string UserId { get; set; } public string Username { get; set; } + public string DisplayName { get; set; } public string Message { get; set; } public string Emotes { get; set; } public string Id { get; set; } diff --git a/TwitchSitePlugin/ICommentData.cs b/TwitchSitePlugin/ICommentData.cs index 3b2c202a..72ed0fbc 100644 --- a/TwitchSitePlugin/ICommentData.cs +++ b/TwitchSitePlugin/ICommentData.cs @@ -7,6 +7,7 @@ interface ICommentData string Message { get; } string UserId { get; } string Username { get; } + string DisplayName { get; } System.DateTime SentAt { get; } } } \ No newline at end of file diff --git a/TwitchSitePlugin/Tools.cs b/TwitchSitePlugin/Tools.cs index e64827bf..4417e161 100644 --- a/TwitchSitePlugin/Tools.cs +++ b/TwitchSitePlugin/Tools.cs @@ -39,6 +39,10 @@ public static ICommentData ParsePrivMsg(Result result) { commentData.UserId = userId; } + if (result.Tags.TryGetValue("display-name", out string displayName)) + { + commentData.DisplayName = displayName; + } if(result.Tags.TryGetValue("tmi-sent-ts", out string ts)) { var unix = new DateTime(1970, 1, 1).AddMilliseconds(long.Parse(ts)); diff --git a/TwitchSitePlugin/TwitchCommentViewModel.cs b/TwitchSitePlugin/TwitchCommentViewModel.cs index d75eea74..a8adb2b0 100644 --- a/TwitchSitePlugin/TwitchCommentViewModel.cs +++ b/TwitchSitePlugin/TwitchCommentViewModel.cs @@ -8,6 +8,7 @@ class TwitchCommentViewModel : CommentViewModelBase { public override MessageType MessageType { get; protected set; } public override string UserId { get; } + public string DisplayName { get; } private readonly ITwitchSiteOptions _siteOptions; public TwitchCommentViewModel(ICommentOptions options, ITwitchSiteOptions siteOptions, ICommentData commentData, bool isFirstComment, ICommentProvider commentProvider, IUser user) @@ -17,6 +18,7 @@ public TwitchCommentViewModel(ICommentOptions options, ITwitchSiteOptions siteOp _siteOptions = siteOptions; Id = commentData.Id; UserId = commentData.UserId; + DisplayName = commentData.DisplayName; PostTime = commentData.SentAt.ToString("HH:mm:ss"); var name = commentData.Username;