Exemplo n.º 1
0
        public async Task InstagramAsync([Summary("Index")] int index, [Summary("Screenshot height")] int height, [Summary("Load timeout")] int timeout, [Remainder][Summary("Search query")] string query)
        {
            query  = StringUtils.DiscordStringFormat(query);
            index -= 1;
            await _chrome.NewBrowserAsync(height).ConfigureAwait(false);

            await RankaReplyAsync("Loading Instagram...").ConfigureAwait(false);

            await _chrome.InstaLogin().ConfigureAwait(false);

            Instafetcher instafetcher = new Instafetcher(query);

            await RankaReplyAsync("Getting search results...").ConfigureAwait(false);

            var results = await instafetcher.GetSearchResults(_chrome.GetChromiumPage()).ConfigureAwait(false);

            await RankaReplyAsync("Taking screenshot...").ConfigureAwait(false);

            var file = await instafetcher.GetScreenshot(results, index, _chrome.GetChromiumPage(), timeout).ConfigureAwait(false);

            await RankaReplyAsync($"Done, here's your screenshot for user {results.ToArray()[index].Url.Replace("/", "")}").ConfigureAwait(false);
            await RankaFileUploadAsync(file).ConfigureAwait(false);

            await instafetcher.Cleanup(_chrome.GetChromiumPage()).ConfigureAwait(false);

            await _chrome.Destroy().ConfigureAwait(false);
        }
Exemplo n.º 2
0
        public async Task InstagramAsync([Remainder][Summary("Search query")] string query)
        {
            query = StringUtils.DiscordStringFormat(query);
            await _chrome.NewBrowserAsync().ConfigureAwait(false);

            await RankaReplyAsync("Loading Instagram...").ConfigureAwait(false);

            await _chrome.InstaLogin().ConfigureAwait(false);

            Instafetcher instafetcher = new Instafetcher(query);

            await RankaReplyAsync("Getting search results...").ConfigureAwait(false);

            var results = await instafetcher.GetSearchResults(_chrome.GetChromiumPage()).ConfigureAwait(false);

            await RankaReplyAsync("Done!").ConfigureAwait(false);

            EmbedBuilder eb = new EmbedBuilder
            {
                Title       = "Instagram Results",
                Description = $"You requested for {query}, here's what I found!",
                Color       = Color.Purple,
            };

            eb.WithFooter(footer => footer.Text = "Instafetcher for Ranka");
            int i = 1;

            foreach (var item in results.Take(10))
            {
                eb.AddField($"{i}. {item.Url.Replace("/", "")}", $"[https://www.instagram.com{item.Url}](https://www.instagram.com{item.Url})");
                i++;
            }
            await RankaReplyAsync(eb).ConfigureAwait(false);

            await instafetcher.Cleanup(_chrome.GetChromiumPage()).ConfigureAwait(false);

            await _chrome.Destroy().ConfigureAwait(false);
        }