added ~memegen and ~memelist commands

This commit is contained in:
Master Kwoth 2016-06-29 21:02:43 +02:00
parent 51d6fd88ed
commit ed59d11d71
3 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,46 @@
using Discord.Commands;
using NadekoBot.Classes;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace NadekoBot.Modules.Searches.Commands
{
class MemegenCommands : DiscordCommand
{
public MemegenCommands(DiscordModule module) : base(module)
{
}
internal override void Init(CommandGroupBuilder cgb)
{
cgb.CreateCommand(Prefix + "memelist")
.Description("Pulls a list of memes you can use with `~memegen` from http://memegen.link/templates/")
.Do(async e =>
{
int i = 0;
await e.Channel.SendMessage("`List Of Commands:`\n```xl\n" +
string.Join("\n", JsonConvert.DeserializeObject<Dictionary<string, string>>(await SearchHelper.GetResponseStringAsync("http://memegen.link/templates/"))
.Select(kvp => Path.GetFileName(kvp.Value))
.GroupBy(item => (i++) / 4)
.Select(ig => string.Join("", ig.Select(el => $"{el,-17}"))))
+ $"\n```").ConfigureAwait(false);
});
cgb.CreateCommand(Prefix + "memegen")
.Description("Generates a meme from memelist with top and bottom text. | `~memegen biw \"gets iced coffee\" \"in the winter\"`")
.Parameter("meme", ParameterType.Required)
.Parameter("toptext", ParameterType.Required)
.Parameter("bottext", ParameterType.Required)
.Do(async e =>
{
var meme = e.GetArg("meme");
var top = Uri.EscapeDataString(e.GetArg("toptext").Replace(' ', '-'));
var bot = Uri.EscapeDataString(e.GetArg("bottext").Replace(' ', '-'));
await e.Channel.SendMessage($"http://memegen.link/{meme}/{top}/{bot}.jpg");
});
}
}
}

View File

@ -31,6 +31,7 @@ namespace NadekoBot.Modules.Searches
commands.Add(new CalcCommand(this)); commands.Add(new CalcCommand(this));
commands.Add(new OsuCommands(this)); commands.Add(new OsuCommands(this));
commands.Add(new PokemonSearchCommands(this)); commands.Add(new PokemonSearchCommands(this));
commands.Add(new MemegenCommands(this));
rng = new Random(); rng = new Random();
} }

View File

@ -149,6 +149,7 @@
<Compile Include="Modules\Searches\Commands\IMDB\ImdbMovie.cs" /> <Compile Include="Modules\Searches\Commands\IMDB\ImdbMovie.cs" />
<Compile Include="Modules\Searches\Commands\IMDB\ImdbScraper.cs" /> <Compile Include="Modules\Searches\Commands\IMDB\ImdbScraper.cs" />
<Compile Include="Classes\IncidentsHandler.cs" /> <Compile Include="Classes\IncidentsHandler.cs" />
<Compile Include="Modules\Searches\Commands\MemegenCommands.cs" />
<Compile Include="Modules\Searches\Commands\OsuCommands.cs" /> <Compile Include="Modules\Searches\Commands\OsuCommands.cs" />
<Compile Include="Modules\Searches\Commands\PokemonSearchCommands.cs" /> <Compile Include="Modules\Searches\Commands\PokemonSearchCommands.cs" />
<Compile Include="Modules\Utility\UtilityModule.cs" /> <Compile Include="Modules\Utility\UtilityModule.cs" />
@ -210,7 +211,6 @@
<Compile Include="Modules\Games\Commands\SpeedTyping.cs" /> <Compile Include="Modules\Games\Commands\SpeedTyping.cs" />
<Compile Include="Modules\Gambling\Helpers\Cards.cs" /> <Compile Include="Modules\Gambling\Helpers\Cards.cs" />
<Compile Include="Classes\Extensions.cs" /> <Compile Include="Classes\Extensions.cs" />
<Compile Include="Modules\Conversations\Commands\CopyCommand.cs" />
<Compile Include="Modules\Gambling\DiceRollCommand.cs" /> <Compile Include="Modules\Gambling\DiceRollCommand.cs" />
<Compile Include="Modules\Gambling\DrawCommand.cs" /> <Compile Include="Modules\Gambling\DrawCommand.cs" />
<Compile Include="Modules\Gambling\FlipCoinCommand.cs" /> <Compile Include="Modules\Gambling\FlipCoinCommand.cs" />