~place and ~placelist commands added #596

This commit is contained in:
Kwoth 2016-10-24 15:59:34 +02:00
parent ee4d17c3d0
commit 03399d5813
3 changed files with 175 additions and 0 deletions

View File

@ -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);
}
}
}
}

View File

@ -4244,6 +4244,60 @@ namespace NadekoBot.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to place.
/// </summary>
public static string place_cmd {
get {
return ResourceManager.GetString("place_cmd", resourceCulture);
}
}
/// <summary>
/// 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..
/// </summary>
public static string place_desc {
get {
return ResourceManager.GetString("place_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `{0}place Cage` or `{0}place steven 500 400`.
/// </summary>
public static string place_usage {
get {
return ResourceManager.GetString("place_usage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to placelist.
/// </summary>
public static string placelist_cmd {
get {
return ResourceManager.GetString("placelist_cmd", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Shows the list of available tags for the `{0}place` command..
/// </summary>
public static string placelist_desc {
get {
return ResourceManager.GetString("placelist_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `{0}placelist`.
/// </summary>
public static string placelist_usage {
get {
return ResourceManager.GetString("placelist_usage", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to plant. /// Looks up a localized string similar to plant.
/// </summary> /// </summary>

View File

@ -2511,6 +2511,24 @@
<data name="xkcd_usage" xml:space="preserve"> <data name="xkcd_usage" xml:space="preserve">
<value>`{0}xkcd` or `{0}xkcd 1400` or `{0}xkcd latest`</value> <value>`{0}xkcd` or `{0}xkcd 1400` or `{0}xkcd latest`</value>
</data> </data>
<data name="placelist_cmd" xml:space="preserve">
<value>placelist</value>
</data>
<data name="placelist_desc" xml:space="preserve">
<value>Shows the list of available tags for the `{0}place` command.</value>
</data>
<data name="placelist_usage" xml:space="preserve">
<value>`{0}placelist`</value>
</data>
<data name="place_cmd" xml:space="preserve">
<value>place</value>
</data>
<data name="place_desc" xml:space="preserve">
<value>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.</value>
</data>
<data name="place_usage" xml:space="preserve">
<value>`{0}place Cage` or `{0}place steven 500 400`</value>
</data>
<data name="togethertube_cmd" xml:space="preserve"> <data name="togethertube_cmd" xml:space="preserve">
<value>togethertube totube</value> <value>togethertube totube</value>
</data> </data>