Ejemplo n.º 1
0
        public Bitmap LastP(EditNull n, IMessage m, int messagesToSkip = 0)
        {
            var messages = DiscordNETWrapper.EnumerateMessages(m.Channel).Skip(1 + messagesToSkip);

            foreach (var lm in messages)
            {
                try
                {
                    string pic = null;
                    if (lm.Attachments.Count > 0 && lm.Attachments.ElementAt(0).Size > 0)
                    {
                        if (lm.Attachments.ElementAt(0).Filename.EndsWith(".png") ||
                            lm.Attachments.ElementAt(0).Filename.EndsWith(".jpeg") ||
                            lm.Attachments.ElementAt(0).Filename.EndsWith(".jpg"))
                        {
                            pic = lm.Attachments.ElementAt(0).Url;
                        }
                    }
                    string picLink = lm.Content.GetPictureLinkInMessage();
                    if (string.IsNullOrWhiteSpace(pic) && picLink != null)
                    {
                        pic = picLink;
                    }
                    var b = pic.GetBitmapFromURL();
                    if ((long)b.Width * b.Height > maxImagePixelSize)
                    {
                        var mult = Math.Sqrt(maxImagePixelSize / ((double)b.Width * b.Height));
                        b = PictureCommands.StretchM(b, m, (float)mult, (float)mult);
                    }
                    return(b);
                }
                catch { }
            }
            throw new Exception("Didn't find any");
        }
Ejemplo n.º 2
0
        public Bitmap ThisP(EditNull n, IMessage m, string PictureURL = "")
        {
            var b = GetPictureLinkFromMessage(m, PictureURL).GetBitmapFromURL();

            if ((long)b.Width * b.Height > maxImagePixelSize)
            {
                var mult = Math.Sqrt(maxImagePixelSize / ((double)b.Width * b.Height));
                b = PictureCommands.StretchM(b, m, (float)mult, (float)mult);
            }
            return(b);
        }
Ejemplo n.º 3
0
        public Gif Pat(Bitmap b, IMessage m)
        {
            Bitmap[] pats = new Bitmap[5];
            for (int i = 1; i <= 5; i++)
            {
                var patDesignPath  = $"Commands{s}Edit{s}Resources{s}pat{s}{i}d.png";
                var patOverlayPath = $"Commands{s}Edit{s}Resources{s}pat{s}{i}o.png";
                pats[i - 1] = PictureCommands.InsertIntoRect(b, m, (Bitmap)Bitmap.FromFile(patDesignPath), (Bitmap)Bitmap.FromFile(patOverlayPath), false);
            }
            int[] patTimings = new int[] { 40, 40, 40, 40, 40 };

            pats = pats.Select(x => (Bitmap)x.Stretch(new Size(128, 128))).ToArray();

            return(new Gif(pats, patTimings));
        }