Пример #1
0
 private MirrativMessageContext CreateMessageContext(IMirrativMessage message)
 {
     if (message is IMirrativComment comment)
     {
         var userId  = comment.UserId;
         var isFirst = _first.IsFirstComment(userId);
         var user    = GetUser(userId);
         //var comment = new MirrativComment(message, raw);
         var metadata = new CommentMessageMetadata(comment, _options, _siteOptions, user, this, isFirst)
         {
             IsInitialComment = false,
             SiteContextGuid  = SiteContextGuid,
         };
         var methods = new MirrativMessageMethods();
         if (_siteOptions.NeedAutoSubNickname)
         {
             var messageText = message.CommentItems.ToText();
             var nick        = SitePluginCommon.Utils.ExtractNickname(messageText);
             if (!string.IsNullOrEmpty(nick))
             {
                 user.Nickname = nick;
             }
         }
         return(new MirrativMessageContext(comment, metadata, methods));
     }
     else if (message is IMirrativJoinRoom join && _siteOptions.IsShowJoinMessage)
     {
         var userId   = join.UserId;
         var user     = GetUser(userId);
         var metadata = new JoinMessageMetadata(join, _options, _siteOptions, user, this)
         {
             IsInitialComment = false,
             SiteContextGuid  = SiteContextGuid,
         };
         var methods = new MirrativMessageMethods();
         return(new MirrativMessageContext(join, metadata, methods));
     }
Пример #2
0
        private MirrativMessageContext CreateMessageContext(Message message, bool isInitialComment, string raw)
        {
            var userId   = message.UserId;
            var isFirst  = _first.IsFirstComment(userId);
            var user     = GetUser(userId);
            var comment  = new MirrativComment(message, raw);//InitialCommentにギフトが含まれている場合があったらバグ。
            var metadata = new CommentMessageMetadata(comment, _options, _siteOptions, user, this, isFirst)
            {
                IsInitialComment = isInitialComment,
                SiteContextGuid  = SiteContextGuid,
            };
            var methods = new MirrativMessageMethods();

            if (_siteOptions.NeedAutoSubNickname)
            {
                var messageText = message.Comment;
                var nick        = SitePluginCommon.Utils.ExtractNickname(messageText);
                if (!string.IsNullOrEmpty(nick))
                {
                    user.Nickname = nick;
                }
            }
            return(new MirrativMessageContext(comment, metadata, methods));
        }