internal void Update(APIMessage model) { var channel = Channel; var server = channel.Server; if (model.Attachments != null) { Attachments = model.Attachments .Select(x => new Attachment() { Id = x.Id, Url = x.Url, ProxyUrl = x.ProxyUrl, Width = x.Width, Height = x.Height, Size = x.Size, Filename = x.Filename }) .ToArray(); } if (model.Embeds != null) { Embeds = model.Embeds.Select(x => { EmbedLink author = null, provider = null; File thumbnail = null, video = null; if (x.Author != null) author = new EmbedLink { Url = x.Author.Url, Name = x.Author.Name }; if (x.Provider != null) provider = new EmbedLink { Url = x.Provider.Url, Name = x.Provider.Name }; if (x.Thumbnail != null) thumbnail = new File { Url = x.Thumbnail.Url, ProxyUrl = x.Thumbnail.ProxyUrl, Width = x.Thumbnail.Width, Height = x.Thumbnail.Height }; if (x.Video != null) video = new File { Url = x.Video.Url, ProxyUrl = null, Width = x.Video.Width, Height = x.Video.Height }; return new Embed { Url = x.Url, Type = x.Type, Title = x.Title, Description = x.Description, Author = author, Provider = provider, Thumbnail = thumbnail, Video = video }; }).ToArray(); } if (model.IsTextToSpeech != null) IsTTS = model.IsTextToSpeech.Value; if (model.Timestamp != null) Timestamp = model.Timestamp.Value; if (model.EditedTimestamp != null) EditedTimestamp = model.EditedTimestamp; if (model.Mentions != null) { MentionedUsers = model.Mentions .Select(x => Channel.GetUserFast(x.Id)) .Where(x => x != null) .ToArray(); } if (model.Content != null) { string text = model.Content; RawText = text; //var mentionedUsers = new List<User>(); var mentionedChannels = new List<Channel>(); var mentionedRoles = new List<Role>(); text = CleanUserMentions(Channel, text/*, mentionedUsers*/); if (server != null) { text = CleanChannelMentions(Channel, text, mentionedChannels); text = CleanRoleMentions(Channel, text, mentionedRoles); if (model.IsMentioningEveryone != null && model.IsMentioningEveryone.Value && User != null && User.GetPermissions(channel).MentionEveryone) mentionedRoles.Add(Server.EveryoneRole); } Text = text; //MentionedUsers = mentionedUsers; MentionedChannels = mentionedChannels; MentionedRoles = mentionedRoles; } }
internal void Update(APIMessage model) { var channel = Channel; var server = channel.Server; if (model.Attachments != null) { Attachments = model.Attachments .Select(x => new Attachment() { Id = x.Id, Url = x.Url, ProxyUrl = x.ProxyUrl, Width = x.Width, Height = x.Height, Size = x.Size, Filename = x.Filename }) .ToArray(); } if (model.Embeds != null) { Embeds = model.Embeds.Select(x => { EmbedLink author = null, provider = null; File thumbnail = null, video = null; if (x.Author != null) { author = new EmbedLink { Url = x.Author.Url, Name = x.Author.Name } } ; if (x.Provider != null) { provider = new EmbedLink { Url = x.Provider.Url, Name = x.Provider.Name } } ; if (x.Thumbnail != null) { thumbnail = new File { Url = x.Thumbnail.Url, ProxyUrl = x.Thumbnail.ProxyUrl, Width = x.Thumbnail.Width, Height = x.Thumbnail.Height } } ; if (x.Video != null) { video = new File { Url = x.Video.Url, ProxyUrl = null, Width = x.Video.Width, Height = x.Video.Height } } ; return(new Embed { Url = x.Url, Type = x.Type, Title = x.Title, Description = x.Description, Author = author, Provider = provider, Thumbnail = thumbnail, Video = video }); }).ToArray(); } if (model.IsTextToSpeech != null) { IsTTS = model.IsTextToSpeech.Value; } if (model.Timestamp != null) { Timestamp = model.Timestamp.Value; } if (model.EditedTimestamp != null) { EditedTimestamp = model.EditedTimestamp; } if (model.Mentions != null) { MentionedUsers = model.Mentions .Select(x => Channel.GetUserFast(x.Id)) .Where(x => x != null) .ToArray(); } if (model.IsMentioningEveryone != null) { if (model.IsMentioningEveryone.Value && User != null && User.GetPermissions(channel).MentionEveryone) { MentionedRoles = new Role[] { Server.EveryoneRole } } ; else { MentionedRoles = new Role[0]; } } if (model.Content != null) { string text = model.Content; RawText = text; //var mentionedUsers = new List<User>(); var mentionedChannels = new List <Channel>(); //var mentionedRoles = new List<Role>(); text = CleanUserMentions(Channel, text /*, mentionedUsers*/); if (server != null) { text = CleanChannelMentions(Channel, text, mentionedChannels); //text = CleanRoleMentions(_client, User, channel, text, mentionedRoles); } Text = text; //MentionedUsers = mentionedUsers; MentionedChannels = mentionedChannels; //MentionedRoles = mentionedRoles; } }
internal void Update(APIMessage model) { var channel = Channel; if (model.Attachments != null) { Attachments = model.Attachments .Select(x => new Attachment() { Id = x.Id, Url = x.Url, ProxyUrl = x.ProxyUrl, Width = x.Width, Height = x.Height, Size = x.Size, Filename = x.Filename }) .ToArray(); } if (model.Embeds != null) { Embeds = model.Embeds.Select(x => { EmbedLink author = null, provider = null; File thumbnail = null, video = null; if (x.Author != null) { author = new EmbedLink { Url = x.Author.Url, Name = x.Author.Name } } ; if (x.Provider != null) { provider = new EmbedLink { Url = x.Provider.Url, Name = x.Provider.Name } } ; if (x.Thumbnail != null) { thumbnail = new File { Url = x.Thumbnail.Url, ProxyUrl = x.Thumbnail.ProxyUrl, Width = x.Thumbnail.Width, Height = x.Thumbnail.Height } } ; if (x.Video != null) { video = new File { Url = x.Video.Url, ProxyUrl = null, Width = x.Video.Width, Height = x.Video.Height } } ; return(new Embed { Url = x.Url, Type = x.Type, Title = x.Title, Description = x.Description, Author = author, Provider = provider, Thumbnail = thumbnail, Video = video }); }).ToArray(); } if (model.IsTextToSpeech != null) { IsTTS = model.IsTextToSpeech.Value; } if (model.Timestamp != null) { Timestamp = model.Timestamp.Value; } if (model.EditedTimestamp != null) { EditedTimestamp = model.EditedTimestamp; } if (model.Mentions != null) { MentionedUsers = model.Mentions .Select(x => (Channel as Channel).GetUser(x.Id)) .Where(x => x != null) .ToArray(); } if (model.IsMentioningEveryone != null) { var server = (channel as PublicChannel).Server; if (model.IsMentioningEveryone.Value && server != null) { MentionedRoles = new Role[] { server.EveryoneRole } } ; else { MentionedRoles = Enumerable.Empty <Role>(); } } if (model.Content != null) { string text = model.Content; RawText = text; List <PublicChannel> mentionedChannels = null; if (Channel.IsPublic) { mentionedChannels = new List <PublicChannel>(); } text = CleanUserMentions(Channel as PublicChannel, text); text = CleanChannelMentions(Channel as PublicChannel, text, mentionedChannels); if (Channel.IsPublic) { MentionedChannels = mentionedChannels; } Text = text; } }