예제 #1
0
        private static Message ToMessage(IUserMessage message)
        {
            var attachment = message.Attachments.FirstOrDefault();
            var attachUrl  = attachment?.Url;

            if (attachUrl != null)
            {
                var ext = Path.GetExtension(attachUrl);
                if (ext == ".png" || ext == ".gif" || ext == ".jpg" || ext == ".jpeg")
                {
                    attachUrl = attachment.ProxyUrl;
                }
            }

            return(new Message
            {
                MessageId = message.Id,
                UserId = message.Author.Id,
                Content = message.Resolve(),
                Attachment = attachUrl
            });
        }