Shows a random image within your chosen category.
About Abbot
Abbot is a programmable bot that turns your team chat into a shared command center. We handle all the boilerplate of building and running these conmmands so that you can focus on making tools that help you ship faster.
We built Abbot because we saw the power of this style of work (called ChatOps), when we worked at GitHub. ChatOps made it possible for GitHub to work productively without meetings, while globally distributed. We think it’s a pretty great way to work, so we made it easy to use in Slack, Discord, and Microsoft Teams.
You can read more about Abbot here, check out our blog, or take a look at some of the other cool packages available as a one-click install from Abbot’s Package Directory.
README
Very simple usage. Simply save the skill as is and run “@abbot show cats” or “@abbot show donkeys” or whatever you want to see an image of. If the image exists, you’ll get one back. If not, you’ll feel some rejection.
Code
try{
var response = await Bot.Http.GetJsonAsync($”http://www.reddit.com/r/{command}.json?sort=top&t=week”);
IEnumerable<dynamic> children = response.data.children;
var images = children.Where(child => !(bool)(child.data.is_self)).ToList();
var rnd = new Random();
await Bot.ReplyAsync(images.Skip(rnd.Next(images.Count – 1)).Take(1).Select(image => (string)image.data.url + “”).FirstOrDefault() ?? $”No {command} for you.”);
}
catch{
await Bot.ReplyAsync($”No {command} for you.”);
}