From 03399d58138f94c1b93174da1cf932316688b53b Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 24 Oct 2016 15:59:34 +0200 Subject: [PATCH] ~place and ~placelist commands added #596 --- .../Searches/Commands/PlaceCommands.cs | 103 ++++++++++++++++++ .../Resources/CommandStrings.Designer.cs | 54 +++++++++ src/NadekoBot/Resources/CommandStrings.resx | 18 +++ 3 files changed, 175 insertions(+) create mode 100644 src/NadekoBot/Modules/Searches/Commands/PlaceCommands.cs diff --git a/src/NadekoBot/Modules/Searches/Commands/PlaceCommands.cs b/src/NadekoBot/Modules/Searches/Commands/PlaceCommands.cs new file mode 100644 index 00000000..9d84e5da --- /dev/null +++ b/src/NadekoBot/Modules/Searches/Commands/PlaceCommands.cs @@ -0,0 +1,103 @@ +using Discord; +using Discord.Commands; +using NadekoBot.Attributes; +using NadekoBot.Services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; + +namespace NadekoBot.Modules.Searches +{ + public partial class Searches + { + [Group] + public class PlaceCommands + { + string typesStr { get; } = ""; + public PlaceCommands() + { + typesStr = $"`List of \"{NadekoBot.ModulePrefixes[typeof(Searches).Name]}place\" tags:`\n" + String.Join(", ", Enum.GetNames(typeof(PlaceType))); + } + + public enum PlaceType + { + Cage, //http://www.placecage.com + Steven, //http://www.stevensegallery.com + Beard, //http://placebeard.it + Img, //https://placeimg.com doesn't embed + Fill, //http://www.fillmurray.com + Bear, //https://www.placebear.com + Kitten, //http://placekitten.com + Bacon, //http://baconmockup.com + Xoart, //http://xoart.link + } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task Placelist(IUserMessage imsg) + { + var channel = (ITextChannel)imsg.Channel; + + await channel.SendMessageAsync(typesStr) + .ConfigureAwait(false); + } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task Place(IUserMessage imsg, PlaceType placeType, uint width = 0, uint height = 0) + { + var channel = (ITextChannel)imsg.Channel; + + string url = ""; + switch (placeType) + { + case PlaceType.Cage: + url = "http://www.placecage.com"; + break; + case PlaceType.Steven: + url = "http://www.stevensegallery.com"; + break; + case PlaceType.Beard: + url = "http://placebeard.it"; + break; + case PlaceType.Img: + url = "https://placeimg.com"; + break; + case PlaceType.Fill: + url = "http://www.fillmurray.com"; + break; + case PlaceType.Bear: + url = "https://www.placebear.com"; + break; + case PlaceType.Kitten: + url = "http://placekitten.com"; + break; + case PlaceType.Bacon: + url = "http://baconmockup.com"; + break; + case PlaceType.Xoart: + url = "http://xoart.link"; + break; + } + var rng = new NadekoRandom(); + if (width <= 0 || width > 1000) + width = (uint)rng.Next(250, 850); + + if (height <= 0 || height > 1000) + height = (uint)rng.Next(250, 850); + + url += $"/{width}/{height}"; + + //using (var http = new HttpClient()) + //{ + // var res = await http.GetStreamAsync(url).ConfigureAwait(false); + // await channel.SendFileAsync() + //} + await channel.SendMessageAsync(url).ConfigureAwait(false); + } + } + } +} diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index 16a386c7..b3153042 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -4244,6 +4244,60 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to place. + /// + public static string place_cmd { + get { + return ResourceManager.GetString("place_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Shows a placeholder image of a given tag. Use `{0}placelist` to see all available tags. You can specify the width and height of the image as the last two optional arguments.. + /// + public static string place_desc { + get { + return ResourceManager.GetString("place_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}place Cage` or `{0}place steven 500 400`. + /// + public static string place_usage { + get { + return ResourceManager.GetString("place_usage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to placelist. + /// + public static string placelist_cmd { + get { + return ResourceManager.GetString("placelist_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Shows the list of available tags for the `{0}place` command.. + /// + public static string placelist_desc { + get { + return ResourceManager.GetString("placelist_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}placelist`. + /// + public static string placelist_usage { + get { + return ResourceManager.GetString("placelist_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to plant. /// diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 652f489f..9ad7965d 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2511,6 +2511,24 @@ `{0}xkcd` or `{0}xkcd 1400` or `{0}xkcd latest` + + placelist + + + Shows the list of available tags for the `{0}place` command. + + + `{0}placelist` + + + place + + + Shows a placeholder image of a given tag. Use `{0}placelist` to see all available tags. You can specify the width and height of the image as the last two optional arguments. + + + `{0}place Cage` or `{0}place steven 500 400` + togethertube totube