Exemplo n.º 1
0
        public async Task Link(string song)
        {
            if (!Program.Guilds.GetValueOrDefault(Context.Guild.Id).Music || Context.Message.Author.Id != Program.OwnerID)
            {
                await Context.Channel.SendMessageAsync("", false, Embed.GetEmbed("Music", "This guild is not authorised to use music")); return;
            }
            try
            {
                var tmp = await GetFromWeb.PullImageFromWebAsync(song);

                var dot     = song.LastIndexOf('.');
                var type    = song.Substring(dot, song.Length - dot);
                var slash   = song.LastIndexOf('/');
                var namelen = song.Length - slash - (Math.Abs(dot - song.Length));
                var name    = song.Substring(slash + 1, namelen - 1);
                if (!File.Exists($"{Program.Rootdir}\\Music\\{Program.CalculateMD5(tmp)}{type}"))
                {
                    await File.WriteAllBytesAsync($"{Program.Rootdir}\\Music\\{Program.CalculateMD5(tmp)}{type}", tmp);
                }
                var tmp2 = GetSong($"{Program.Rootdir}\\Music\\{Program.CalculateMD5(tmp)}{type}");
                if (tmp2 != null)
                {
                    name = tmp2;
                }
                await service.AddToQueue(Context.Guild, Context.Channel, $"{Program.Rootdir}\\Music\\{Program.CalculateMD5(tmp)}{type}", name);
            }
            catch (Exception e)
            {
                await ReplyAsync("", false, Embed.GetEmbed("Music", $"There was an error getting the file : {e.Message}"));
            }
        }
Exemplo n.º 2
0
        public async Task GetProfile(IGuildUser UserTag = null)
        {
            if (UserTag == null)
            {
                UserTag = Context.Message.Author as IGuildUser;
            }

            var tmp = await ReplyAsync("", false, Embed.GetEmbed("Profile", "Working..."));

            if (!File.Exists($"{Program.Rootdir}\\Users\\Profile\\{UserTag.Id}.gif"))
            {
                await tmp.ModifyAsync(x => x.Embed = Embed.GetEmbed("Profile", "You havn't uploaded a profile image yet"));

                return;
            }

            try
            {
                var avatar = await GetFromWeb.PullImageFromWebAsync(UserTag.GetAvatarUrl());

                string name   = UserTag.Nickname ?? UserTag.Username;
                var    tmpimg = await Profile.GetProfile(Program.Users.GetValueOrDefault(UserTag.Id), name, avatar);

                if (tmpimg.Length > 8000000)
                {
                    await tmp.ModifyAsync(x => x.Embed = Embed.GetEmbed("Get Profile", "File too big"));

                    GC.Collect();
                    return;
                }
                else
                {
                    var file = await CompressFile.CheckForDupesAndSave(tmpimg);

                    await Context.Message.Channel.SendFileAsync(file);

                    File.Delete(file);
                }
            }
            catch (Exception e)
            {
                await tmp.ModifyAsync(x => x.Embed = Embed.GetEmbed("Get Profile", e.Message));

                GC.Collect();
                return;
            }

            await tmp.ModifyAsync(x => x.Embed = Embed.GetEmbed("Get Profile", "Done"));

            System.Threading.Thread.Sleep(5000);
            await tmp.DeleteAsync();

            GC.Collect();
        }
Exemplo n.º 3
0
    public List <Features> featureList; // Title of dataset
    // public List<Coordinates> coordinates; // Title of dataset

    // Use this for initialization
    void Awake()
    {
        // Get the components we need
        getFromWeb  = gameObject.GetComponent <GetFromWeb>();
        itemSpawner = GameObject.FindWithTag("ItemSpawner");

        // populateData = itemSpawner.GetComponent<PopulateData>(); // Siesmic Spawner
        // populateLines = itemSpawner.GetComponent<PopulateLines>(); // Line Spawner
        populateMeshes = itemSpawner.GetComponent <PopulateMeshes>();

        proceduralBarGraphCube = itemSpawner.GetComponent <ProceduralBarGraphCube>();
    }
Exemplo n.º 4
0
        public async Task Upload()
        {
            if (!Program.Guilds.GetValueOrDefault(Context.Guild.Id).Music || Context.Message.Author.Id != Program.OwnerID)
            {
                await Context.Channel.SendMessageAsync("", false, Embed.GetEmbed("Music", "This guild is not authorised to use music")); return;
            }
            if (Context.Message.Attachments.Count() >= 1)
            {
                int count = 1;
                foreach (var item in Context.Message.Attachments)
                {
                    try
                    {
                        var tmp = await GetFromWeb.PullImageFromWebAsync(item.Url);

                        var dot  = item.Filename.LastIndexOf('.');
                        var type = item.Filename.Substring(dot, item.Filename.Length - dot);
                        var name = item.Filename.Substring(0, item.Filename.Length - type.Length);
                        if (!File.Exists($"{Program.Rootdir}\\Music\\{Program.CalculateMD5(tmp)}{type}"))
                        {
                            await File.WriteAllBytesAsync($"{Program.Rootdir}\\Music\\{Program.CalculateMD5(tmp)}{type}", tmp);
                        }
                        var tmp2 = GetSong($"{Program.Rootdir}\\Music\\{Program.CalculateMD5(tmp)}{type}");
                        if (tmp2 != null)
                        {
                            name = tmp2;
                        }
                        await service.AddToQueue(Context.Guild, Context.Channel, $"{Program.Rootdir}\\Music\\{Program.CalculateMD5(tmp)}{type}", name);
                    }
                    catch (Exception e)
                    {
                        await ReplyAsync("", false, Embed.GetEmbed("Music", $"There was an error getting the file : {e.Message}"));
                    }
                    count++;
                }
            }
            else
            {
            }
        }
