Exemple #1
0
        public async Task HankImagesAsync([Remainder][Summary("Text to project onto the canvas. If a number is supplied, number of times to repeat the projection instead.")] string text = null)
        {
            IReadOnlyCollection <Attachment> attachments = await AttachmentHelper.GetMostRecentAttachmentsAsync(Context, AttachmentFilter.Images);

            if (attachments == null && text == null)
            {
                await ServiceReplyAsync(NO_ATTACHMENTS_FOUND_MESSAGE);

                return;
            }

            ParamType     paramType = ParseParamType(text);
            List <string> images    = new List <string>();

            switch (paramType)
            {
            case ParamType.Numeric:
                images = _imageService.HankImages(attachments, uint.Parse(text));
                await SendImages(images);

                break;

            case ParamType.Text:
                string textImg = _imageService.HankText(text);
                await SendImage(textImg);

                break;

            case ParamType.None:
                images = _imageService.HankImages(attachments);
                await SendImages(images);

                break;
            }
        }
Exemple #2
0
        public async Task AddSong([Summary("alias to use when playing this song in the future")] string alias)
        {
            IReadOnlyCollection <Attachment> atts = await AttachmentHelper.GetMostRecentAttachmentsAsync(Context, AttachmentFilter.Media);

            if (atts == null)
            {
                throw new NullReferenceException("No media attachments were found in the current or previous 20 messages.");
            }
            _service.SaveSong(alias, atts);
        }
Exemple #3
0
        public async Task DeepFryImageAsync([Summary("how many times to fry the image")] uint numPasses = 1)
        {
            IReadOnlyCollection <Attachment> attachments = await AttachmentHelper.GetMostRecentAttachmentsAsync(Context, AttachmentFilter.Images);

            if (attachments == null)
            {
                await ServiceReplyAsync(NO_ATTACHMENTS_FOUND_MESSAGE);

                return;
            }

            var images = _imageService.DeepfryImages(attachments, numPasses);

            await SendImages(images);
        }
Exemple #4
0
        public async Task MirrorImagesAsync([Summary("axis to mirror the image on")] string flipMode = "horizontal")
        {
            IReadOnlyCollection <Attachment> attachments = await AttachmentHelper.GetMostRecentAttachmentsAsync(Context, AttachmentFilter.Images);

            if (attachments == null)
            {
                await ServiceReplyAsync(NO_ATTACHMENTS_FOUND_MESSAGE);

                return;
            }

            var images = _imageService.MirrorImages(attachments, flipMode);

            await SendImages(images);
        }
Exemple #5
0
        public async Task SaturateImageAsync([Summary("Contrast amount")] float amount = 2.0f)
        {
            IReadOnlyCollection <Attachment> attachments = await AttachmentHelper.GetMostRecentAttachmentsAsync(Context, AttachmentFilter.Images);

            if (attachments == null)
            {
                await ServiceReplyAsync(NO_ATTACHMENTS_FOUND_MESSAGE);

                return;
            }

            var images = _imageService.SaturateImages(attachments, amount);

            await SendImages(images);
        }
Exemple #6
0
        public async Task PixelateImageAsync([Summary("Pixel size")] int pixelSize = 0)
        {
            IReadOnlyCollection <Attachment> attachments = await AttachmentHelper.GetMostRecentAttachmentsAsync(Context, AttachmentFilter.Images);

            if (attachments == null)
            {
                await ServiceReplyAsync(NO_ATTACHMENTS_FOUND_MESSAGE);

                return;
            }

            var images = _imageService.PixelateImages(attachments, pixelSize);

            await SendImages(images);
        }
Exemple #7
0
        public async Task ThiccImageAsync([Summary("factor to scale the image width by")] int thiccCount = 2)
        {
            IReadOnlyCollection <Attachment> attachments = await AttachmentHelper.GetMostRecentAttachmentsAsync(Context, AttachmentFilter.Images);

            if (attachments == null)
            {
                await ServiceReplyAsync(NO_ATTACHMENTS_FOUND_MESSAGE);

                return;
            }

            var images = _imageService.ThiccImages(attachments, thiccCount);

            await SendImages(images);
        }
Exemple #8
0
        public async Task MosaicImageAsync()
        {
            IReadOnlyCollection <Attachment> attachments = await AttachmentHelper.GetMostRecentAttachmentsAsync(Context, AttachmentFilter.Images);

            if (attachments == null)
            {
                await ServiceReplyAsync(NO_ATTACHMENTS_FOUND_MESSAGE);

                return;
            }

            var images = _imageService.MosaicImages(attachments);

            await SendImages(images);
        }
Exemple #9
0
        public async Task MemeCaptionImageAsync([Summary("top text to add")] string topText = null, [Summary("bottom text to add")] string bottomText = null)
        {
            IReadOnlyCollection <Attachment> attachments = await AttachmentHelper.GetMostRecentAttachmentsAsync(Context, AttachmentFilter.Images);

            if (attachments == null)
            {
                await ServiceReplyAsync(NO_ATTACHMENTS_FOUND_MESSAGE);

                return;
            }

            if (topText == null && bottomText == null)
            {
                await ServiceReplyAsync("Please add a caption.");

                return;
            }

            var images = _imageService.MemeCaptionImages(attachments, topText, bottomText);

            await SendImages(images);
        }
Exemple #10
0
        public async Task PlaySong([Summary("name of song to play (use \"attached\" to play an attached mp3 file")] string song,
                                   [Summary("Which end of the queue to insert the song at (appended to the back by default.)")] string qEnd = "back",
                                   [Summary("Channel name to play the song in (`main` or `weed`).")] string channelName = "main")
        {
            //check if channel id is valid and exists
            if (!_channelNameToIdMap.ContainsKey(channelName))
            {
                await ReplyAsync("Invalid channel name (please use `main` or `weed`).");

                return;
            }
            ulong voiceID = _channelNameToIdMap[channelName];

            //check if path is valid and exists
            bool   useFile = false;
            string path    = _service.AudioPath;

            if (song == "attached")
            {
                useFile = true;
            }
            foreach (string line in File.ReadAllLines(Path.Combine(_service.AudioPath, "audioaliases.txt")))
            {
                if (line.StartsWith("#") || String.IsNullOrEmpty(line))
                {
                    continue;
                }
                string[] tmp = line.Split(" ");
                if (song.Equals(tmp[0]))
                {
                    path = Path.Combine(path, tmp[1]);
                    break;
                }
            }
            if (path.Equals(_service.AudioPath))
            {
                path = Path.Combine(path, song);
            }
            if (useFile)
            {
                IReadOnlyCollection <Attachment> atts = await AttachmentHelper.GetMostRecentAttachmentsAsync(Context, AttachmentFilter.Media);

                if (atts == null)
                {
                    throw new NullReferenceException("No media attachments were found in the current or previous 20 messages.");
                }
                await _service.QueueTempSong(Context.Message.Author, atts, voiceID, qEnd != "front");
            }
            else
            {
                path = Path.GetFullPath(path);
                if (!File.Exists(path))
                {
                    await ReplyAsync("File does not exist.");

                    Console.WriteLine(path);
                    return;
                }
                await _service.QueueLocalSong(Context.Message.Author, path, voiceID, qEnd != "front");
            }
        }