public WaveStream ThisA(EditNull n, IMessage m)
        {
            string url;

            try
            {
                url = m.Attachments.FirstOrDefault(x => x.Url.EndsWith(".mp3")).Url;
                if (!string.IsNullOrWhiteSpace(url))
                {
                    return(url.GetMp3AudioFromURL());
                }
            }
            catch { }

            try
            {
                url = m.Attachments.FirstOrDefault(x => x.Url.EndsWith(".wav")).Url;
                if (!string.IsNullOrWhiteSpace(url))
                {
                    return(url.GetwavAudioFromURL());
                }
            } catch { }

            //url = m.Attachments.FirstOrDefault(x => x.Url.EndsWith(".ogg")).Url;
            //if (!string.IsNullOrWhiteSpace(url))
            //    return url.GetoggAudioFromURL();

            throw new Exception("No audio file found!");
        }
        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");
        }
 public Gif EmoteG(EditNull n, IMessage m, string emote)
 {
     Discord.Emote.TryParse(emote.Trim(' '), out Emote res);
     if (res != null)
     {
         return((Gif)res.Url.GetBitmapsAndTimingsFromGIFURL());
     }
     return((Gif)Program.GetGuildFromChannel(m.Channel).Emotes.
            FirstOrDefault(x => x.Name.Contains(emote.Trim(' ', ':')) && x.Animated).Url.
            GetBitmapsAndTimingsFromGIFURL());
 }
 public Bitmap Emote(EditNull n, IMessage m, string emote)
 {
     Discord.Emote.TryParse(emote.Trim(' '), out Emote res);
     if (res != null)
     {
         return(res.Url.GetBitmapFromURL());
     }
     return(Program.GetGuildFromChannel(m.Channel).Emotes.
            FirstOrDefault(x => x.Name.Contains(emote.Trim(' ', ':'))).Url.
            GetBitmapFromURL());
 }
 public Bitmap ServerPic(EditNull n, IMessage m, string ServerID)
 {
     if (ServerID == "")
     {
         return(Program.GetGuildFromChannel(m.Channel).IconUrl.GetBitmapFromURL());
     }
     else
     {
         return(Program.GetGuildFromID(Convert.ToUInt64(ServerID.Trim(new char[] { ' ', '<', '>', '@', '!' }))).IconUrl.GetBitmapFromURL());
     }
 }
        public IMessage GetTweet(EditNull n, IMessage m, string tweetID)
        {
            long id = Convert.ToInt64(tweetID.Split('/').Last().Split('?').First());

            var channel = new TwitterChannel(Program.twitterService.GetTweet(new GetTweetOptions()
            {
                Id = id, IncludeEntities = true
            }), Program.twitterService);

            return(channel.InitialMessage);
        }
        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);
        }
        public IMessage LastM(EditNull n, IMessage m, int messagesToSkip = 0)
        {
            var messages = DiscordNETWrapper.EnumerateMessages(m.Channel).Skip(1 + messagesToSkip);
            var debug    = messages.Take(50);

            foreach (var lm in debug)
            {
                try { return(lm); }
                catch { }
            }
            throw new Exception("Didn't find any");
        }
 public Bitmap MyProfilePic(EditNull n, IMessage m)
 {
     if (m is TwitterMessage)
     {
         string url = (m as TwitterMessage).Author.GetAvatarUrl();
         return(url.GetBitmapFromURL());
     }
     else
     {
         string avatarURL = m.Author.GetAvatarUrl(ImageFormat.Png, 512);
         return((string.IsNullOrWhiteSpace(avatarURL) ? m.Author.GetDefaultAvatarUrl() : avatarURL).GetBitmapFromURL());
     }
 }
        public WaveStream AudioFromYT(EditNull n, IMessage m, string YouTubeVideoURL)
        {
            if (m.Author.Id != Program.Master.Id)
            {
                throw new Exception("u r not allowed");
            }

            MemoryStream mem = new MemoryStream();

            using Process P = MultiMediaHelper.GetAudioStreamFromYouTubeVideo(YouTubeVideoURL, "mp3");
            P.StandardOutput.BaseStream.CopyTo(mem);
            return(WaveFormatConversionStream.CreatePcmStream(new StreamMediaFoundationReader(mem)));
        }
        public Gif LastG(EditNull n, IMessage m, int messagesToSkip = 0)
        {
            var messages = DiscordNETWrapper.EnumerateMessages(m.Channel).Skip(1 + messagesToSkip);

            foreach (var lm in messages)
            {
                try
                {
                    return(GetPictureLinkFromMessage(lm, "").GetBitmapsAndTimingsFromGIFURL());
                }
                catch { }
            }
            throw new Exception("Didn't find any");
        }
        public string LastT(EditNull n, IMessage m, int messagesToSkip = 0)
        {
            var messages = DiscordNETWrapper.EnumerateMessages(m.Channel).Skip(1 + messagesToSkip);

            foreach (var lm in messages)
            {
                if (!string.IsNullOrWhiteSpace(lm.Content))
                {
                    try { return(lm.Content); }
                    catch { }
                }
            }
            throw new Exception("Didn't find any");
        }
        public Bitmap Mandelbrot(EditNull n, IMessage m, double zoom = 1, Vector2 camera = new Vector2(), int passes = 40)
        {
            Bitmap bmp = new Bitmap(500, 500);

            if (passes > 200)
            {
                throw new Exception("200 passes should be enough, everything else would be spam and you dont wanna spam");
            }

            zoom = Math.Pow(2, -zoom);

            using (UnsafeBitmapContext con = new UnsafeBitmapContext(bmp))
                for (int x = 0; x < bmp.Width; x++)
                {
                    for (int y = 0; y < bmp.Height; y++)
                    {
                        double cre = (2 * ((x / (double)bmp.Width) - 0.5)) * zoom - camera.X;
                        double cim = (2 * ((y / (double)bmp.Height) - 0.5)) * zoom - camera.Y;

                        double x2 = 0, y2 = 0;
                        int    count = 0;

                        for (int i = 0; i < passes; i++)
                        {
                            if (x2 * x2 + y2 * y2 < 1)
                            {
                                count++;
                            }

                            double xtemp = x2 * x2 - y2 * y2 + cre;
                            y2 = 2 * x2 * y2 + cim;
                            x2 = xtemp;
                        }

                        var float4 = HSVtoRGB((float)((Math.Atan2(y2, x2) + Math.PI) / (Math.PI * 2) * 360), 1, count * 10);
                        con.SetPixel(x, y, Color.FromArgb((x2 + y2 < 1000 ? 255 : 0), (int)(float4.X * 255), (int)(float4.Y * 255), (int)(float4.Z * 255)));
                    }
                }

            return(bmp);
        }
 public double Sin(EditNull n, IMessage m, double a) => Math.Sin(a);
 public double Log(EditNull n, IMessage m, double a, double b) => Math.Log(a, b);
 public double Sqrt(EditNull n, IMessage m, double a) => Math.Sqrt(a);
 public double Pow(EditNull n, IMessage m, double a, double b) => Math.Pow(a, b);
 public double Div(EditNull n, IMessage m, double a, double b) => a / b;
 public double Mult(EditNull n, IMessage m, double a, double b) => a * b;
 public double Sub(EditNull n, IMessage m, double a, double b) => a - b;
Beispiel #21
0
 public Color Lerp(EditNull n, IMessage m, Color a, Color b, float l)
 {
     return(a.Lerp(b, l));
 }
 public double RdmDouble(EditNull n, IMessage m) => rdm.NextDouble();
 public double E(EditNull n, IMessage m) => Math.E;
 public double Cos(EditNull n, IMessage m, double a) => Math.Cos(a);
 public double Pi(EditNull n, IMessage m) => Math.PI;
Beispiel #26
0
 public Color Red(EditNull n, IMessage m)
 {
     return(Color.Red);
 }
 public double Rdm(EditNull n, IMessage m, int l = 0, int h = int.MaxValue) => rdm.Next(l, h);
Beispiel #28
0
 public Color Col(EditNull n, IMessage m, byte r, byte g, byte b)
 {
     return(Color.FromArgb(r, g, b));
 }
 public double Add(EditNull n, IMessage m, double a, double b) => a + b;
Beispiel #30
0
 public Color ColName(EditNull n, IMessage m, string name)
 {
     return(Color.FromName(name));
 }