示例#1
0
 public static ChannelMessageView fromChannelMessage(ChannelMessage message)
 {
     return(message == null
         ? new ChannelMessageView()
         : new ChannelMessageView {
         id = message.id,
         nonce = getNonce(message.nonce),
         channelId = message.channelId,
         author = message.author,
         content = getContent(message.content, message.deletedTime.isNotEmpty(), message.attachments, message.embeds),
         fileSize = getFileSize(message.content, message.deletedTime.isNotEmpty(), message.attachments, message.embeds),
         width = getImageWidth(message.content, message.deletedTime.isNotEmpty(), message.attachments, message.embeds),
         height = getImageHeight(message.content, message.deletedTime.isNotEmpty(), message.attachments, message.embeds),
         time = DateConvert.DateTimeFromNonce(message.id),
         attachments = message.attachments,
         type = getType(message.content, message.deletedTime.isNotEmpty(), message.attachments, message.embeds),
         mentionEveryone = message.mentionEveryone,
         mentions = message.mentions,
         starred = message.starred,
         replyMessageIds = message.replyMessageIds,
         lowerMessageIds = message.lowerMessageIds,
         replyUsers = message.replyUsers,
         lowerUsers = message.lowerUsers,
         pending = message.pending,
         deleted = message.deletedTime != null,
         embeds = message.embeds,
         reactions = message.reactions
     });
 }
示例#2
0
 public static ChannelMessageView fromChannelMessageLite(ChannelMessageLite message)
 {
     return(message == null
         ? new ChannelMessageView()
         : new ChannelMessageView {
         id = message.id,
         nonce = getNonce(message.nonce),
         channelId = message.channelId,
         author = new User {
             id = message.author.id
         },
         content = getContent(message.content, message.deletedTime.isNotEmpty(), message.attachments),
         fileSize = getFileSize(message.content, message.deletedTime.isNotEmpty(), message.attachments),
         width = getImageWidth(message.content, message.deletedTime.isNotEmpty(), message.attachments),
         height = getImageHeight(message.content, message.deletedTime.isNotEmpty(), message.attachments),
         time = DateConvert.DateTimeFromNonce(message.id),
         attachments = message.attachments,
         type = getType(message.content, message.deletedTime.isNotEmpty(), message.attachments),
         mentionEveryone = message.mentionEveryone,
         mentions = message.mentions?.Select(user => new User {
             id = user.id
         }).ToList(),
         deleted = message.deletedTime != null
     });
 }
示例#3
0
 public static ChannelMessageView fromChannelMessageLite(ChannelMessageLite message)
 {
     return(message == null
         ? new ChannelMessageView()
         : new ChannelMessageView {
         id = message.id,
         nonce = getNonce(message.nonce),
         channelId = message.channelId,
         author = new User {
             id = message.author.id
         },
         content = getContent(message.content, message.deletedTime.isNotEmpty(), message.attachments),
         fileSize = getFileSize(message.content, message.deletedTime.isNotEmpty(), message.attachments),
         width = getImageWidth(message.content, message.deletedTime.isNotEmpty(), message.attachments),
         height = getImageHeight(message.content, message.deletedTime.isNotEmpty(), message.attachments),
         time = DateConvert.DateTimeFromNonce(message.id),
         attachments = message.attachments,
         type = getType(message.content, message.deletedTime.isNotEmpty(), message.attachments),
         mentionEveryone = message.mentionEveryone,
         mentions = message.mentions?.Select(user => new User {
             id = user.id
         }).ToList(),
         deleted = message.deletedTime != null,
         reactions = new List <Reaction>(),
         reactionsCountDict = new SortedDictionary <string, int>(),
         allUserReactionsDict = new Dictionary <string, Dictionary <string, int> >(),
         isGif = getImageIsGif(message.attachments)
     });
 }
示例#4
0
        public static ChannelMessageView fromChannelMessage(ChannelMessage message)
        {
            if (message == null)
            {
                return(new ChannelMessageView());
            }
            var allUserReactions = getAllUserReactions(message.reactions);

            return(new ChannelMessageView {
                id = message.id,
                nonce = getNonce(message.nonce),
                channelId = message.channelId,
                author = message.author,
                content = getContent(message.content, message.deletedTime.isNotEmpty(), message.attachments,
                                     message.embeds),
                fileSize = getFileSize(message.content, message.deletedTime.isNotEmpty(), message.attachments,
                                       message.embeds),
                width = getImageWidth(message.content, message.deletedTime.isNotEmpty(), message.attachments,
                                      message.embeds),
                height = getImageHeight(message.content, message.deletedTime.isNotEmpty(), message.attachments,
                                        message.embeds),
                time = DateConvert.DateTimeFromNonce(message.id),
                attachments = message.attachments,
                type = getType(message.content, message.deletedTime.isNotEmpty(), message.attachments,
                               message.embeds),
                mentionEveryone = message.mentionEveryone,
                mentions = message.mentions,
                starred = message.starred,
                replyMessageIds = message.replyMessageIds,
                lowerMessageIds = message.lowerMessageIds,
                replyUsers = message.replyUsers,
                lowerUsers = message.lowerUsers,
                pending = message.pending,
                deleted = message.deletedTime != null,
                embeds = message.embeds,
                reactions = message.reactions,
                allUserReactionsDict = allUserReactions,
                reactionsCountDict = getReactionsTotalCount(message.likeEmojiStats, allUserReactions),
                reactionsUsernameListDict = getReactionsUsernameDict(message.reactions),
                isGif = getImageIsGif(message.attachments)
            });
        }