From a4cc1ab563dfd9ccb1216e460dffb220117b090c Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 14 Sep 2016 03:38:44 +0200 Subject: [PATCH] Hopefuly fixed build. Added ~hs back. Good night --- src/NadekoBot/Attributes/NadekoModule.cs | 3 +- .../Gambling/Commands/DiceRollCommand.cs | 435 +++++++++--------- src/NadekoBot/Modules/NSFW/NSFW.cs | 4 +- src/NadekoBot/Modules/Searches/Searches.cs | 102 ++-- src/NadekoBot/NadekoBot.cs | 10 +- src/NadekoBot/NuGet.Config | 19 + .../Resources/CommandStrings.Designer.cs | 54 +-- src/NadekoBot/Resources/CommandStrings.resx | 8 +- .../Services/Database/NadekoContext.cs | 6 + 9 files changed, 340 insertions(+), 301 deletions(-) create mode 100644 src/NadekoBot/NuGet.Config diff --git a/src/NadekoBot/Attributes/NadekoModule.cs b/src/NadekoBot/Attributes/NadekoModule.cs index 68f7db5f..c685078b 100644 --- a/src/NadekoBot/Attributes/NadekoModule.cs +++ b/src/NadekoBot/Attributes/NadekoModule.cs @@ -40,11 +40,10 @@ namespace NadekoBot.Attributes string prefix; if (ModulePrefixes.TryGetValue(moduleName, out prefix)) { - Console.WriteLine("Cache hit"); return prefix; } - Console.WriteLine("Cache not hit for " + moduleName); + NLog.LogManager.GetCurrentClassLogger().Warn("Cache not hit for {0}", moduleName); return null; } } diff --git a/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs b/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs index 0db9b5d1..95ab1cf8 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs @@ -16,245 +16,250 @@ namespace NadekoBot.Modules.Gambling { public partial class Gambling { - private Regex dndRegex { get; } = new Regex(@"(?\d+)d(?\d+)", RegexOptions.Compiled); - - [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] - [RequireContext(ContextType.Guild)] - public async Task Roll(IUserMessage umsg) + [Group] + public class DriceRollCommands { - var channel = (ITextChannel)umsg.Channel; - if (channel == null) - return; - var rng = new NadekoRandom(); - var gen = rng.Next(1, 101); + private Regex dndRegex { get; } = new Regex(@"(?\d+)d(?\d+)", RegexOptions.Compiled); - var num1 = gen / 10; - var num2 = gen % 10; - var imageStream = await Task.Run(() => + [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] + [RequireContext(ContextType.Guild)] + public async Task Roll(IUserMessage umsg) { + var channel = (ITextChannel)umsg.Channel; + if (channel == null) + return; + var rng = new NadekoRandom(); + var gen = rng.Next(1, 101); + + var num1 = gen / 10; + var num2 = gen % 10; + var imageStream = await Task.Run(() => + { + var ms = new MemoryStream(); + new[] { GetDice(num1), GetDice(num2) }.Merge().SaveAsPng(ms); + ms.Position = 0; + return ms; + }); + + await channel.SendFileAsync(imageStream, "dice.png", $"{umsg.Author.Mention} rolled " + Format.Code(gen.ToString())).ConfigureAwait(false); + } + //todo merge into internallDndRoll and internalRoll + [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] + [RequireContext(ContextType.Guild)] + public async Task Roll(IUserMessage umsg, string arg) + { + var channel = (ITextChannel)umsg.Channel; + if (channel == null) + return; + + var ordered = true; + var rng = new NadekoRandom(); + Match match; + if ((match = dndRegex.Match(arg)).Length != 0) + { + int n1; + int n2; + if (int.TryParse(match.Groups["n1"].ToString(), out n1) && + int.TryParse(match.Groups["n2"].ToString(), out n2) && + n1 <= 50 && n2 <= 100000 && n1 > 0 && n2 > 0) + { + var arr = new int[n1]; + for (int i = 0; i < n1; i++) + { + arr[i] = rng.Next(1, n2 + 1); + } + var elemCnt = 0; + await channel.SendMessageAsync($"`{umsg.Author.Mention} rolled {n1} {(n1 == 1 ? "die" : "dice")} 1-{n2}.`\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false); + } + } + } + + [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] + [RequireContext(ContextType.Guild)] + public async Task Roll(IUserMessage umsg, int num) + { + var channel = (ITextChannel)umsg.Channel; + if (channel == null) + return; + + var ordered = true; + + if (num < 1 || num > 30) + { + await channel.SendMessageAsync("Invalid number specified. You can roll up to 1-30 dice at a time.").ConfigureAwait(false); + num = 30; + return; + } + + var rng = new NadekoRandom(); + + var dice = new List(num); + var values = new List(num); + for (var i = 0; i < num; i++) + { + var randomNumber = rng.Next(1, 7); + var toInsert = dice.Count; + if (ordered) + { + if (randomNumber == 6 || dice.Count == 0) + toInsert = 0; + else if (randomNumber != 1) + for (var j = 0; j < dice.Count; j++) + { + if (values[j] < randomNumber) + { + toInsert = j; + break; + } + } + } + else + { + toInsert = dice.Count; + } + dice.Insert(toInsert, GetDice(randomNumber)); + values.Insert(toInsert, randomNumber); + } + + var bitmap = dice.Merge(); var ms = new MemoryStream(); - new[] { GetDice(num1), GetDice(num2) }.Merge().SaveAsPng(ms); + bitmap.SaveAsPng(ms); ms.Position = 0; - return ms; - }); - - await channel.SendFileAsync(imageStream, "dice.png", $"{umsg.Author.Mention} rolled " + Format.Code(gen.ToString())).ConfigureAwait(false); - } - - [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] - [RequireContext(ContextType.Guild)] - public async Task Roll(IUserMessage umsg, int num) - { - var channel = (ITextChannel)umsg.Channel; - if (channel == null) - return; - - var ordered = true; - - if (num < 1 || num > 30) - { - await channel.SendMessageAsync("Invalid number specified. You can roll up to 1-30 dice at a time.").ConfigureAwait(false); - num = 30; + await channel.SendFileAsync(ms, "dice.png", $"{umsg.Author.Mention} rolled {values.Count} {(values.Count == 1 ? "die" : "dice")}. Total: **{values.Sum()}** Average: **{(values.Sum() / (1.0f * values.Count)).ToString("N2")}**").ConfigureAwait(false); } - var rng = new NadekoRandom(); - - var dice = new List(num); - var values = new List(num); - for (var i = 0; i < num; i++) + [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] + [RequireContext(ContextType.Guild)] + public async Task Rolluo(IUserMessage umsg, string arg) { - var randomNumber = rng.Next(1, 7); - var toInsert = dice.Count; - if (ordered) - { - if (randomNumber == 6 || dice.Count == 0) - toInsert = 0; - else if (randomNumber != 1) - for (var j = 0; j < dice.Count; j++) - { - if (values[j] < randomNumber) - { - toInsert = j; - break; - } - } - } - else - { - toInsert = dice.Count; - } - dice.Insert(toInsert, GetDice(randomNumber)); - values.Insert(toInsert, randomNumber); - } + var channel = (ITextChannel)umsg.Channel; + if (channel == null) + return; - var bitmap = dice.Merge(); - var ms = new MemoryStream(); - bitmap.SaveAsPng(ms); - ms.Position = 0; - await channel.SendFileAsync(ms, "dice.png", $"{umsg.Author.Mention} rolled {values.Count} {(values.Count == 1 ? "die" : "dice")}. Total: **{values.Sum()}** Average: **{(values.Sum() / (1.0f * values.Count)).ToString("N2")}**").ConfigureAwait(false); - } - //todo merge into internallDndRoll and internalRoll - [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] - [RequireContext(ContextType.Guild)] - public async Task Roll(IUserMessage umsg, string arg = "") - { - var channel = (ITextChannel)umsg.Channel; - if (channel == null) - return; - - var ordered = true; - var rng = new NadekoRandom(); - Match match; - if ((match = dndRegex.Match(arg)).Length != 0) - { - int n1; - int n2; - if (int.TryParse(match.Groups["n1"].ToString(), out n1) && - int.TryParse(match.Groups["n2"].ToString(), out n2) && - n1 <= 50 && n2 <= 100000 && n1 > 0 && n2 > 0) + var ordered = false; + var rng = new NadekoRandom(); + Match match; + if ((match = dndRegex.Match(arg)).Length != 0) { - var arr = new int[n1]; - for (int i = 0; i < n1; i++) + int n1; + int n2; + if (int.TryParse(match.Groups["n1"].ToString(), out n1) && + int.TryParse(match.Groups["n2"].ToString(), out n2) && + n1 <= 50 && n2 <= 100000 && n1 > 0 && n2 > 0) { - arr[i] = rng.Next(1, n2 + 1); - } - var elemCnt = 0; - await channel.SendMessageAsync($"`{umsg.Author.Mention} rolled {n1} {(n1 == 1 ? "die" : "dice")} 1-{n2}.`\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false); - } - } - } - - [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] - [RequireContext(ContextType.Guild)] - public async Task Rolluo(IUserMessage umsg, string arg = "") - { - var channel = (ITextChannel)umsg.Channel; - if (channel == null) - return; - - var ordered = false; - var rng = new NadekoRandom(); - Match match; - if ((match = dndRegex.Match(arg)).Length != 0) - { - int n1; - int n2; - if (int.TryParse(match.Groups["n1"].ToString(), out n1) && - int.TryParse(match.Groups["n2"].ToString(), out n2) && - n1 <= 50 && n2 <= 100000 && n1 > 0 && n2 > 0) - { - var arr = new int[n1]; - for (int i = 0; i < n1; i++) - { - arr[i] = rng.Next(1, n2 + 1); - } - var elemCnt = 0; - await channel.SendMessageAsync($"`{umsg.Author.Mention} rolled {n1} {(n1 == 1 ? "die" : "dice")} 1-{n2}.`\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false); - } - } - } - - [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] - [RequireContext(ContextType.Guild)] - public async Task Rolluo(IUserMessage umsg, int num) - { - var channel = (ITextChannel)umsg.Channel; - if (channel == null) - return; - - var ordered = true; - - if (num < 1 || num > 30) - { - await channel.SendMessageAsync("Invalid number specified. You can roll up to 1-30 dice at a time.").ConfigureAwait(false); - num = 30; - } - - var rng = new NadekoRandom(); - - var dice = new List(num); - var values = new List(num); - for (var i = 0; i < num; i++) - { - var randomNumber = rng.Next(1, 7); - var toInsert = dice.Count; - if (ordered) - { - if (randomNumber == 6 || dice.Count == 0) - toInsert = 0; - else if (randomNumber != 1) - for (var j = 0; j < dice.Count; j++) + var arr = new int[n1]; + for (int i = 0; i < n1; i++) { - if (values[j] < randomNumber) - { - toInsert = j; - break; - } + arr[i] = rng.Next(1, n2 + 1); } + var elemCnt = 0; + await channel.SendMessageAsync($"`{umsg.Author.Mention} rolled {n1} {(n1 == 1 ? "die" : "dice")} 1-{n2}.`\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false); + } } - else + } + + [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] + [RequireContext(ContextType.Guild)] + public async Task Rolluo(IUserMessage umsg, int num) + { + var channel = (ITextChannel)umsg.Channel; + if (channel == null) + return; + + var ordered = false; + + if (num < 1 || num > 30) { - toInsert = dice.Count; + await channel.SendMessageAsync("Invalid number specified. You can roll up to 1-30 dice at a time.").ConfigureAwait(false); + num = 30; } - dice.Insert(toInsert, GetDice(randomNumber)); - values.Insert(toInsert, randomNumber); - } - var bitmap = dice.Merge(); - var ms = new MemoryStream(); - bitmap.SaveAsPng(ms); - ms.Position = 0; - await channel.SendFileAsync(ms, "dice.png", $"{umsg.Author.Mention} rolled {values.Count} {(values.Count == 1 ? "die" : "dice")}. Total: **{values.Sum()}** Average: **{(values.Sum() / (1.0f * values.Count)).ToString("N2")}**").ConfigureAwait(false); - } + var rng = new NadekoRandom(); - [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] - [RequireContext(ContextType.Guild)] - public async Task NRoll(IUserMessage umsg, [Remainder] string range) - { - var channel = (ITextChannel)umsg.Channel; - - try - { - int rolled; - if (range.Contains("-")) + var dice = new List(num); + var values = new List(num); + for (var i = 0; i < num; i++) { - var arr = range.Split('-') - .Take(2) - .Select(int.Parse) - .ToArray(); - if (arr[0] > arr[1]) - throw new ArgumentException("First argument should be bigger than the second one."); - rolled = new NadekoRandom().Next(arr[0], arr[1] + 1); + var randomNumber = rng.Next(1, 7); + var toInsert = dice.Count; + if (ordered) + { + if (randomNumber == 6 || dice.Count == 0) + toInsert = 0; + else if (randomNumber != 1) + for (var j = 0; j < dice.Count; j++) + { + if (values[j] < randomNumber) + { + toInsert = j; + break; + } + } + } + else + { + toInsert = dice.Count; + } + dice.Insert(toInsert, GetDice(randomNumber)); + values.Insert(toInsert, randomNumber); } - else + + var bitmap = dice.Merge(); + var ms = new MemoryStream(); + bitmap.SaveAsPng(ms); + ms.Position = 0; + await channel.SendFileAsync(ms, "dice.png", $"{umsg.Author.Mention} rolled {values.Count} {(values.Count == 1 ? "die" : "dice")}. Total: **{values.Sum()}** Average: **{(values.Sum() / (1.0f * values.Count)).ToString("N2")}**").ConfigureAwait(false); + } + + [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] + [RequireContext(ContextType.Guild)] + public async Task NRoll(IUserMessage umsg, [Remainder] string range) + { + var channel = (ITextChannel)umsg.Channel; + + try { - rolled = new NadekoRandom().Next(0, int.Parse(range) + 1); + int rolled; + if (range.Contains("-")) + { + var arr = range.Split('-') + .Take(2) + .Select(int.Parse) + .ToArray(); + if (arr[0] > arr[1]) + throw new ArgumentException("First argument should be bigger than the second one."); + rolled = new NadekoRandom().Next(arr[0], arr[1] + 1); + } + else + { + rolled = new NadekoRandom().Next(0, int.Parse(range) + 1); + } + + await channel.SendMessageAsync($"{umsg.Author.Mention} rolled **{rolled}**.").ConfigureAwait(false); + } + catch (Exception ex) + { + await channel.SendMessageAsync($":anger: {ex.Message}").ConfigureAwait(false); + } + } + + private Image GetDice(int num) + { + const string pathToImage = "data/images/dice"; + if (num != 10) + { + using (var stream = File.OpenRead(Path.Combine(pathToImage, $"{num}.png"))) + return new Image(stream); } - await channel.SendMessageAsync($"{umsg.Author.Mention} rolled **{rolled}**.").ConfigureAwait(false); - } - catch (Exception ex) - { - await channel.SendMessageAsync($":anger: {ex.Message}").ConfigureAwait(false); - } - } + using (var one = File.OpenRead(Path.Combine(pathToImage, "1.png"))) + using (var zero = File.OpenRead(Path.Combine(pathToImage, "0.png"))) + { + Image imgOne = new Image(one); + Image imgZero = new Image(zero); - private Image GetDice(int num) - { - const string pathToImage = "data/images/dice"; - if(num != 10) - { - using (var stream = File.OpenRead(Path.Combine(pathToImage, $"{num}.png"))) - return new Image(stream); - } - - using (var one = File.OpenRead(Path.Combine(pathToImage, "1.png"))) - using (var zero = File.OpenRead(Path.Combine(pathToImage, "0.png"))) - { - Image imgOne = new Image(one); - Image imgZero = new Image(zero); - - return new[] { imgOne, imgZero }.Merge(); + return new[] { imgOne, imgZero }.Merge(); + } } } } diff --git a/src/NadekoBot/Modules/NSFW/NSFW.cs b/src/NadekoBot/Modules/NSFW/NSFW.cs index ae9f6c19..cbcfc15d 100644 --- a/src/NadekoBot/Modules/NSFW/NSFW.cs +++ b/src/NadekoBot/Modules/NSFW/NSFW.cs @@ -62,7 +62,7 @@ namespace NadekoBot.Modules.NSFW var channel = (ITextChannel)umsg.Channel; tag = tag?.Trim() ?? ""; - var link = await GetRule34ImageLink(tag).ConfigureAwait(false); + var link = await GetGelbooruImageLink(tag).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(link)) await channel.SendMessageAsync("Search yielded no results ;("); else @@ -76,7 +76,7 @@ namespace NadekoBot.Modules.NSFW var channel = (ITextChannel)umsg.Channel; tag = tag?.Trim() ?? ""; - var link = await GetGelbooruImageLink(tag).ConfigureAwait(false); + var link = await GetRule34ImageLink(tag).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(link)) await channel.SendMessageAsync("Search yielded no results ;("); else diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 0ac25ca1..6a0558ec 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -13,6 +13,10 @@ using System.Net; using Discord.WebSocket; using NadekoBot.Modules.Searches.Models; using NadekoBot.Modules.Searches.IMDB; +using System.Collections.Generic; +using ImageProcessorCore; +using NadekoBot.Extensions; +using System.IO; namespace NadekoBot.Modules.Searches { @@ -199,51 +203,59 @@ $@"🌍 **Weather for** 【{obj["target"]}】 await channel.SendMessageAsync($"https://google.com/search?q={ WebUtility.UrlEncode(terms).Replace(' ', '+') }") .ConfigureAwait(false); } - ////todo drawing - //[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] - //[RequireContext(ContextType.Guild)] - //public async Task Hearthstone(IUserMessage umsg, [Remainder] string name = null) - //{ - // var channel = (ITextChannel)umsg.Channel; - // var arg = name; - // if (string.IsNullOrWhiteSpace(arg)) - // { - // await channel.SendMessageAsync("💢 Please enter a card name to search for.").ConfigureAwait(false); - // return; - // } - // await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); - // string response = ""; - // using (var http = new HttpClient()) - // { - // http.DefaultRequestHeaders.Clear(); - // http.DefaultRequestHeaders.Add("X-Mashape-Key", NadekoBot.Credentials.MashapeKey); - // response = await http.GetStringAsync($"https://omgvamp-hearthstone-v1.p.mashape.com/cards/search/{Uri.EscapeUriString(arg)}", headers) - // .ConfigureAwait(false); - // try - // { - // var items = JArray.Parse(response).Shuffle().ToList(); - // var images = new List(); - // if (items == null) - // throw new KeyNotFoundException("Cannot find a card by that name"); - // var cnt = 0; - // foreach (var item in items.TakeWhile(item => cnt++ < 4).Where(item => item.HasValues && item["img"] != null)) - // { - // images.Add( - // Image.FromStream(await http.GetStreamAsync(item["img"].ToString()).ConfigureAwait(false))); - // } - // if (items.Count > 4) - // { - // await channel.SendMessageAsync("⚠ Found over 4 images. Showing random 4.").ConfigureAwait(false); - // } - // await channel.SendMessageAsync(arg + ".png", (await images.MergeAsync()).ToStream(System.Drawing.Imaging.ImageFormat.Png)) - // .ConfigureAwait(false); - // } - // catch (Exception ex) - // { - // await channel.SendMessageAsync($"💢 Error {ex.Message}").ConfigureAwait(false); - // } - // } - //} + //todo drawing + [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] + [RequireContext(ContextType.Guild)] + public async Task Hearthstone(IUserMessage umsg, [Remainder] string name = null) + { + var channel = (ITextChannel)umsg.Channel; + var arg = name; + if (string.IsNullOrWhiteSpace(arg)) + { + await channel.SendMessageAsync("💢 Please enter a card name to search for.").ConfigureAwait(false); + return; + } + await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); + string response = ""; + using (var http = new HttpClient()) + { + http.DefaultRequestHeaders.Clear(); + http.DefaultRequestHeaders.Add("X-Mashape-Key", NadekoBot.Credentials.MashapeKey); + response = await http.GetStringAsync($"https://omgvamp-hearthstone-v1.p.mashape.com/cards/search/{Uri.EscapeUriString(arg)}") + .ConfigureAwait(false); + try + { + var items = JArray.Parse(response).Shuffle().ToList(); + var images = new List(); + if (items == null) + throw new KeyNotFoundException("Cannot find a card by that name"); + var cnt = 0; + foreach (var item in items.TakeWhile(item => cnt++ < 4).Where(item => item.HasValues && item["img"] != null)) + { + using (var sr =await http.GetStreamAsync(item["img"].ToString())) + { + var imgStream = new MemoryStream(); + await sr.CopyToAsync(imgStream); + imgStream.Position = 0; + images.Add(new Image(imgStream)); + } + } + string msg = null; + if (items.Count > 4) + { + msg = "⚠ Found over 4 images. Showing random 4."; + } + var ms = new MemoryStream(); + images.Merge().SaveAsPng(ms); + ms.Position = 0; + await channel.SendFileAsync(ms, arg + ".png", msg).ConfigureAwait(false); + } + catch (Exception ex) + { + await channel.SendMessageAsync($"💢 Error {ex.Message}").ConfigureAwait(false); + } + } + } [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] [RequireContext(ContextType.Guild)] diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index 38d15dc8..30b58ca9 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -13,6 +13,10 @@ using System.Linq; using System.Reflection; using System.Threading.Tasks; using NLog.Fluent; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations.Operations; +using Microsoft.EntityFrameworkCore; namespace NadekoBot { @@ -52,12 +56,6 @@ namespace NadekoBot CommandHandler = new CommandHandler(Client, Commands); Stats = new StatsService(Client, CommandHandler); - //init db - using (var context = DbHandler.Instance.GetDbContext()) - { - context.EnsureSeedData(); - } - //setup DI var depMap = new DependencyMap(); depMap.Add(Localizer); diff --git a/src/NadekoBot/NuGet.Config b/src/NadekoBot/NuGet.Config new file mode 100644 index 00000000..36bf7319 --- /dev/null +++ b/src/NadekoBot/NuGet.Config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index e9cf1a91..25136f16 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -3002,6 +3002,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to Searches for a Hearthstone card and shows its image. Takes a while to complete.. + /// + public static string hearthstone_desc { + get { + return ResourceManager.GetString("hearthstone_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `~hs Ysera`. + /// + public static string hearthstone_summary { + get { + return ResourceManager.GetString("hearthstone_summary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to hearthstone hs. + /// + public static string hearthstone_text { + get { + return ResourceManager.GetString("hearthstone_text", resourceCulture); + } + } + /// /// Looks up a localized string similar to Shows a random NSFW hentai image from gelbooru and danbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +). /// @@ -3110,33 +3137,6 @@ namespace NadekoBot.Resources { } } - /// - /// Looks up a localized string similar to Searches for a Hearthstone card and shows its image. Takes a while to complete.. - /// - public static string hs_desc { - get { - return ResourceManager.GetString("hs_desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `~hs Ysera`. - /// - public static string hs_summary { - get { - return ResourceManager.GetString("hs_summary", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to hs. - /// - public static string hs_text { - get { - return ResourceManager.GetString("hs_text", resourceCulture); - } - } - /// /// Looks up a localized string similar to Pulls the first image found using a search parameter. Use ~ir for different results.. /// diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 029ba9f9..e43b132f 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2205,13 +2205,13 @@ `~google query` - - hs + + hearthstone hs - + Searches for a Hearthstone card and shows its image. Takes a while to complete. - + `~hs Ysera` diff --git a/src/NadekoBot/Services/Database/NadekoContext.cs b/src/NadekoBot/Services/Database/NadekoContext.cs index 46e42179..b2da1c17 100644 --- a/src/NadekoBot/Services/Database/NadekoContext.cs +++ b/src/NadekoBot/Services/Database/NadekoContext.cs @@ -33,6 +33,12 @@ namespace NadekoBot.Services.Database public DbSet RaceAnimals { get; set; } public DbSet ModulePrefixes { get; set; } + public NadekoContext() + { + this.Database.Migrate(); + EnsureSeedData(); + } + public void EnsureSeedData() { if (!BotConfig.Any())