internal void Update(MessageInfo model) { if (model.Attachments != null) { Attachments = model.Attachments .Select(x => new Attachment(x.Id, x.Url, x.ProxyUrl, x.Width, x.Height, x.Size, x.Filename)) .ToArray(); } if (model.Embeds != null) { Embeds = model.Embeds.Select(x => { EmbedReference author = null, provider = null; File thumbnail = null; if (x.Author != null) { author = new EmbedReference(x.Author.Url, x.Author.Name); } if (x.Provider != null) { provider = new EmbedReference(x.Provider.Url, x.Provider.Name); } if (x.Thumbnail != null) { thumbnail = new File(x.Thumbnail.Url, x.Thumbnail.ProxyUrl, x.Thumbnail.Width, x.Thumbnail.Height); } return(new Embed(x.Url, x.Type, x.Title, x.Description, author, provider, thumbnail)); }).ToArray(); } if (model.IsMentioningEveryone != null) { IsMentioningEveryone = model.IsMentioningEveryone.Value; } 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) { Mentions = model.Mentions.Select(x => _client.Users[x.Id, Channel.Server?.Id]).ToArray(); IsMentioningMe = model.Mentions.Any(x => x.Id == _client.CurrentUserId); } if (model.Content != null) { RawText = model.Content; _cleanText = null; } }
internal Embed(string url, string type, string title, string description, EmbedReference author, EmbedReference provider, File thumbnail) { Url = url; Type = type; Title = title; Description = description; Author = author; Provider = provider; Thumbnail = thumbnail; }
internal Embed(string url, string type, string title, string description, EmbedReference author, EmbedReference provider, File thumbnail) { Url = url; Type = type; Title = title; Description = description; Author = author; Provider = provider; Thumbnail = thumbnail; }
public void UpdateReference(EmbedReference embedRef, string value, string guild = "0") { embedRef.EmbedEntry = Update(embedRef.Slug, embedRef.Property, value, guild); }
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 => { EmbedReference author = null, provider = null; File thumbnail = null; if (x.Author != null) { author = new EmbedReference { Url = x.Author.Url, Name = x.Author.Name } } ; if (x.Provider != null) { provider = new EmbedReference { 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 } } ; return(new Embed { Url = x.Url, Type = x.Type, Title = x.Title, Description = x.Description, Author = author, Provider = provider, Thumbnail = thumbnail }); }).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.GetUser(x.Id)) .Where(x => x != null) .ToArray(); } if (model.IsMentioningEveryone != null) { if (model.IsMentioningEveryone.Value && 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(API.Message model) { if (model.Attachments != null) { Attachments = model.Attachments .Select(x => new Attachment(x.Id, x.Url, x.ProxyUrl, x.Width, x.Height, x.Size, x.Filename)) .ToArray(); } if (model.Embeds != null) { Embeds = model.Embeds.Select(x => { EmbedReference author = null, provider = null; File thumbnail = null; if (x.Author != null) author = new EmbedReference(x.Author.Url, x.Author.Name); if (x.Provider != null) provider = new EmbedReference(x.Provider.Url, x.Provider.Name); if (x.Thumbnail != null) thumbnail = new File(x.Thumbnail.Url, x.Thumbnail.ProxyUrl, x.Thumbnail.Width, x.Thumbnail.Height); return new Embed(x.Url, x.Type, x.Title, x.Description, author, provider, thumbnail); }).ToArray(); } if (model.IsMentioningEveryone != null) IsMentioningEveryone = model.IsMentioningEveryone.Value; 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) { MentionIds = model.Mentions.Select(x => x.Id)?.ToArray(); IsMentioningMe = MentionIds.Contains(_client.CurrentUserId); } if (model.Content != null) { RawText = model.Content; _cleanText = null; } }
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 => { EmbedReference author = null, provider = null; File thumbnail = null; if (x.Author != null) author = new EmbedReference { Url = x.Author.Url, Name = x.Author.Name }; if (x.Provider != null) provider = new EmbedReference { 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 }; return new Embed { Url = x.Url, Type = x.Type, Title = x.Title, Description = x.Description, Author = author, Provider = provider, Thumbnail = thumbnail }; }).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.GetUser(x.Id)) .Where(x => x != null) .ToArray(); } if (model.IsMentioningEveryone != null) { if (model.IsMentioningEveryone.Value && 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; } }
private string RefLabel(EmbedReference embedReference) { return(embedReference.Slug + (embedReference.Property == null ? "" : "." + embedReference.Property)); }