Exemplo n.º 5
0
        public async Task Changeavatar(string PersonaName)
        {
            var img = Context.Message.Attachments.ElementAt(0);

            File.WriteAllBytes($"{Program.Rootdir}\\Personas\\{PersonaName}.png", await GetFromWeb.PullImageFromWebAsync(img.ProxyUrl));
            Discord.Image img2 = new Discord.Image($"{Program.Rootdir}\\Personas\\{PersonaName}.png");
            Program.persona.AddAsync(new string[] { PersonaName, $"{Program.Rootdir}\\Personas\\{PersonaName}.png" });
            try
            {
                await Context.Client.CurrentUser.ModifyAsync(x =>
                {
                    x.Avatar   = img2;
                    x.Username = PersonaName;
                });
                await ReplyAndDeleteAsync("", false, Embed.GetEmbed("**Avatar**", $"Avatar changed!"), new TimeSpan(0, 0, 15));
            }
            catch { await ReplyAndDeleteAsync("", false, Embed.GetEmbed("**Avatar**", $"Avatar added but could not be changed right now!"), new TimeSpan(0, 0, 15)); }
            img = null;
        }
Exemplo n.º 6
0
        public async Task UploadLevelUp(string ImageLink, string ResizeMode = "stretch")
        {
            if (Context.Message.Attachments.Count > 0)
            {
                await UploadLevelUp(ImageLink);

                return;
            }

            var tmp = await ReplyAsync("", false, Embed.GetEmbed("Set Levelup", "Working..."));

            try
            {
                switch (ResizeMode.ToLower())
                {
                case "stretch":
                    await File.WriteAllBytesAsync($"{Program.Rootdir}\\Users\\LevelUp\\{Context.Message.Author.Id}.gif", await Resize.ImageResizeStretchAsync(await GetFromWeb.PullImageFromWebAsync(ImageLink), 600, 240));

                    break;

                case "pad":
                    await File.WriteAllBytesAsync($"{Program.Rootdir}\\Users\\LevelUp\\{Context.Message.Author.Id}.gif", await Resize.ImageResizePadAsync(await GetFromWeb.PullImageFromWebAsync(ImageLink), 600, 240));

                    break;

                case "crop":
                    await File.WriteAllBytesAsync($"{Program.Rootdir}\\Users\\LevelUp\\{Context.Message.Author.Id}.gif", await Resize.ImageResizeCropAsync(await GetFromWeb.PullImageFromWebAsync(ImageLink), 600, 240));

                    break;

                default:
                    await File.WriteAllBytesAsync($"{Program.Rootdir}\\Users\\LevelUp\\{Context.Message.Author.Id}.gif", await Resize.ImageResizeStretchAsync(await GetFromWeb.PullImageFromWebAsync(ImageLink), 600, 240));

                    break;
                }
                Program.Users.GetValueOrDefault(Context.Message.Author.Id).changed = true;
                await Program.SaveUser(Context.Message.Author.Id);
            }
            catch
            {
                await tmp.ModifyAsync(x => x.Embed = Embed.GetEmbed("Set Levelup", "Sorry but you did not attach an image or link"));

                GC.Collect();
                return;
            }
            await tmp.ModifyAsync(x => x.Embed = Embed.GetEmbed("Set Levelup", "Done"));

            GC.Collect();
        }
Exemplo n.º 7
0
        public async Task UploadProfile(string ResizeMode = "stretch")
        {
            var tmp = await ReplyAsync("", false, Embed.GetEmbed("Set Profile", "Working..."));

            if (Context.Message.Attachments.Count > 0)
            {
                switch (ResizeMode.ToLower())
                {
                case "stretch":
                    await File.WriteAllBytesAsync($"{Program.Rootdir}\\Users\\Profile\\{Context.Message.Author.Id}.gif", await Resize.ImageResizeStretchAsync(await GetFromWeb.PullImageFromWebAsync(Context.Message.Attachments.First().ProxyUrl), 1200, 480));

                    break;

                case "pad":
                    await File.WriteAllBytesAsync($"{Program.Rootdir}\\Users\\Profile\\{Context.Message.Author.Id}.gif", await Resize.ImageResizePadAsync(await GetFromWeb.PullImageFromWebAsync(Context.Message.Attachments.First().ProxyUrl), 1200, 480));

                    break;

                case "crop":
                    await File.WriteAllBytesAsync($"{Program.Rootdir}\\Users\\Profile\\{Context.Message.Author.Id}.gif", await Resize.ImageResizeCropAsync(await GetFromWeb.PullImageFromWebAsync(Context.Message.Attachments.First().ProxyUrl), 1200, 480));

                    break;

                default:
                    await File.WriteAllBytesAsync($"{Program.Rootdir}\\Users\\Profile\\{Context.Message.Author.Id}.gif", await Resize.ImageResizeStretchAsync(await GetFromWeb.PullImageFromWebAsync(Context.Message.Attachments.First().ProxyUrl), 1200, 480));

                    break;
                }
            }
            else
            {
                await tmp.ModifyAsync(x => x.Embed = Embed.GetEmbed("Set Profile", "Sorry but you did not attach an image or link"));

                GC.Collect();
                return;
            }
            await tmp.ModifyAsync(x => x.Embed = Embed.GetEmbed("Set Profile", "Done"));

            GC.Collect();
        }