From 75c4da7edd2fa46dbbfc43faf5cac511a911c32f Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 10 Oct 2016 02:27:33 +0200 Subject: [PATCH] So many fixes. Thanks a lot to @fearnlj01 for the testing --- .../Commands/RatelimitCommand.cs | 1 + src/NadekoBot/Modules/Help/Help.cs | 2 +- .../Searches/Commands/UnitConversion.cs | 19 +-- src/NadekoBot/Modules/Searches/Searches.cs | 2 +- .../Modules/Utility/Commands/QuoteCommands.cs | 11 +- src/NadekoBot/Modules/Utility/Utility.cs | 16 ++- .../Resources/CommandStrings.Designer.cs | 133 +++++++----------- src/NadekoBot/Resources/CommandStrings.resx | 115 +++++++-------- .../Database/Repositories/IQuoteRepository.cs | 2 +- .../Repositories/Impl/QuoteRepository.cs | 6 +- src/NadekoBot/_Extensions/Extensions.cs | 2 + 11 files changed, 146 insertions(+), 163 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs b/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs index b7b11f64..51ca481e 100644 --- a/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs @@ -86,6 +86,7 @@ namespace NadekoBot.Modules.Administration [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] + [RequirePermission(GuildPermission.ManageMessages)] public async Task Slowmode(IUserMessage umsg, int msg = 1, int perSec = 5) { var channel = (ITextChannel)umsg.Channel; diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index 9a9cbe6c..b9b90702 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -127,7 +127,7 @@ namespace NadekoBot.Modules.Help var helpstr = new StringBuilder(); var lastModule = ""; - foreach (var com in _commands.Commands) + foreach (var com in _commands.Commands.GroupBy(c=>c.Text).Select(g=>g.First())) { if (com.Module.Name != lastModule) { diff --git a/src/NadekoBot/Modules/Searches/Commands/UnitConversion.cs b/src/NadekoBot/Modules/Searches/Commands/UnitConversion.cs index 844ee5d0..9b2da234 100644 --- a/src/NadekoBot/Modules/Searches/Commands/UnitConversion.cs +++ b/src/NadekoBot/Modules/Searches/Commands/UnitConversion.cs @@ -109,7 +109,7 @@ namespace NadekoBot.Modules.Searches await msg.ReplyLong(sb.ToString(), breakOn: new[] { "```xl\n", "\n" }); } [NadekoCommand, Usage, Description, Aliases] - public async Task Convert(IUserMessage msg, string origin, string target, decimal value) + public async Task Convert(IUserMessage msg, string origin, string target, double value) { var originUnit = Units.Find(x => x.Triggers.Select(y => y.ToLowerInvariant()).Contains(origin.ToLowerInvariant())); var targetUnit = Units.Find(x => x.Triggers.Select(y => y.ToLowerInvariant()).Contains(target.ToLowerInvariant())); @@ -123,7 +123,7 @@ namespace NadekoBot.Modules.Searches await msg.Reply(string.Format("Cannot convert {0} to {1}: types of unit are not equal", originUnit.Triggers.First(), targetUnit.Triggers.First())); return; } - decimal res; + double res; if (originUnit.Triggers == targetUnit.Triggers) res = value; else if (originUnit.UnitType == "temperature") { @@ -131,10 +131,10 @@ namespace NadekoBot.Modules.Searches switch (originUnit.Triggers.First().ToUpperInvariant()) { case "C": - res = value + (decimal)273.15; //celcius! + res = value + 273.15; //celcius! break; case "F": - res = (value + (decimal)459.67) * ((decimal)5 / 9); + res = (value + 459.67) * (5 / 9); break; default: res = value; @@ -144,10 +144,10 @@ namespace NadekoBot.Modules.Searches switch (targetUnit.Triggers.First()) { case "C": - res = value - (decimal)273.15; //celcius! + res = value - 273.15; //celcius! break; case "F": - res = res * ((decimal)9 / 5) - (decimal)458.67; + res = res * (9 / 5) - 458.67; break; default: break; @@ -157,13 +157,14 @@ namespace NadekoBot.Modules.Searches { if (originUnit.UnitType == "currency") { - res = (value * targetUnit.Modifier) / originUnit.Modifier; + res = (value * (double)targetUnit.Modifier) / (double)originUnit.Modifier; } else - res = (value * originUnit.Modifier) / targetUnit.Modifier; + res = (value * (double)originUnit.Modifier) / (double)targetUnit.Modifier; } res = Math.Round(res, 2); - await msg.Reply(string.Format("{0} {1} is equal to {2} {3}", value, originUnit.Triggers.First(), res, targetUnit.Triggers.First())); + + await msg.Reply(string.Format("{0} {1}s is equal to {2} {3}s", value, originUnit.Triggers.First().SnPl(value.IsInteger() ? (int)value : 2), res, targetUnit.Triggers.First().SnPl(res.IsInteger() ? (int)res : 2))); } } diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 541d0f0d..e88656d3 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -39,7 +39,7 @@ namespace NadekoBot.Modules.Searches country = city.Replace(" ", ""); string response; using (var http = new HttpClient()) - response = await http.GetStringAsync($"http://api.lawlypopzz.xyz/nadekobot/weather/?city={city}&country={country}").ConfigureAwait(false); + response = await http.GetStringAsync($"http://api.ninetales.us/nadekobot/weather/?city={city}&country={country}").ConfigureAwait(false); var obj = JObject.Parse(response)["weather"]; diff --git a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs index f9c37bf6..f1133359 100644 --- a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs +++ b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs @@ -73,18 +73,22 @@ namespace NadekoBot.Modules.Utility if (string.IsNullOrWhiteSpace(keyword)) return; + var isAdmin = ((IGuildUser)umsg.Author).GuildPermissions.Administrator; + keyword = keyword.ToUpperInvariant(); string response; using (var uow = DbHandler.UnitOfWork()) { - var q = await uow.Quotes.GetRandomQuoteByKeywordAsync(channel.Guild.Id, keyword).ConfigureAwait(false); + var qs = uow.Quotes.GetAllQuotesByKeyword(channel.Guild.Id, keyword); - if (q == null) + if (qs==null || !qs.Any()) { response = "`No quotes found.`"; return; } + var q = qs.Shuffle().FirstOrDefault(elem => isAdmin || elem.AuthorId == umsg.Author.Id); + uow.Quotes.Remove(q); await uow.CompleteAsync().ConfigureAwait(false); response = "`Deleted a random quote`"; @@ -94,6 +98,7 @@ namespace NadekoBot.Modules.Utility [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] + [RequirePermission(GuildPermission.Administrator)] public async Task DelAllQuotes(IUserMessage umsg, [Remainder] string keyword) { var channel = (ITextChannel)umsg.Channel; @@ -105,7 +110,7 @@ namespace NadekoBot.Modules.Utility using (var uow = DbHandler.UnitOfWork()) { - var quotes = uow.Quotes.GetAllQuotesByKeyword(keyword); + var quotes = uow.Quotes.GetAllQuotesByKeyword(channel.Guild.Id, keyword); uow.Quotes.RemoveRange(quotes.ToArray());//wtf?! diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 9224f351..6f4848ff 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -116,20 +116,30 @@ namespace NadekoBot.Modules.Utility [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - public async Task Roles(IUserMessage msg, IGuildUser target = null) + public async Task Roles(IUserMessage msg, IGuildUser target, int page = 1) { var channel = (ITextChannel)msg.Channel; var guild = channel.Guild; + + const int RolesPerPage = 20; + + if (page < 1 || page > 100) + return; if (target != null) { - await msg.Reply($"`List of roles for **{target.Username}**:` \n• " + string.Join("\n• ", target.Roles.Except(new[] { guild.EveryoneRole }).OrderBy(r => r.Position)).SanitizeMentions()); + await msg.Reply($"`Page #{page} of roles for **{target.Username}**:` \n• " + string.Join("\n• ", target.Roles.Skip((page-1) * RolesPerPage).Take(RolesPerPage).Except(new[] { guild.EveryoneRole }).OrderBy(r => r.Position)).SanitizeMentions()); } else { - await msg.Reply("`List of roles:` \n• " + string.Join("\n• ", guild.Roles.Except(new[] { guild.EveryoneRole }).OrderBy(r=>r.Position)).SanitizeMentions()); + await msg.Reply($"`Page #{page} of all roles on this server:` \n• " + string.Join("\n• ", guild.Roles.Skip((page - 1) * RolesPerPage).Take(RolesPerPage).Except(new[] { guild.EveryoneRole }).OrderBy(r => r.Position)).SanitizeMentions()); } } + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public Task Roles(IUserMessage msg, int page = 1) => + Roles(msg, null, page); + [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] public async Task ChannelTopic(IUserMessage umsg) diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index b5ef1d94..6e1cb268 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -78,7 +78,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `>8ball should i do something`. + /// Looks up a localized string similar to `>8ball should I do something`. /// public static string _8ball_usage { get { @@ -96,7 +96,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Add a custom reaction with a trigger and a response. Running this command in server requires Administration permission. Running this command in DM is Bot Owner only and adds a new global custom reaction. Guide here: <https://github.com/Kwoth/NadekoBot/wiki/Custom-Reactions>. + /// Looks up a localized string similar to Add a custom reaction with a trigger and a response. Running this command in server requires Administration permission. Running this command in DM is Bot Owner only and adds a new global custom reaction. Guide here: <http://nadekobot.readthedocs.io/en/1.0/Custom%20Reactions/>. /// public static string addcustreact_desc { get { @@ -501,7 +501,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Gives someone a certain amount of flowers. . + /// Looks up a localized string similar to Awards someone a certain amount of currency. . /// public static string award_desc { get { @@ -582,7 +582,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Bet to guess will the result be heads or tails. Guessing award you double flowers you've bet.. + /// Looks up a localized string similar to Bet to guess will the result be heads or tails. Guessing awards you double flowers you've bet.. /// public static string betflip_desc { get { @@ -1122,7 +1122,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Enables or disables automatic deleting of invites on the channel.If no channel supplied, it will default to current one. Use ALL to apply to all existing channels at once.. + /// Looks up a localized string similar to Toggles automatic deleting of invites posted in the channel. Does not negate the .srvrfilterinv enabled setting.. /// public static string chnlfilterinv_desc { get { @@ -1131,7 +1131,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `;cfi enable #general-chat`. + /// Looks up a localized string similar to `;cfi`. /// public static string chnlfilterinv_usage { get { @@ -1149,7 +1149,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Enables or disables automatic deleting of messages containing banned words on the channel.If no channel supplied, it will default to current one. Use ALL to apply to all existing channels at once.. + /// Looks up a localized string similar to Toggles automatic deleting of messages containing banned words on the channel. Does not negate the .srvrfilterwords enabled setting.. /// public static string chnlfilterwords_desc { get { @@ -1158,7 +1158,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `;cfw enable #general-chat`. + /// Looks up a localized string similar to `;cfw`. /// public static string chnlfilterwords_usage { get { @@ -1329,7 +1329,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to claimfinish cf cf3 claimfinish3. + /// Looks up a localized string similar to claimfinish cf. /// public static string claimfinish_cmd { get { @@ -1338,7 +1338,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Finish your claim with 3 stars if you destroyed a base. Optional second argument finishes for someone else.. + /// Looks up a localized string similar to Finish your claim with 3 stars if you destroyed a base. First argument is the war number, optional second argument finishes for someone else.. /// public static string claimfinish_desc { get { @@ -1347,7 +1347,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `,cf [war_number] [optional_other_name]`. + /// Looks up a localized string similar to `,cf 1 Someone`. /// public static string claimfinish_usage { get { @@ -1365,7 +1365,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Finish your claim with 1 stars if you destroyed a base. Optional second argument finishes for someone else.. + /// Looks up a localized string similar to Finish your claim with 1 star if you destroyed a base. First argument is the war number, optional second argument finishes for someone else.. /// public static string claimfinish1_desc { get { @@ -1374,7 +1374,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `,cf [war_number] [optional_other_name]`. + /// Looks up a localized string similar to `,cf1 2 SomeGirl`. /// public static string claimfinish1_usage { get { @@ -1392,7 +1392,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Finish your claim with 2 stars if you destroyed a base. Optional second argument finishes for someone else.. + /// Looks up a localized string similar to Finish your claim with 2 stars if you destroyed a base. First argument is the war number, optional second argument finishes for someone else.. /// public static string claimfinish2_desc { get { @@ -1401,7 +1401,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `,cf [war_number] [optional_other_name]`. + /// Looks up a localized string similar to `,cf2 1 SomeGuy`. /// public static string claimfinish2_usage { get { @@ -1473,7 +1473,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Sets a cooldown per user for a command. Set 0 to clear.. + /// Looks up a localized string similar to Sets a cooldown per user for a command. Set to 0 to remove the cooldown.. /// public static string cmdcooldown_desc { get { @@ -1527,7 +1527,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to List all of the bot's commands from a certain module.. + /// Looks up a localized string similar to List all of the bot's commands from a certain module. You can either specify full, or only first few letters of the module name.. /// public static string commands_desc { get { @@ -1536,7 +1536,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `-commands` or `.commands`. + /// Looks up a localized string similar to `-commands Administration` or `-cmds Admin`. /// public static string commands_usage { get { @@ -1554,7 +1554,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Convert quantities from>to.. + /// Looks up a localized string similar to Convert quantities. Use `~convertlist` to see supported dimensions and currencies.. /// public static string convert_desc { get { @@ -1563,7 +1563,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `~convert m>km 1000`. + /// Looks up a localized string similar to `~convert m km 1000`. /// public static string convert_usage { get { @@ -1581,7 +1581,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to List of the convertable dimensions and currencies.. + /// Looks up a localized string similar to List of the convertible dimensions and currencies.. /// public static string convertlist_desc { get { @@ -1905,7 +1905,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Deletes all quotes with the specified keyword. You have to either be bot owner or the creator of the quote to delete it.. + /// Looks up a localized string similar to Deletes a random quote with the specified keyword. You have to either be server Administrator or the creator of the quote to delete it.. /// public static string deletequote_desc { get { @@ -2094,7 +2094,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Instructions for helping the project!. + /// Looks up a localized string similar to Instructions for helping the project financially.. /// public static string donate_desc { get { @@ -2103,7 +2103,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `-donate` or `~donate`. + /// Looks up a localized string similar to `-donate`. /// public static string donate_usage { get { @@ -2310,7 +2310,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Adds or removes (if it exists) a word from the list of filtered words. + /// Looks up a localized string similar to Adds or removes (if it exists) a word from the list of filtered words.. /// public static string filterword_desc { get { @@ -2418,7 +2418,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Toggles currency generation on this channel. Every posted message will have 2% chance to spawn a NadekoFlower. Requires Manage Messages permission.. + /// Looks up a localized string similar to Toggles currency generation on this channel. Every posted message will have chance to spawn a NadekoFlower. Chance is specified by the Bot Owner. (default is 2%). /// public static string gencurrency_desc { get { @@ -2472,7 +2472,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Give someone a certain amount of NadekoFlowers. + /// Looks up a localized string similar to Give someone a certain amount of currency.. /// public static string give_desc { get { @@ -2571,7 +2571,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to greetdel. + /// Looks up a localized string similar to greetdel grdel. /// public static string greetdel_cmd { get { @@ -2706,7 +2706,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to h help. + /// Looks up a localized string similar to help h. /// public static string h_cmd { get { @@ -2715,7 +2715,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Either shows a help for a single command, or PMs you help link if no arguments are specified.. + /// Looks up a localized string similar to Either shows a help for a single command, or DMs you help link if no arguments are specified.. /// public static string h_desc { get { @@ -2724,7 +2724,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `-h !m q` or just `-h`. + /// Looks up a localized string similar to `-h !!q` or `-h`. /// public static string h_usage { get { @@ -2877,7 +2877,7 @@ namespace NadekoBot.Resources { } /// - /// 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 +). + /// Looks up a localized string similar to Shows a 2 random images (from gelbooru and danbooru) with a given tag. Tag is optional but preferred. Only 1 tag allowed.. /// public static string hentai_desc { get { @@ -2886,7 +2886,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `~hentai yuri+kissing`. + /// Looks up a localized string similar to `~hentai yuri`. /// public static string hentai_usage { get { @@ -3156,7 +3156,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `.jcsc`. + /// Looks up a localized string similar to `.jcsc TokenHere`. /// public static string jcsc_usage { get { @@ -3255,7 +3255,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Displays bot currency leaderboard. + /// Looks up a localized string similar to Displays bot currency leaderboard.. /// public static string leaderboard_desc { get { @@ -3444,7 +3444,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Lists whole permission chain with their indexes. You can specify optional page number if there are a lot of permissions. + /// Looks up a localized string similar to Lists whole permission chain with their indexes. You can specify an optional page number if there are a lot of permissions.. /// public static string listperms_desc { get { @@ -3849,7 +3849,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Shows a list of filtered words. + /// Looks up a localized string similar to Shows a list of filtered words.. /// public static string lstfilterwords_desc { get { @@ -4065,7 +4065,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to List all bot modules.. + /// Looks up a localized string similar to Lists all bot modules.. /// public static string modules_desc { get { @@ -4074,7 +4074,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `-modules` or `.modules`. + /// Looks up a localized string similar to `-modules`. /// public static string modules_usage { get { @@ -5001,7 +5001,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to removeplaying rmlp repl. + /// Looks up a localized string similar to removeplaying rmpl repl. /// public static string removeplaying_cmd { get { @@ -5091,7 +5091,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Renames a role. Roles you are renaming must be lower than bot's highest role. **Manage Roles Permissions.**. + /// Looks up a localized string similar to Renames a role. Roles you are renaming must be lower than bot's highest role.. /// public static string renamerole_desc { get { @@ -5324,33 +5324,6 @@ namespace NadekoBot.Resources { } } - /// - /// Looks up a localized string similar to rmvfilterword rw. - /// - public static string rmvfilterword_cmd { - get { - return ResourceManager.GetString("rmvfilterword_cmd", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Removes the word from the list of filtered words. - /// - public static string rmvfilterword_desc { - get { - return ResourceManager.GetString("rmvfilterword_desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `;rw poop`. - /// - public static string rmvfilterword_usage { - get { - return ResourceManager.GetString("rmvfilterword_usage", resourceCulture); - } - } - /// /// Looks up a localized string similar to rolecmd rc. /// @@ -5793,7 +5766,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Send a message to someone on a different server through the bot. . + /// Looks up a localized string similar to Sends a message to someone on a different server through the bot. Separate server and channel/user ids with | and prepend channel id with `c:` and user id with `u:`.. /// public static string send_desc { get { @@ -5802,7 +5775,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `.send sid`. + /// Looks up a localized string similar to `.send serverid|c:channelid` or `.send serverid|u:userid`. /// public static string send_usage { get { @@ -6414,7 +6387,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Enables or disables automatic deleting of invites on the server.. + /// Looks up a localized string similar to Toggles automatic deleting of invites posted in the server.. /// public static string srvrfilterinv_desc { get { @@ -6423,7 +6396,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `;sfi disable`. + /// Looks up a localized string similar to `;sfi`. /// public static string srvrfilterinv_usage { get { @@ -6441,7 +6414,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Enables or disables automatic deleting of messages containing forbidden words on the server.. + /// Looks up a localized string similar to Toggles automatic deleting of messages containing forbidden words on the server.. /// public static string srvrfilterwords_desc { get { @@ -6450,7 +6423,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `;sfw disable`. + /// Looks up a localized string similar to `;sfw`. /// public static string srvrfilterwords_usage { get { @@ -6630,7 +6603,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to toggle whether the self-assigned roles should be exclusive. + /// Looks up a localized string similar to Toggles whether the self-assigned roles are exclusive. (So that any person can have only one of the self assignable roles). /// public static string tesar_desc { get { @@ -6711,7 +6684,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to List the valid languages for translation.. + /// Looks up a localized string similar to Lists the valid languages for translation.. /// public static string translangs_desc { get { @@ -6738,7 +6711,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Translates from>to text. From the given language to the destiation language.. + /// Looks up a localized string similar to Translates from>to text. From the given language to the destination language.. /// public static string translate_desc { get { @@ -7395,7 +7368,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `.voicerpresence`. + /// Looks up a localized string similar to `.voicepresence`. /// public static string voicepresence_usage { get { @@ -7458,7 +7431,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to whosplaying. + /// Looks up a localized string similar to whosplaying whpl. /// public static string whosplaying_cmd { get { @@ -7476,7 +7449,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `.whoplays Overwatch`. + /// Looks up a localized string similar to `.whpl Overwatch`. /// public static string whosplaying_usage { get { diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 7ea75246..65d8b9ff 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -118,13 +118,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - h help + help h - Either shows a help for a single command, or PMs you help link if no arguments are specified. + Either shows a help for a single command, or DMs you help link if no arguments are specified. - `-h !m q` or just `-h` + `-h !!q` or `-h` hgit @@ -139,31 +139,31 @@ donate - Instructions for helping the project! + Instructions for helping the project financially. - `-donate` or `~donate` + `-donate` modules mdls - List all bot modules. + Lists all bot modules. - `-modules` or `.modules` + `-modules` commands cmds - List all of the bot's commands from a certain module. + List all of the bot's commands from a certain module. You can either specify full, or only first few letters of the module name. - `-commands` or `.commands` + `-commands Administration` or `-cmds Admin` - greetdel + greetdel grdel Toggles automatic deletion of greet messages. @@ -268,7 +268,7 @@ Toggles logging to this channel whenever someone joins or leaves a voice channel you are in right now. - `.voicerpresence` + `.voicepresence` repeatinvoke repinv @@ -316,7 +316,7 @@ `.lipl` - removeplaying rmlp repl + removeplaying rmpl repl Removes a playing string on a given number. @@ -367,7 +367,7 @@ Joins current channel to an instance of cross server channel using the token. - `.jcsc` + `.jcsc TokenHere` lcsc @@ -409,7 +409,7 @@ togglexclsar tesar - toggle whether the self-assigned roles should be exclusive + Toggles whether the self-assigned roles are exclusive. (So that any person can have only one of the self assignable roles) `.tesar` @@ -436,7 +436,7 @@ addcustreact acr - Add a custom reaction with a trigger and a response. Running this command in server requires Administration permission. Running this command in DM is Bot Owner only and adds a new global custom reaction. Guide here: <https://github.com/Kwoth/NadekoBot/wiki/Custom-Reactions> + Add a custom reaction with a trigger and a response. Running this command in server requires Administration permission. Running this command in DM is Bot Owner only and adds a new global custom reaction. Guide here: <http://nadekobot.readthedocs.io/en/1.0/Custom%20Reactions/> `.acr "hello" Hi there %user%` @@ -553,7 +553,7 @@ renamerole renr - Renames a role. Roles you are renaming must be lower than bot's highest role. **Manage Roles Permissions.** + Renames a role. Roles you are renaming must be lower than bot's highest role. `.renr "First role" SecondRole` @@ -760,10 +760,10 @@ send - Send a message to someone on a different server through the bot. + Sends a message to someone on a different server through the bot. Separate server and channel/user ids with | and prepend channel id with `c:` and user id with `u:`. - `.send sid` + `.send serverid|c:channelid` or `.send serverid|u:userid` mentionrole menro @@ -865,13 +865,13 @@ `.uinfo @SomeUser` - whosplaying + whosplaying whpl Shows a list of users who are playing the specified game. - `.whoplays Overwatch` + `.whpl Overwatch` inrole @@ -958,52 +958,43 @@ chnlfilterinv cfi - Enables or disables automatic deleting of invites on the channel.If no channel supplied, it will default to current one. Use ALL to apply to all existing channels at once. + Toggles automatic deleting of invites posted in the channel. Does not negate the .srvrfilterinv enabled setting. - `;cfi enable #general-chat` + `;cfi` srvrfilterinv sfi - Enables or disables automatic deleting of invites on the server. + Toggles automatic deleting of invites posted in the server. - `;sfi disable` + `;sfi` chnlfilterwords cfw - Enables or disables automatic deleting of messages containing banned words on the channel.If no channel supplied, it will default to current one. Use ALL to apply to all existing channels at once. + Toggles automatic deleting of messages containing banned words on the channel. Does not negate the .srvrfilterwords enabled setting. - `;cfw enable #general-chat` + `;cfw` fw - Adds or removes (if it exists) a word from the list of filtered words + Adds or removes (if it exists) a word from the list of filtered words. `;fw poop` - - rmvfilterword rw - - - Removes the word from the list of filtered words - - - `;rw poop` - lstfilterwords lfw - Shows a list of filtered words + Shows a list of filtered words. `;lfw` @@ -1012,10 +1003,10 @@ srvrfilterwords sfw - Enables or disables automatic deleting of messages containing forbidden words on the server. + Toggles automatic deleting of messages containing forbidden words on the server. - `;sfw disable` + `;sfw` permrole pr @@ -1228,7 +1219,7 @@ cmdcooldown cmdcd - Sets a cooldown per user for a command. Set 0 to clear. + Sets a cooldown per user for a command. Set to 0 to remove the cooldown. `;cmdcd "some cmd" 5` @@ -1264,7 +1255,7 @@ deletequote delq - Deletes all quotes with the specified keyword. You have to either be bot owner or the creator of the quote to delete it. + Deletes a random quote with the specified keyword. You have to either be server Administrator or the creator of the quote to delete it. `.delq abc` @@ -1336,7 +1327,7 @@ betflip bf - Bet to guess will the result be heads or tails. Guessing award you double flowers you've bet. + Bet to guess will the result be heads or tails. Guessing awards you double flowers you've bet. `$bf 5 heads` or `$bf 3 t` @@ -1399,7 +1390,7 @@ give - Give someone a certain amount of NadekoFlowers + Give someone a certain amount of currency. `$give 1 "@SomeGuy"` @@ -1408,7 +1399,7 @@ award - Gives someone a certain amount of flowers. + Awards someone a certain amount of currency. `$award 100 @person` @@ -1435,7 +1426,7 @@ leaderboard lb - Displays bot currency leaderboard + Displays bot currency leaderboard. `$lb` @@ -1534,7 +1525,7 @@ gencurrency gc - Toggles currency generation on this channel. Every posted message will have 2% chance to spawn a NadekoFlower. Requires Manage Messages permission. + Toggles currency generation on this channel. Every posted message will have chance to spawn a NadekoFlower. Chance is specified by the Bot Owner. (default is 2%) `>gc` @@ -1564,7 +1555,7 @@ Ask the 8ball a yes/no question. - `>8ball should i do something` + `>8ball should I do something` rps @@ -1930,16 +1921,16 @@ convert - Convert quantities from>to. + Convert quantities. Use `~convertlist` to see supported dimensions and currencies. - `~convert m>km 1000` + `~convert m km 1000` convertlist - List of the convertable dimensions and currencies. + List of the convertible dimensions and currencies. `~convertlist` @@ -2263,10 +2254,10 @@ hentai - Shows a random NSFW hentai image from gelbooru and danbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +) + Shows a 2 random images (from gelbooru and danbooru) with a given tag. Tag is optional but preferred. Only 1 tag allowed. - `~hentai yuri+kissing` + `~hentai yuri` danbooru @@ -2368,31 +2359,31 @@ `,call [war_number] [base_number] [optional_other_name]` - claimfinish cf cf3 claimfinish3 + claimfinish cf - Finish your claim with 3 stars if you destroyed a base. Optional second argument finishes for someone else. + Finish your claim with 3 stars if you destroyed a base. First argument is the war number, optional second argument finishes for someone else. - `,cf [war_number] [optional_other_name]` + `,cf 1 Someone` claimfinish2 cf2 - Finish your claim with 2 stars if you destroyed a base. Optional second argument finishes for someone else. + Finish your claim with 2 stars if you destroyed a base. First argument is the war number, optional second argument finishes for someone else. - `,cf [war_number] [optional_other_name]` + `,cf2 1 SomeGuy` claimfinish1 cf1 - Finish your claim with 1 stars if you destroyed a base. Optional second argument finishes for someone else. + Finish your claim with 1 star if you destroyed a base. First argument is the war number, optional second argument finishes for someone else. - `,cf [war_number] [optional_other_name]` + `,cf1 2 SomeGirl` unclaim ucall uc @@ -2461,7 +2452,7 @@ translate trans - Translates from>to text. From the given language to the destiation language. + Translates from>to text. From the given language to the destination language. `~trans en>fr Hello` @@ -2470,7 +2461,7 @@ translangs - List the valid languages for translation. + Lists the valid languages for translation. `~translangs` @@ -2557,7 +2548,7 @@ cash $$ - Lists whole permission chain with their indexes. You can specify optional page number if there are a lot of permissions + Lists whole permission chain with their indexes. You can specify an optional page number if there are a lot of permissions. `;lp` or `;lp 3` diff --git a/src/NadekoBot/Services/Database/Repositories/IQuoteRepository.cs b/src/NadekoBot/Services/Database/Repositories/IQuoteRepository.cs index 3bbef352..f119fb1e 100644 --- a/src/NadekoBot/Services/Database/Repositories/IQuoteRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/IQuoteRepository.cs @@ -9,7 +9,7 @@ namespace NadekoBot.Services.Database.Repositories { public interface IQuoteRepository : IRepository { - IEnumerable GetAllQuotesByKeyword(string keyword); + IEnumerable GetAllQuotesByKeyword(ulong guildId, string keyword); Task GetRandomQuoteByKeywordAsync(ulong guildId, string keyword); } } diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/QuoteRepository.cs b/src/NadekoBot/Services/Database/Repositories/Impl/QuoteRepository.cs index 702cfc21..35e9bd0e 100644 --- a/src/NadekoBot/Services/Database/Repositories/Impl/QuoteRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/Impl/QuoteRepository.cs @@ -15,13 +15,13 @@ namespace NadekoBot.Services.Database.Repositories.Impl { } - public IEnumerable GetAllQuotesByKeyword(string keyword) => - _set.Where(q => q.Keyword == keyword); + public IEnumerable GetAllQuotesByKeyword(ulong guildId, string keyword) => + _set.Where(q => q.GuildId == guildId && q.Keyword == keyword); public Task GetRandomQuoteByKeywordAsync(ulong guildId, string keyword) { var rng = new NadekoRandom(); - return _set.Where(q => q.Keyword == keyword).OrderBy(q => rng.Next()).FirstOrDefaultAsync(); + return _set.Where(q => q.GuildId == guildId && q.Keyword == keyword).OrderBy(q => rng.Next()).FirstOrDefaultAsync(); } } } diff --git a/src/NadekoBot/_Extensions/Extensions.cs b/src/NadekoBot/_Extensions/Extensions.cs index f2c22573..9089646a 100644 --- a/src/NadekoBot/_Extensions/Extensions.cs +++ b/src/NadekoBot/_Extensions/Extensions.cs @@ -23,6 +23,8 @@ namespace NadekoBot.Extensions http.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); } + public static bool IsInteger(this double number) => number == Math.Truncate(number); + public static string SanitizeMentions(this string str) => str.Replace("@everyone", "@everyοne").Replace("@here", "@һere");