diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 5cb42f5a..904a7b1f 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -313,6 +313,50 @@ namespace NadekoBot.Modules.Searches } } + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task Yodify(IUserMessage umsg, [Remainder] string query = null) + { + var channel = (ITextChannel)umsg.Channel; + + if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.MashapeKey)) + { + await channel.SendMessageAsync("💢 `Bot owner didn't specify MashapeApiKey. You can't use this functionality.`").ConfigureAwait(false); + return; + } + + var arg = query; + if (string.IsNullOrWhiteSpace(arg)) + { + await channel.SendMessageAsync("💢 `Please enter a sentence.`").ConfigureAwait(false); + return; + } + await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); + using (var http = new HttpClient()) + { + http.DefaultRequestHeaders.Clear(); + http.DefaultRequestHeaders.Add("X-Mashape-Key", NadekoBot.Credentials.MashapeKey); + http.DefaultRequestHeaders.Add("Accept", "text/plain"); + var res = await http.GetStringAsync($"https://yoda.p.mashape.com/yoda?sentence={Uri.EscapeUriString(arg)}").ConfigureAwait(false); + try + { + var embed = new EmbedBuilder() + .WithTitle("Young Padawan") + .WithUrl("http://www.yodaspeak.co.uk/") + .WithAuthor(au => au.WithName("Yoda").WithIconUrl("http://www.yodaspeak.co.uk/yoda-small1.gif")) + .WithDescription("Seek advice, you must!") + .WithThumbnail(th => th.WithUrl("http://i.imgur.com/62Uh4u6.jpg")) + .AddField(fb => fb.WithName($"🌍 **{umsg.Author.Username}**").WithValue($"{res.ToString()}").WithIsInline(false)) + .WithColor(NadekoBot.OkColor); + await channel.EmbedAsync(embed.Build()).ConfigureAwait(false); + } + catch + { + await channel.SendMessageAsync("💢 Failed to yodify your sentence.").ConfigureAwait(false); + } + } + } + [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] public async Task UrbanDict(IUserMessage umsg, [Remainder] string query = null) diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 028a679b..4e479ab8 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -293,4 +293,3 @@ namespace NadekoBot.Modules.Utility //} } } - diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index d6568b6e..9bee88cc 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -7781,6 +7781,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to yodify yoda. + /// + public static string yodify_cmd { + get { + return ResourceManager.GetString("yodify_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Translates your normal sentences into Yoda styled sentences!. + /// + public static string yodify_desc { + get { + return ResourceManager.GetString("yodify_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0}yodify I was once an adventurer like you` or `{0}yoda my feelings hurt`. + /// + public static string yodify_usage { + get { + return ResourceManager.GetString("yodify_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to yomama ym. /// diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index dc97bd25..26c79ade 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2709,4 +2709,13 @@ `{0}magicthegathering about face` or `{0}mtg about face` + + yodify yoda + + + Translates your normal sentences into Yoda styled sentences! + + + {0}yodify I was once an adventurer like you` or `{0}yoda my feelings hurt` + \ No newline at end of file diff --git a/src/NadekoBot/Services/Impl/StatsService.cs b/src/NadekoBot/Services/Impl/StatsService.cs index e0916306..30993844 100644 --- a/src/NadekoBot/Services/Impl/StatsService.cs +++ b/src/NadekoBot/Services/Impl/StatsService.cs @@ -95,4 +95,4 @@ Messages: {MessageCounter} [{MessagesPerSecond:F2}/sec] Heap: [{Heap} MB]"; return $"{time.Days} days{separator}{time.Hours} hours{separator}{time.Minutes} minutes"; } } -} +} \ No newline at end of file