From 073b31d717e7b38ec71c2fe205b441d2066f37e3 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 26 Oct 2016 16:30:49 +0200 Subject: [PATCH 01/58] Much better startup time on shared bot --- .../Modules/Administration/Administration.cs | 2 +- .../Administration/Commands/LogCommand.cs | 3 +-- .../Commands/VoicePlusTextCommands.cs | 2 +- .../Games/Commands/PlantAndPickCommands.cs | 2 +- .../Permissions/Commands/CmdCdsCommands.cs | 2 +- .../Permissions/Commands/FilterCommands.cs | 2 +- src/NadekoBot/NadekoBot.cs | 11 +++++++++ src/NadekoBot/Services/DbHandler.cs | 23 ++++++++++--------- 8 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Administration.cs b/src/NadekoBot/Modules/Administration/Administration.cs index 17a74f35..46176fcf 100644 --- a/src/NadekoBot/Modules/Administration/Administration.cs +++ b/src/NadekoBot/Modules/Administration/Administration.cs @@ -36,7 +36,7 @@ namespace NadekoBot.Modules.Administration { using (var uow = DbHandler.UnitOfWork()) { - var configs = uow.GuildConfigs.GetAll(); + var configs = NadekoBot.AllGuildConfigs; GuildMuteRoles = new ConcurrentDictionary(configs .Where(c=>!string.IsNullOrWhiteSpace(c.MuteRoleName)) .ToDictionary(c => c.GuildId, c => c.MuteRoleName)); diff --git a/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs b/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs index 1ee43243..40ac1a5d 100644 --- a/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs @@ -41,8 +41,7 @@ namespace NadekoBot.Modules.Administration using (var uow = DbHandler.UnitOfWork()) { - GuildLogSettings = new ConcurrentDictionary(uow.GuildConfigs - .GetAll() + GuildLogSettings = new ConcurrentDictionary(NadekoBot.AllGuildConfigs .ToDictionary(g => g.GuildId, g => g.LogSetting)); } diff --git a/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs b/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs index d9451afc..cd9b4bc2 100644 --- a/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs @@ -25,7 +25,7 @@ namespace NadekoBot.Modules.Administration { using (var uow = DbHandler.UnitOfWork()) { - voicePlusTextCache = new ConcurrentHashSet(uow.GuildConfigs.GetAll().Where(g => g.VoicePlusTextEnabled).Select(g => g.GuildId)); + voicePlusTextCache = new ConcurrentHashSet(NadekoBot.AllGuildConfigs.Where(g => g.VoicePlusTextEnabled).Select(g => g.GuildId)); } NadekoBot.Client.UserVoiceStateUpdated += UserUpdatedEventHandler; } diff --git a/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs b/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs index c6ab6c12..4f78c620 100644 --- a/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs @@ -54,7 +54,7 @@ namespace NadekoBot.Modules.Games { var conf = uow.BotConfig.GetOrCreate(); var x = - generationChannels = new ConcurrentHashSet(uow.GuildConfigs.GetAll() + generationChannels = new ConcurrentHashSet(NadekoBot.AllGuildConfigs .SelectMany(c => c.GenerateCurrencyChannelIds.Select(obj=>obj.ChannelId))); chance = conf.CurrencyGenerationChance; cooldown = conf.CurrencyGenerationCooldown; diff --git a/src/NadekoBot/Modules/Permissions/Commands/CmdCdsCommands.cs b/src/NadekoBot/Modules/Permissions/Commands/CmdCdsCommands.cs index 9cdd092b..97728db1 100644 --- a/src/NadekoBot/Modules/Permissions/Commands/CmdCdsCommands.cs +++ b/src/NadekoBot/Modules/Permissions/Commands/CmdCdsCommands.cs @@ -33,7 +33,7 @@ namespace NadekoBot.Modules.Permissions { using (var uow = DbHandler.UnitOfWork()) { - var configs = uow.GuildConfigs.GetAll(); + var configs = NadekoBot.AllGuildConfigs; commandCooldowns = new ConcurrentDictionary>(configs.ToDictionary(k => k.GuildId, v => new ConcurrentHashSet(v.CommandCooldowns))); } } diff --git a/src/NadekoBot/Modules/Permissions/Commands/FilterCommands.cs b/src/NadekoBot/Modules/Permissions/Commands/FilterCommands.cs index a6894929..006ecac9 100644 --- a/src/NadekoBot/Modules/Permissions/Commands/FilterCommands.cs +++ b/src/NadekoBot/Modules/Permissions/Commands/FilterCommands.cs @@ -46,7 +46,7 @@ namespace NadekoBot.Modules.Permissions { using (var uow = DbHandler.UnitOfWork()) { - var guildConfigs = uow.GuildConfigs.GetAll(); + var guildConfigs = NadekoBot.AllGuildConfigs; InviteFilteringServers = new ConcurrentHashSet(guildConfigs.Where(gc => gc.FilterInvites).Select(gc => gc.GuildId)); InviteFilteringChannels = new ConcurrentHashSet(guildConfigs.SelectMany(gc => gc.FilterInvitesChannelIds.Select(fci => fci.ChannelId))); diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index a50dd94c..31da82ab 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -19,6 +19,7 @@ using Module = Discord.Commands.Module; using NadekoBot.TypeReaders; using System.Collections.Concurrent; using NadekoBot.Modules.Music; +using NadekoBot.Services.Database.Models; namespace NadekoBot { @@ -38,6 +39,16 @@ namespace NadekoBot public static ConcurrentDictionary ModulePrefixes { get; private set; } public static bool Ready { get; private set; } + public static IEnumerable AllGuildConfigs { get; } + + static NadekoBot() + { + using (var uow = DbHandler.UnitOfWork()) + { + AllGuildConfigs = uow.GuildConfigs.GetAll(); + } + } + public async Task RunAsync(string[] args) { SetupLogger(); diff --git a/src/NadekoBot/Services/DbHandler.cs b/src/NadekoBot/Services/DbHandler.cs index ee1833dd..a2349560 100644 --- a/src/NadekoBot/Services/DbHandler.cs +++ b/src/NadekoBot/Services/DbHandler.cs @@ -19,18 +19,19 @@ namespace NadekoBot.Services static DbHandler() { } private DbHandler() { - switch (NadekoBot.Credentials.Db.Type.ToUpperInvariant()) - { - case "SQLITE": - dbType = typeof(NadekoSqliteContext); - break; - //case "SQLSERVER": - // dbType = typeof(NadekoSqlServerContext); - // break; - default: - break; + dbType = typeof(NadekoSqliteContext); + //switch (NadekoBot.Credentials.Db.Type.ToUpperInvariant()) + //{ + // case "SQLITE": + // dbType = typeof(NadekoSqliteContext); + // break; + // //case "SQLSERVER": + // // dbType = typeof(NadekoSqlServerContext); + // // break; + // default: + // break; - } + //} } public NadekoContext GetDbContext() => From 24dcbfb0076fc4a6788b740f714c7decbdf9b373 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 26 Oct 2016 18:17:40 +0200 Subject: [PATCH 02/58] Fixed $jr sucking money into the ether --- .../Modules/Gambling/Commands/AnimalRacing.cs | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs b/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs index a849f702..5faf6108 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs @@ -46,13 +46,6 @@ namespace NadekoBot.Modules.Gambling if (amount < 0) amount = 0; - if (amount > 0) - if (!await CurrencyHandler.RemoveCurrencyAsync((IGuildUser)umsg.Author, "BetRace", amount, true).ConfigureAwait(false)) - { - try { await channel.SendMessageAsync($"{umsg.Author.Mention} You don't have enough {Gambling.CurrencyName}s.").ConfigureAwait(false); } catch { } - return; - } - AnimalRace ar; if (!AnimalRaces.TryGetValue(channel.Guild.Id, out ar)) @@ -225,28 +218,33 @@ namespace NadekoBot.Modules.Gambling } } - public async Task JoinRace(IGuildUser u, int amount = 0) + public async Task JoinRace(IGuildUser u, int amount = 0) { var animal = ""; if (!animals.TryDequeue(out animal)) { await raceChannel.SendMessageAsync($"{u.Mention} `There is no running race on this server.`"); - return false; + return; } var p = new Participant(u, animal, amount); if (participants.Contains(p)) { await raceChannel.SendMessageAsync($"{u.Mention} `You already joined this race.`"); - return false; + return; } if (Started) { await raceChannel.SendMessageAsync($"{u.Mention} `Race is already started`"); - return false; + return; } + if (amount > 0) + if (!await CurrencyHandler.RemoveCurrencyAsync((IGuildUser)u, "BetRace", amount, true).ConfigureAwait(false)) + { + try { await raceChannel.SendMessageAsync($"{u.Mention} You don't have enough {Gambling.CurrencyName}s.").ConfigureAwait(false); } catch { } + return; + } participants.Add(p); - await raceChannel.SendMessageAsync($"{u.Mention} **joined the race as a {p.Animal}" + (amount > 0 ? $" and bet {amount} {(amount == 1? CurrencyName : CurrencyPluralName)}!**" : "**")); - return true; + await raceChannel.SendMessageAsync($"{u.Mention} **joined the race as a {p.Animal}" + (amount > 0 ? $" and bet {amount} {CurrencySign}!**" : "**")); } } From f1be66cfb71c80deabca8fbad74389dbc82b2b03 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 26 Oct 2016 21:38:01 +0200 Subject: [PATCH 03/58] Removed docker guide --- docs/guides/Docker Guide.md | 53 +------------------------------------ 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/docs/guides/Docker Guide.md b/docs/guides/Docker Guide.md index 1c0bb3c4..00a13a99 100644 --- a/docs/guides/Docker Guide.md +++ b/docs/guides/Docker Guide.md @@ -1,54 +1,3 @@ # Docker Guide with DigitalOcean -#####Prerequisites -- Digital ocean account (you can use my [reflink][reflink] to support the project and get 10$ after you register) -- [PuTTY][PuTTY] -- A bot account - follow this [guide][guide] -- $5 -- Common sense - -#####Guide -- Click on the create droplet button -![img](http://i.imgur.com/g2ayOcC.png) - -- Pick one click apps and select docker on 14.04 - -![img](http://imgur.com/065Xkme.png) - -- Pick any droplet size you want (5$ will work ok-ish on a few servers) -- Pick location closest to your discord server's location -- Pick a hostname -![img](http://imgur.com/ifPKB6p.png) - -- Click create - -You will get an email from DigitalOcean with your credentials now. - -Open putty and type ip adress **you got in your email** with port 22 - -![img](http://imgur.com/Mh5ehsh.png) - -- Console will open and you will be prompted for a username, type `root`. -- Type in the password you got in the email. -- Confirm the password you just typed in. -- Type in the new password. -- Confirm new password. - -- When you are successfully logged in, type -`docker run --name nadeko -v /nadeko:/config uirel/nadeko` - -- Wait for it to download and at one point it is going to start throwing errors due to `credentials.json` being empty -- CTRL+C to exit that -- Type `docker stop nadeko` -- Type `nano /nadeko/credentials.json` and type in your `credentials` -- CTRL+X then CTRL+Y to save -- Type `docker start nadeko` -- Type `docker logs -f nadeko` to see the console output - -**Your bot is running, enjoy! o/** - -*When you want to update the bot, just type `docker restart nadeko` as it always downloads latest prerelease* - -[reflink]: http://m.do.co/c/46b4d3d44795/ -[PuTTY]: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html -[guide]: http://discord.kongslien.net/guide.html +## There is no docker image for 1.0 nadeko right now. Soon. \ No newline at end of file From b47e68314c51877059b9fb23639b91fce9b2a883 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 26 Oct 2016 22:26:25 +0200 Subject: [PATCH 04/58] Added text to image but commented out, too slow and bad --- src/NadekoBot/Modules/Utility/Utility.cs | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 946ee7c1..8634c721 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -11,6 +11,8 @@ using System.Text.RegularExpressions; using System.Collections.Generic; using System.Reflection; using Discord.WebSocket; +using System.Net.Http; +using System.IO; namespace NadekoBot.Modules.Utility { @@ -174,6 +176,37 @@ namespace NadekoBot.Modules.Utility await msg.Channel.SendMessageAsync(result).ConfigureAwait(false); } + + //[NadekoCommand, Usage, Description, Aliases] + //[RequireContext(ContextType.Guild)] + //public async Task TextToImage(IUserMessage msg, [Remainder] string arg) + //{ + // var channel = (ITextChannel)msg.Channel; + + // const string bgName = "xbiy3"; + + // if (string.IsNullOrWhiteSpace(arg)) + // return; + + // using (var http = new HttpClient()) + // { + // http.AddFakeHeaders(); + + // http.DefaultRequestHeaders.Add("Host", "www.tagsmaker.com"); + // http.DefaultRequestHeaders.Add("Referer", "http://www.tagsmaker.com/"); + // http.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); + // http.DefaultRequestHeaders.Add("Alt-Used", "www.tagsmaker.com:443"); + + // var res = await http.GetAsync($"http://www.tagsmaker.com/tagsmaker.php?background_name=0011&tag_text={arg}&font_name=applejuiced&text_color=white&text_size=48&text_alignment=middle").ConfigureAwait(false); + + // var img = res.RequestMessage.RequestUri.Segments[1].Replace("image-", "").Replace("tag-", ""); + // var imgStream = await http.GetStreamAsync($"http://www.tagsmaker.com/upload/www.tagsmaker.com_{ img.ToString() }.png"); + // var ms = new MemoryStream(); + // await imgStream.CopyToAsync(ms).ConfigureAwait(false); + // ms.Position = 0; + // await channel.SendFileAsync(ms, arg+".png", "Provided by www.tagsmaker.com").ConfigureAwait(false); + // } + //} } } From 84a0fc4c8f3c4949bd8ade15361bf2798cb15bc6 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 27 Oct 2016 11:45:57 +0200 Subject: [PATCH 05/58] Added auto-translate language feature (~atl and ~at) --- .../Modules/Searches/Commands/Translator.cs | 180 +++++++++++++++--- .../Resources/CommandStrings.Designer.cs | 56 +++++- src/NadekoBot/Resources/CommandStrings.resx | 20 +- 3 files changed, 229 insertions(+), 27 deletions(-) diff --git a/src/NadekoBot/Modules/Searches/Commands/Translator.cs b/src/NadekoBot/Modules/Searches/Commands/Translator.cs index 07d36f91..f82b1a98 100644 --- a/src/NadekoBot/Modules/Searches/Commands/Translator.cs +++ b/src/NadekoBot/Modules/Searches/Commands/Translator.cs @@ -6,47 +6,177 @@ using System; using System.Threading.Tasks; using NadekoBot.Services; using Discord.WebSocket; +using System.Collections.Generic; +using System.Collections.Concurrent; +using System.Linq; namespace NadekoBot.Modules.Searches { public partial class Searches { - [NadekoCommand, Usage, Description, Aliases] - [RequireContext(ContextType.Guild)] - public async Task Translate(IUserMessage umsg, string langs, [Remainder] string text = null) + public struct UserChannelPair { - var channel = (ITextChannel)umsg.Channel; + public ulong UserId { get; set; } + public ulong ChannelId { get; set; } + } - try + [Group] + public class TranslateCommands + { + private static ConcurrentDictionary TranslatedChannels { get; } + private static ConcurrentDictionary UserLanguages { get; } + + static TranslateCommands() + { + TranslatedChannels = new ConcurrentDictionary(); + UserLanguages = new ConcurrentDictionary(); + + NadekoBot.Client.MessageReceived += (msg) => + { + var umsg = msg as IUserMessage; + if(umsg == null) + return Task.CompletedTask; + + bool autoDelete; + if (!TranslatedChannels.TryGetValue(umsg.Channel.Id, out autoDelete)) + return Task.CompletedTask; + + var t = Task.Run(async () => + { + var key = new UserChannelPair() + { + UserId = umsg.Author.Id, + ChannelId = umsg.Channel.Id, + }; + + string langs; + if (!UserLanguages.TryGetValue(key, out langs)) + return; + + try + { + var text = await TranslateInternal(umsg, langs, umsg.Resolve(UserMentionHandling.Ignore), true) + .ConfigureAwait(false); + if (autoDelete) + try { await umsg.DeleteAsync().ConfigureAwait(false); } catch { } + await umsg.Channel.SendMessageAsync($"{umsg.Author.Mention} `said:` "+text.Replace("<@ ", "<@").Replace("<@! ", "<@!")).ConfigureAwait(false); + } + catch { } + + }); + return Task.CompletedTask; + }; + } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task Translate(IUserMessage umsg, string langs, [Remainder] string text = null) + { + var channel = (ITextChannel)umsg.Channel; + + try + { + await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); + var translation = await TranslateInternal(umsg, langs, text); + await channel.SendMessageAsync(translation).ConfigureAwait(false); + + } + catch + { + await channel.SendMessageAsync("Bad input format, or something went wrong...").ConfigureAwait(false); + } + } + + private static async Task TranslateInternal(IUserMessage umsg, string langs, [Remainder] string text = null, bool silent = false) { var langarr = langs.ToLowerInvariant().Split('>'); if (langarr.Length != 2) - return; + throw new ArgumentException(); string from = langarr[0]; string to = langarr[1]; text = text?.Trim(); if (string.IsNullOrWhiteSpace(text)) - return; - - await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); - string translation = await GoogleTranslator.Instance.Translate(text, from, to).ConfigureAwait(false); - await channel.SendMessageAsync(translation).ConfigureAwait(false); + throw new ArgumentException(); + return await GoogleTranslator.Instance.Translate(text, from, to).ConfigureAwait(false); } - catch (Exception ex) + + public enum AutoDeleteAutoTranslate { - Console.WriteLine(ex); - await channel.SendMessageAsync("Bad input format, or something went wrong...").ConfigureAwait(false); + Del, + Nodel } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + [RequirePermission(GuildPermission.Administrator)] + [OwnerOnly] + public async Task AutoTranslate(IUserMessage msg, AutoDeleteAutoTranslate autoDelete = AutoDeleteAutoTranslate.Nodel) + { + var channel = (ITextChannel)msg.Channel; + + if (autoDelete == AutoDeleteAutoTranslate.Del) + { + TranslatedChannels.AddOrUpdate(channel.Id, true, (key, val) => true); + try { await channel.SendMessageAsync("`Started automatic translation of messages on this channel. User messages will be auto-deleted.`").ConfigureAwait(false); } catch { } + return; + } + + bool throwaway; + if (TranslatedChannels.TryRemove(channel.Id, out throwaway)) + { + try { await channel.SendMessageAsync("`Stopped automatic translation of messages on this channel.`").ConfigureAwait(false); } catch { } + return; + } + else if (TranslatedChannels.TryAdd(channel.Id, autoDelete == AutoDeleteAutoTranslate.Del)) + { + try { await channel.SendMessageAsync("`Started automatic translation of messages on this channel.`").ConfigureAwait(false); } catch { } + } + } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task AutoTransLang(IUserMessage msg, [Remainder] string langs = null) + { + var channel = (ITextChannel)msg.Channel; + + var ucp = new UserChannelPair + { + UserId = msg.Author.Id, + ChannelId = msg.Channel.Id, + }; + + if (string.IsNullOrWhiteSpace(langs)) + { + if (UserLanguages.TryRemove(ucp, out langs)) + await channel.SendMessageAsync($"{msg.Author.Mention}'s auto-translate language has been removed.").ConfigureAwait(false); + return; + } + + var langarr = langs.ToLowerInvariant().Split('>'); + if (langarr.Length != 2) + return; + var from = langarr[0]; + var to = langarr[1]; + + if (!GoogleTranslator.Instance.Languages.Contains(from) || !GoogleTranslator.Instance.Languages.Contains(to)) + { + try { await channel.SendMessageAsync("`Invalid source and/or target Language.`").ConfigureAwait(false); } catch { } + } + + UserLanguages.AddOrUpdate(ucp, langs, (key, val) => langs); + + await channel.SendMessageAsync(":ok:").ConfigureAwait(false); + } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task Translangs(IUserMessage umsg) + { + var channel = (ITextChannel)umsg.Channel; + + await channel.SendTableAsync(GoogleTranslator.Instance.Languages, str => $"{str,-15}", columns: 3); + } + } - - [NadekoCommand, Usage, Description, Aliases] - [RequireContext(ContextType.Guild)] - public async Task Translangs(IUserMessage umsg) - { - var channel = (ITextChannel)umsg.Channel; - - await channel.SendTableAsync(GoogleTranslator.Instance.Languages, str => $"{str,-15}", columns: 3); - } - } -} +} \ No newline at end of file diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index 8a728890..f4cf477f 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -519,7 +519,61 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to av avatar. + /// Looks up a localized string similar to autotranslang atl. + /// + public static string autotranslang_cmd { + get { + return ResourceManager.GetString("autotranslang_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}atl en>fr`. + /// + public static string autotranslang_desc { + get { + return ResourceManager.GetString("autotranslang_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sets your source and target language to be used with `{0}at`. Specify no arguments to remove previously set value.. + /// + public static string autotranslang_usage { + get { + return ResourceManager.GetString("autotranslang_usage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to autotrans at. + /// + public static string autotranslate_cmd { + get { + return ResourceManager.GetString("autotranslate_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Starts automatic translation of all messages by users who set their `{0}atl` in this channel. You can set "del" argument to automatically delete all translated user messages.. + /// + public static string autotranslate_desc { + get { + return ResourceManager.GetString("autotranslate_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}at` or `{0}at del`. + /// + public static string autotranslate_usage { + get { + return ResourceManager.GetString("autotranslate_usage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to avatar av. /// public static string avatar_cmd { get { diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 36b807dc..8fc36849 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2089,7 +2089,7 @@ `{0}videocall "@SomeGuy"` - av avatar + avatar av Shows a mentioned person's avatar. @@ -2547,4 +2547,22 @@ `{0}ppoll Question?;Answer1;Answ 2;A_3` + + autotranslang atl + + + `{0}atl en>fr` + + + Sets your source and target language to be used with `{0}at`. Specify no arguments to remove previously set value. + + + autotrans at + + + Starts automatic translation of all messages by users who set their `{0}atl` in this channel. You can set "del" argument to automatically delete all translated user messages. + + + `{0}at` or `{0}at del` + \ No newline at end of file From 828eb29b5ca6f463a3a8b80b32295bb8f77c31ce Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 27 Oct 2016 12:36:42 +0200 Subject: [PATCH 06/58] Added .liqu command which lists quotes --- .../Modules/Utility/Commands/QuoteCommands.cs | 24 +++++++++++++++++ .../Resources/CommandStrings.Designer.cs | 27 +++++++++++++++++++ src/NadekoBot/Resources/CommandStrings.resx | 9 +++++++ .../Database/Repositories/IQuoteRepository.cs | 1 + .../Repositories/Impl/QuoteRepository.cs | 3 +++ 5 files changed, 64 insertions(+) diff --git a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs index f1133359..19ccc770 100644 --- a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs +++ b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs @@ -15,6 +15,30 @@ namespace NadekoBot.Modules.Utility { public partial class Utility { + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task ListQuotes(IUserMessage imsg, int page = 1) + { + var channel = (ITextChannel)imsg.Channel; + + page -= 1; + + if (page < 0) + return; + + IEnumerable quotes; + using (var uow = DbHandler.UnitOfWork()) + { + quotes = uow.Quotes.GetGroup(page * 16, 16); + } + + if (quotes.Any()) + await channel.SendMessageAsync($"`Page {page + 1} of quotes:`\n```xl\n" + String.Join("\n", quotes.Select((q) => $"{q.Keyword,-20} by {q.AuthorName}")) + "\n```") + .ConfigureAwait(false); + else + await channel.SendMessageAsync("`No quotes on this page.`").ConfigureAwait(false); + } + [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] public async Task ShowQuote(IUserMessage umsg, [Remainder] string keyword) diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index f4cf477f..ef639f4c 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -3407,6 +3407,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to listquotes liqu. + /// + public static string listquotes_cmd { + get { + return ResourceManager.GetString("listquotes_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}liqu` or `{0}liqu 3`. + /// + public static string listquotes_desc { + get { + return ResourceManager.GetString("listquotes_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lists all quotes on the server ordered alphabetically. 15 Per page.. + /// + public static string listquotes_usage { + get { + return ResourceManager.GetString("listquotes_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to liststreams ls. /// diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 8fc36849..23fdb67f 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2565,4 +2565,13 @@ `{0}at` or `{0}at del` + + listquotes liqu + + + `{0}liqu` or `{0}liqu 3` + + + Lists all quotes on the server ordered alphabetically. 15 Per page. + \ No newline at end of file diff --git a/src/NadekoBot/Services/Database/Repositories/IQuoteRepository.cs b/src/NadekoBot/Services/Database/Repositories/IQuoteRepository.cs index f119fb1e..7dd06e8b 100644 --- a/src/NadekoBot/Services/Database/Repositories/IQuoteRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/IQuoteRepository.cs @@ -11,5 +11,6 @@ namespace NadekoBot.Services.Database.Repositories { IEnumerable GetAllQuotesByKeyword(ulong guildId, string keyword); Task GetRandomQuoteByKeywordAsync(ulong guildId, string keyword); + IEnumerable GetGroup(int skip, int take); } } diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/QuoteRepository.cs b/src/NadekoBot/Services/Database/Repositories/Impl/QuoteRepository.cs index 35e9bd0e..d0cf8ae9 100644 --- a/src/NadekoBot/Services/Database/Repositories/Impl/QuoteRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/Impl/QuoteRepository.cs @@ -18,6 +18,9 @@ namespace NadekoBot.Services.Database.Repositories.Impl public IEnumerable GetAllQuotesByKeyword(ulong guildId, string keyword) => _set.Where(q => q.GuildId == guildId && q.Keyword == keyword); + public IEnumerable GetGroup(int skip, int take) => + _set.OrderBy(q => q.Keyword).Skip(skip).Take(take).ToList(); + public Task GetRandomQuoteByKeywordAsync(ulong guildId, string keyword) { var rng = new NadekoRandom(); From 9e3995a3acfe29039ebcaf5076fc092ce9e6dede Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 28 Oct 2016 01:56:51 +0200 Subject: [PATCH 07/58] Playing rotate goes off once per minute --- .../Modules/Administration/Commands/PlayingRotateCommands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/PlayingRotateCommands.cs b/src/NadekoBot/Modules/Administration/Commands/PlayingRotateCommands.cs index 41d7201f..011f5812 100644 --- a/src/NadekoBot/Modules/Administration/Commands/PlayingRotateCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/PlayingRotateCommands.cs @@ -67,7 +67,7 @@ namespace NadekoBot.Modules.Administration } finally { - await Task.Delay(15000); + await Task.Delay(TimeSpan.FromMinutes(1)); } } while (true); }); From b3fe6077777f8679223576e3f157cf06f732f0d1 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 28 Oct 2016 01:58:15 +0200 Subject: [PATCH 08/58] Adding custom reaction will show the id --- src/NadekoBot/Modules/CustomReactions/CustomReactions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs b/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs index efbf1217..d13b143a 100644 --- a/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs +++ b/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs @@ -115,7 +115,7 @@ namespace NadekoBot.Modules.CustomReactions reactions.Add(cr); } - await imsg.Channel.SendMessageAsync($"`Added new custom reaction:`\n\t`Trigger:` {key}\n\t`Response:` {message}").ConfigureAwait(false); + await imsg.Channel.SendMessageAsync($"`Added new custom reaction {cr.Id}:`\n\t`Trigger:` {key}\n\t`Response:` {message}").ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] From 8abf26cb8e0d7bf563ccee4e479c3b208bb58a2d Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 28 Oct 2016 02:04:14 +0200 Subject: [PATCH 09/58] commandlist updated --- docs/Commands List.md | 36 ++++++++++++++++++++++++++---- src/NadekoBot/Modules/Help/Help.cs | 10 +++++++-- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/docs/Commands List.md b/docs/Commands List.md index 3465c139..6efe3e61 100644 --- a/docs/Commands List.md +++ b/docs/Commands List.md @@ -1,9 +1,24 @@ +######For more information and how to setup your own NadekoBot, go to: +######You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com` +##Table Of Contents +- [Permissions](#Permissions) +- [Games](#Games) +- [NSFW](#NSFW) +- [Searches](#Searches) +- [ClashOfClans](#ClashOfClans) +- [Music](#Music) +- [Utility](#Utility) +- [Gambling](#Gambling) +- [CustomReactions](#CustomReactions) +- [Help](#Help) +- [Administration](#Administration) + +###### [Back to TOC](#table-of-contents) ### Administration Command and aliases | Description | Usage ----------------|--------------|------- `.resetperms` | Resets BOT's permissions module on this server to the default value. **Requires Administrator server permission.** | `.resetperms` -`.restart` | Restarts the bot. Might not work. **Bot owner only.** | `.restart` `.delmsgoncmd` | Toggles the automatic deletion of user's successful command message to prevent chat flood. **Requires Administrator server permission.** | `.delmsgoncmd` `.setrole` `.sr` | Sets a role for a given user. **Requires ManageRoles server permission.** | `.sr @User Guest` `.removerole` `.rr` | Removes a role from a given user. **Requires ManageRoles server permission.** | `.rr @User Admin` @@ -79,6 +94,7 @@ Command and aliases | Description | Usage `.byedel` | Toggles automatic deletion of bye messages. **Requires ManageServer server permission.** | `.byedel` `.voice+text` `.v+t` | Creates a text channel for each voice channel only users in that voice channel can see.If you are server owner, keep in mind you will see them all the time regardless. **Requires ManageRoles server permission.** **Requires ManageChannels server permission.** | `.voice+text` `.cleanvplust` `.cv+t` | Deletes all text channels ending in `-voice` for which voicechannels are not found. Use at your own risk. **Requires ManageChannels server permission.** **Requires ManageRoles server permission.** | `.cleanv+t` +###### [Back to TOC](#table-of-contents) ### ClashOfClans Command and aliases | Description | Usage @@ -92,6 +108,7 @@ Command and aliases | Description | Usage `,claimfinish` `,cf` | Finish your claim with 3 stars if you destroyed a base. First argument is the war number, optional second argument is a base number if you want to finish for someone else. | `,cf 1` or `,cf 1 5` `,endwar` `,ew` | Ends the war with a given index. | `,ew [war_number]` `,unclaim` `,ucall` `,uc` | Removes your claim from a certain war. Optional second argument denotes a person in whose place to unclaim | `,uc [war_number] [optional_other_name]` +###### [Back to TOC](#table-of-contents) ### CustomReactions Command and aliases | Description | Usage @@ -100,6 +117,7 @@ Command and aliases | Description | Usage `.listcustreact` `.lcr` | Lists global or server custom reactions (15 commands per page). Running the command in DM will list global custom reactions, while running it in server will list that server's custom reactions. | `.lcr 1` `.showcustreact` `.scr` | Shows a custom reaction's response on a given ID. | `.scr 1` `.delcustreact` `.dcr` | Deletes a custom reaction on a specific index. If ran in DM, it is bot owner only and deletes a global custom reaction. If ran in a server, it requires Administration priviledges and removes server custom reaction. | `.dcr 5` +###### [Back to TOC](#table-of-contents) ### Gambling Command and aliases | Description | Usage @@ -120,6 +138,7 @@ Command and aliases | Description | Usage `$shuffle` `$sh` | Reshuffles all cards back into the deck. | `$sh` `$flip` | Flips coin(s) - heads or tails, and shows an image. | `$flip` or `$flip 3` `$betflip` `$bf` | Bet to guess will the result be heads or tails. Guessing awards you 1.8x the currency you've bet. | `$bf 5 heads` or `$bf 3 t` +###### [Back to TOC](#table-of-contents) ### Games Command and aliases | Description | Usage @@ -141,6 +160,7 @@ Command and aliases | Description | Usage `>trivia` `>t` | Starts a game of trivia. You can add nohint to prevent hints.First player to get to 10 points wins by default. You can specify a different number. 30 seconds per question. | `>t` or `>t 5 nohint` `>tl` | Shows a current trivia leaderboard. | `>tl` `>tq` | Quits current trivia after current question. | `>tq` +###### [Back to TOC](#table-of-contents) ### Help Command and aliases | Description | Usage @@ -151,6 +171,7 @@ Command and aliases | Description | Usage `-hgit` | Generates the commandlist.md file. **Bot owner only.** | `-hgit` `-readme` `-guide` | Sends a readme and a guide links to the channel. | `-readme` or `-guide` `-donate` | Instructions for helping the project financially. | `-donate` +###### [Back to TOC](#table-of-contents) ### Music Command and aliases | Description | Usage @@ -184,6 +205,7 @@ Command and aliases | Description | Usage `!!goto` | Goes to a specific time in seconds in a song. | `!!goto 30` `!!getlink` `!!gl` | Shows a link to the song in the queue by index, or the currently playing song by default. | `!!gl` `!!autoplay` `!!ap` | Toggles autoplay - When the song is finished, automatically queue a related youtube song. (Works only for youtube songs and when queue is empty) | `!!ap` +###### [Back to TOC](#table-of-contents) ### NSFW Command and aliases | Description | Usage @@ -197,6 +219,7 @@ Command and aliases | Description | Usage `~cp` | We all know where this will lead you to. | `~cp` `~boobs` | Real adult content. | `~boobs` `~butts` `~ass` `~butt` | Real adult content. | `~butts` or `~ass` +###### [Back to TOC](#table-of-contents) ### Permissions Command and aliases | Description | Usage @@ -229,6 +252,7 @@ Command and aliases | Description | Usage `;chnlfilterwords` `;cfw` | Toggles automatic deleting of messages containing banned words on the channel. Does not negate the ;srvrfilterwords enabled setting. Does not affect bot owner. | `;cfw` `;fw` | Adds or removes (if it exists) a word from the list of filtered words. Use`;sfw` or `;cfw` to toggle filtering. | `;fw poop` `;lstfilterwords` `;lfw` | Shows a list of filtered words. | `;lfw` +###### [Back to TOC](#table-of-contents) ### Searches Command and aliases | Description | Usage @@ -252,12 +276,10 @@ Command and aliases | Description | Usage `~wikipedia` `~wiki` | Gives you back a wikipedia link | `~wiki query` `~color` `~clr` | Shows you what color corresponds to that hex. | `~clr 00ff00` `~videocall` | Creates a private video call link for you and other mentioned people. The link is sent to mentioned people via a private message. | `~videocall "@SomeGuy"` -`~av` `~avatar` | Shows a mentioned person's avatar. | `~av "@SomeGuy"` +`~avatar` `~av` | Shows a mentioned person's avatar. | `~av "@SomeGuy"` `~lolban` | Shows top banned champions ordered by ban rate. | `~lolban` `~memelist` | Pulls a list of memes you can use with `~memegen` from http://memegen.link/templates/ | `~memelist` `~memegen` | Generates a meme from memelist with top and bottom text. | `~memegen biw "gets iced coffee" "in the winter"` -`~translate` `~trans` | Translates from>to text. From the given language to the destination language. | `~trans en>fr Hello` -`~translangs` | Lists the valid languages for translation. | `~translangs` `~anime` `~ani` `~aq` | Queries anilist for an anime and shows the first result. | `~ani aquarion evol` `~manga` `~mang` `~mq` | Queries anilist for a manga and shows the first result. | `~mq Shingeki no kyojin` `~yomama` `~ym` | Shows a random joke from | `~ym` @@ -278,7 +300,12 @@ Command and aliases | Description | Usage `~liststreams` `~ls` | Lists all streams you are following on this server. | `~ls` `~removestream` `~rms` | Removes notifications of a certain streamer on this channel. **Requires ManageMessages server permission.** | `~rms SomeGuy` `~checkstream` `~cs` | Checks if a user is online on a certain streaming platform. | `~cs twitch MyFavStreamer` +`~translate` `~trans` | Translates from>to text. From the given language to the destination language. | `~trans en>fr Hello` +`~autotrans` `~at` | Starts automatic translation of all messages by users who set their `~atl` in this channel. You can set "del" argument to automatically delete all translated user messages. **Requires Administrator server permission.** **Bot owner only.** | `~at` or `~at del` +`~autotranslang` `~atl` | `~atl en>fr` | Sets your source and target language to be used with `~at`. Specify no arguments to remove previously set value. +`~translangs` | Lists the valid languages for translation. | `~translangs` `~xkcd` | Shows a XKCD comic. No arguments will retrieve random one. Number argument will retrieve a specific comic, and "latest" will get the latest one. | `~xkcd` or `~xkcd 1400` or `~xkcd latest` +###### [Back to TOC](#table-of-contents) ### Utility Command and aliases | Description | Usage @@ -299,6 +326,7 @@ Command and aliases | Description | Usage `.serverinfo` `.sinfo` | Shows info about the server the bot is on. If no channel is supplied, it defaults to current one. | `.sinfo Some Server` `.channelinfo` `.cinfo` | Shows info about the channel. If no channel is supplied, it defaults to current one. | `.cinfo #some-channel` `.userinfo` `.uinfo` | Shows info about the user. If no user is supplied, it defaults a user running the command. | `.uinfo @SomeUser` +`.listquotes` `.liqu` | `.liqu` or `.liqu 3` | Lists all quotes on the server ordered alphabetically. 15 Per page. `...` | Shows a random quote with a specified name. | `... abc` `..` | Adds a new quote with the specified name and message. | `.. sayhi Hi` `.deletequote` `.delq` | 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` diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index e868f82b..2ca86e0f 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -125,13 +125,19 @@ namespace NadekoBot.Modules.Help public Task Hgit(IUserMessage umsg) { var helpstr = new StringBuilder(); - + helpstr.AppendLine(@"######For more information and how to setup your own NadekoBot, go to: +######You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com`"); + helpstr.AppendLine("##Table Of Contents"); + helpstr.AppendLine(string.Join("\n", NadekoBot.CommandService.Modules.Select(m => $"- [{m.Name}](#{m.Name})"))); + helpstr.AppendLine(); var lastModule = ""; foreach (var com in _commands.Commands.OrderBy(com=>com.Module.Name).GroupBy(c=>c.Text).Select(g=>g.First())) { if (com.Module.Name != lastModule) { - helpstr.AppendLine("\n### " + com.Module.Name + " "); + helpstr.AppendLine("###### [Back to TOC](#table-of-contents)"); + helpstr.AppendLine(); + helpstr.AppendLine("### " + com.Module.Name + " "); helpstr.AppendLine("Command and aliases | Description | Usage"); helpstr.AppendLine("----------------|--------------|-------"); lastModule = com.Module.Name; From e877e62641ab46275a93d7d1f010b66a9d0af1fb Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 28 Oct 2016 02:09:16 +0200 Subject: [PATCH 10/58] Commandlist fixed --- docs/Commands List.md | 23 +++++++++++------------ src/NadekoBot/Modules/Help/Help.cs | 7 ++++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/Commands List.md b/docs/Commands List.md index 6efe3e61..8a5df38c 100644 --- a/docs/Commands List.md +++ b/docs/Commands List.md @@ -1,19 +1,18 @@ ######For more information and how to setup your own NadekoBot, go to: ######You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com` ##Table Of Contents -- [Permissions](#Permissions) -- [Games](#Games) -- [NSFW](#NSFW) -- [Searches](#Searches) -- [ClashOfClans](#ClashOfClans) -- [Music](#Music) -- [Utility](#Utility) -- [Gambling](#Gambling) -- [CustomReactions](#CustomReactions) -- [Help](#Help) -- [Administration](#Administration) +- [Music](#music) +- [Gambling](#gambling) +- [Permissions](#permissions) +- [Administration](#administration) +- [ClashOfClans](#clashofclans) +- [Utility](#utility) +- [Games](#games) +- [Help](#help) +- [NSFW](#nsfw) +- [CustomReactions](#customreactions) +- [Searches](#searches) -###### [Back to TOC](#table-of-contents) ### Administration Command and aliases | Description | Usage diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index 2ca86e0f..6d487c0d 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -128,14 +128,15 @@ namespace NadekoBot.Modules.Help helpstr.AppendLine(@"######For more information and how to setup your own NadekoBot, go to: ######You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com`"); helpstr.AppendLine("##Table Of Contents"); - helpstr.AppendLine(string.Join("\n", NadekoBot.CommandService.Modules.Select(m => $"- [{m.Name}](#{m.Name})"))); + helpstr.AppendLine(string.Join("\n", NadekoBot.CommandService.Modules.Select(m => $"- [{m.Name}](#{m.Name.ToLowerInvariant()})"))); helpstr.AppendLine(); - var lastModule = ""; + string lastModule = null; foreach (var com in _commands.Commands.OrderBy(com=>com.Module.Name).GroupBy(c=>c.Text).Select(g=>g.First())) { if (com.Module.Name != lastModule) { - helpstr.AppendLine("###### [Back to TOC](#table-of-contents)"); + if (lastModule != null) + helpstr.AppendLine("###### [Back to TOC](#table-of-contents)"); helpstr.AppendLine(); helpstr.AppendLine("### " + com.Module.Name + " "); helpstr.AppendLine("Command and aliases | Description | Usage"); From fa9f17b428663d8b9404867322aded981b8558ca Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 28 Oct 2016 02:17:22 +0200 Subject: [PATCH 11/58] Fixed 'back to TOC' link --- docs/Commands List.md | 28 +++++++++++++++++++--------- src/NadekoBot/Modules/Help/Help.cs | 3 +++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/docs/Commands List.md b/docs/Commands List.md index 8a5df38c..2ed4d12d 100644 --- a/docs/Commands List.md +++ b/docs/Commands List.md @@ -1,17 +1,17 @@ ######For more information and how to setup your own NadekoBot, go to: ######You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com` ##Table Of Contents -- [Music](#music) -- [Gambling](#gambling) -- [Permissions](#permissions) -- [Administration](#administration) -- [ClashOfClans](#clashofclans) -- [Utility](#utility) -- [Games](#games) -- [Help](#help) -- [NSFW](#nsfw) - [CustomReactions](#customreactions) +- [ClashOfClans](#clashofclans) - [Searches](#searches) +- [Utility](#utility) +- [Permissions](#permissions) +- [Help](#help) +- [Administration](#administration) +- [NSFW](#nsfw) +- [Games](#games) +- [Gambling](#gambling) +- [Music](#music) ### Administration @@ -93,6 +93,7 @@ Command and aliases | Description | Usage `.byedel` | Toggles automatic deletion of bye messages. **Requires ManageServer server permission.** | `.byedel` `.voice+text` `.v+t` | Creates a text channel for each voice channel only users in that voice channel can see.If you are server owner, keep in mind you will see them all the time regardless. **Requires ManageRoles server permission.** **Requires ManageChannels server permission.** | `.voice+text` `.cleanvplust` `.cv+t` | Deletes all text channels ending in `-voice` for which voicechannels are not found. Use at your own risk. **Requires ManageChannels server permission.** **Requires ManageRoles server permission.** | `.cleanv+t` + ###### [Back to TOC](#table-of-contents) ### ClashOfClans @@ -107,6 +108,7 @@ Command and aliases | Description | Usage `,claimfinish` `,cf` | Finish your claim with 3 stars if you destroyed a base. First argument is the war number, optional second argument is a base number if you want to finish for someone else. | `,cf 1` or `,cf 1 5` `,endwar` `,ew` | Ends the war with a given index. | `,ew [war_number]` `,unclaim` `,ucall` `,uc` | Removes your claim from a certain war. Optional second argument denotes a person in whose place to unclaim | `,uc [war_number] [optional_other_name]` + ###### [Back to TOC](#table-of-contents) ### CustomReactions @@ -116,6 +118,7 @@ Command and aliases | Description | Usage `.listcustreact` `.lcr` | Lists global or server custom reactions (15 commands per page). Running the command in DM will list global custom reactions, while running it in server will list that server's custom reactions. | `.lcr 1` `.showcustreact` `.scr` | Shows a custom reaction's response on a given ID. | `.scr 1` `.delcustreact` `.dcr` | Deletes a custom reaction on a specific index. If ran in DM, it is bot owner only and deletes a global custom reaction. If ran in a server, it requires Administration priviledges and removes server custom reaction. | `.dcr 5` + ###### [Back to TOC](#table-of-contents) ### Gambling @@ -137,6 +140,7 @@ Command and aliases | Description | Usage `$shuffle` `$sh` | Reshuffles all cards back into the deck. | `$sh` `$flip` | Flips coin(s) - heads or tails, and shows an image. | `$flip` or `$flip 3` `$betflip` `$bf` | Bet to guess will the result be heads or tails. Guessing awards you 1.8x the currency you've bet. | `$bf 5 heads` or `$bf 3 t` + ###### [Back to TOC](#table-of-contents) ### Games @@ -159,6 +163,7 @@ Command and aliases | Description | Usage `>trivia` `>t` | Starts a game of trivia. You can add nohint to prevent hints.First player to get to 10 points wins by default. You can specify a different number. 30 seconds per question. | `>t` or `>t 5 nohint` `>tl` | Shows a current trivia leaderboard. | `>tl` `>tq` | Quits current trivia after current question. | `>tq` + ###### [Back to TOC](#table-of-contents) ### Help @@ -170,6 +175,7 @@ Command and aliases | Description | Usage `-hgit` | Generates the commandlist.md file. **Bot owner only.** | `-hgit` `-readme` `-guide` | Sends a readme and a guide links to the channel. | `-readme` or `-guide` `-donate` | Instructions for helping the project financially. | `-donate` + ###### [Back to TOC](#table-of-contents) ### Music @@ -204,6 +210,7 @@ Command and aliases | Description | Usage `!!goto` | Goes to a specific time in seconds in a song. | `!!goto 30` `!!getlink` `!!gl` | Shows a link to the song in the queue by index, or the currently playing song by default. | `!!gl` `!!autoplay` `!!ap` | Toggles autoplay - When the song is finished, automatically queue a related youtube song. (Works only for youtube songs and when queue is empty) | `!!ap` + ###### [Back to TOC](#table-of-contents) ### NSFW @@ -218,6 +225,7 @@ Command and aliases | Description | Usage `~cp` | We all know where this will lead you to. | `~cp` `~boobs` | Real adult content. | `~boobs` `~butts` `~ass` `~butt` | Real adult content. | `~butts` or `~ass` + ###### [Back to TOC](#table-of-contents) ### Permissions @@ -251,6 +259,7 @@ Command and aliases | Description | Usage `;chnlfilterwords` `;cfw` | Toggles automatic deleting of messages containing banned words on the channel. Does not negate the ;srvrfilterwords enabled setting. Does not affect bot owner. | `;cfw` `;fw` | Adds or removes (if it exists) a word from the list of filtered words. Use`;sfw` or `;cfw` to toggle filtering. | `;fw poop` `;lstfilterwords` `;lfw` | Shows a list of filtered words. | `;lfw` + ###### [Back to TOC](#table-of-contents) ### Searches @@ -304,6 +313,7 @@ Command and aliases | Description | Usage `~autotranslang` `~atl` | `~atl en>fr` | Sets your source and target language to be used with `~at`. Specify no arguments to remove previously set value. `~translangs` | Lists the valid languages for translation. | `~translangs` `~xkcd` | Shows a XKCD comic. No arguments will retrieve random one. Number argument will retrieve a specific comic, and "latest" will get the latest one. | `~xkcd` or `~xkcd 1400` or `~xkcd latest` + ###### [Back to TOC](#table-of-contents) ### Utility diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index 6d487c0d..a25ed111 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -136,7 +136,10 @@ namespace NadekoBot.Modules.Help if (com.Module.Name != lastModule) { if (lastModule != null) + { + helpstr.AppendLine(); helpstr.AppendLine("###### [Back to TOC](#table-of-contents)"); + } helpstr.AppendLine(); helpstr.AppendLine("### " + com.Module.Name + " "); helpstr.AppendLine("Command and aliases | Description | Usage"); From aef1d066658a9d72b8a9d4e3d2fff06a8eb8abca Mon Sep 17 00:00:00 2001 From: fkndean Date: Fri, 28 Oct 2016 04:04:15 -0400 Subject: [PATCH 12/58] Add Minecraft Searches --- src/NadekoBot/Modules/Searches/Searches.cs | 139 ++++++++++++++++++++- 1 file changed, 138 insertions(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 9a370f80..bf8c5203 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -225,7 +225,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 throw new KeyNotFoundException("Cannot find a card by that name"); foreach (var item in items.Where(item => item.HasValues && item["img"] != null).Take(4)) { - using (var sr =await http.GetStreamAsync(item["img"].ToString())) + using (var sr = await http.GetStreamAsync(item["img"].ToString())) { var imgStream = new MemoryStream(); await sr.CopyToAsync(imgStream); @@ -464,6 +464,143 @@ $@"🌍 **Weather for** 【{obj["target"]}】 } } + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task MCPing(IUserMessage umsg, [Remainder] string query = null) + { + var channel = (ITextChannel)umsg.Channel; + var arg = query; + if (string.IsNullOrWhiteSpace(arg)) + { + await channel.SendMessageAsync("πŸ’’ Please enter a ip:port.").ConfigureAwait(false); + return; + } + await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); + using (var http = new HttpClient()) + { + http.DefaultRequestHeaders.Clear(); + string ip = arg.Split(':')[0]; + string port = arg.Split(':')[1]; + var res = await http.GetStringAsync($"https://api.minetools.eu/ping/{Uri.EscapeUriString(ip)}/{Uri.EscapeUriString(port)}").ConfigureAwait(false); + try + { + var items = JObject.Parse(res); + var sb = new System.Text.StringBuilder(); + int ping = (int)Math.Ceiling(Double.Parse(items["latency"].ToString())); + sb.AppendLine($"`Server:` {arg}"); + sb.AppendLine($"`Version:` {items["version"]["name"].ToString()} / Protocol {items["version"]["protocol"].ToString()}"); + sb.AppendLine($"`Description:` {items["description"].ToString()}"); + sb.AppendLine($"`Online Players:` {items["players"]["online"].ToString()}/{items["players"]["max"].ToString()}"); + sb.Append($"`Latency:` {ping}"); + await channel.SendMessageAsync(sb.ToString()); + } + catch + { + await channel.SendMessageAsync($"πŸ’’ [MINECRAFT] Failed finding {arg}.").ConfigureAwait(false); + } + } + } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task MCQuery(IUserMessage umsg, [Remainder] string query = null) + { + var channel = (ITextChannel)umsg.Channel; + var arg = query; + if (string.IsNullOrWhiteSpace(arg)) + { + await channel.SendMessageAsync("πŸ’’ Please enter a ip:port.").ConfigureAwait(false); + return; + } + await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); + using (var http = new HttpClient()) + { + http.DefaultRequestHeaders.Clear(); + try + { + string ip = arg.Split(':')[0]; + string port = arg.Split(':')[1]; + var res = await http.GetStringAsync($"https://api.minetools.eu/query/{Uri.EscapeUriString(ip)}/{Uri.EscapeUriString(port)}").ConfigureAwait(false); + var items = JObject.Parse(res); + var sb = new System.Text.StringBuilder(); + sb.AppendLine($"`Server:` {arg.ToString()} γ€˜Status: {items["status"]}γ€™"); + sb.AppendLine($"`Player List:`"); + for (int i=0;i < items["Playerlist"].Count();i++) + { + if (i == 5) + { + break; + } else + { + sb.AppendLine($"γ€”{i+1}. {items["Playerlist"][i]}〕"); + } + } + sb.AppendLine($"`Online Players:` {items["Players"]} / {items["MaxPlayers"]}"); + sb.AppendLine($"`Plugins:` {items["Plugins"]}"); + sb.Append($"`Version:` {items["Version"]}"); + await channel.SendMessageAsync(sb.ToString()); + } + catch + { + await channel.SendMessageAsync($"πŸ’’ [MINECRAFT] Failed finding server: `{arg}`.").ConfigureAwait(false); + } + } + } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task MCUser(IUserMessage umsg, [Remainder] string query = null) + { + var channel = (ITextChannel)umsg.Channel; + var arg = query; + if (string.IsNullOrWhiteSpace(arg)) + { + await channel.SendMessageAsync("πŸ’’ Please enter a name or uuid.").ConfigureAwait(false); + return; + } + await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); + using (var http = new HttpClient()) + { + http.DefaultRequestHeaders.Clear(); + var res = await http.GetStringAsync($"https://api.minetools.eu/uuid/{Uri.EscapeUriString(arg)}").ConfigureAwait(false); + try + { + var items = JObject.Parse(res); + var sb = new System.Text.StringBuilder(); + if (items["uuid"].ToString() == "null") + { + sb.Append($"πŸ’’ [MINECRAFT] Failed finding a name/uuid going by {Uri.EscapeUriString(arg)}, bugger off!"); + } + else + { + using (var httpkek = new HttpClient()) + { + httpkek.DefaultRequestHeaders.Clear(); + var uuid = items["uuid"].ToString(); + var reskek = await http.GetStringAsync($"https://api.minetools.eu/profile/{Uri.EscapeUriString(uuid)}").ConfigureAwait(false); + try + { + var itemskek = JObject.Parse(reskek); + sb.AppendLine($"`Profile ID:` {itemskek["decoded"]["profileId"].ToString()}"); + sb.AppendLine($"`Profile Name:` {itemskek["decoded"]["profileName"].ToString()}"); + sb.AppendLine($"`Textures (CAPE):` {await _google.ShortenUrl(itemskek["decoded"]["textures"]["CAPE"]["url"].ToString()).ConfigureAwait(false)}"); + sb.AppendLine($"`Textures (SKIN):` {await _google.ShortenUrl(itemskek["decoded"]["textures"]["SKIN"]["url"].ToString()).ConfigureAwait(false)}"); + sb.Append($"`Timestamp:` {Convert.ToDateTime(itemskek["decoded"]["timestamp"].ToString())}"); + } + catch + { + } + } + } + await channel.SendMessageAsync(sb.ToString()); + } + catch + { + await channel.SendMessageAsync("πŸ’’ [MINECRAFT] Failed finding user.").ConfigureAwait(false); + } + } + } + public static async Task ValidateQuery(ITextChannel ch, string query) { if (!string.IsNullOrEmpty(query.Trim())) return true; From dd3d70bd4517dc373f74cb2cd256250b06223954 Mon Sep 17 00:00:00 2001 From: fkndean Date: Fri, 28 Oct 2016 04:09:33 -0400 Subject: [PATCH 13/58] :boom: --- .../Resources/CommandStrings.Designer.cs | 278 ++++++------------ src/NadekoBot/Resources/CommandStrings.resx | 100 ++----- 2 files changed, 117 insertions(+), 261 deletions(-) diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index ef639f4c..dfe67852 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -519,61 +519,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to autotranslang atl. - /// - public static string autotranslang_cmd { - get { - return ResourceManager.GetString("autotranslang_cmd", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `{0}atl en>fr`. - /// - public static string autotranslang_desc { - get { - return ResourceManager.GetString("autotranslang_desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Sets your source and target language to be used with `{0}at`. Specify no arguments to remove previously set value.. - /// - public static string autotranslang_usage { - get { - return ResourceManager.GetString("autotranslang_usage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to autotrans at. - /// - public static string autotranslate_cmd { - get { - return ResourceManager.GetString("autotranslate_cmd", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Starts automatic translation of all messages by users who set their `{0}atl` in this channel. You can set "del" argument to automatically delete all translated user messages.. - /// - public static string autotranslate_desc { - get { - return ResourceManager.GetString("autotranslate_desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `{0}at` or `{0}at del`. - /// - public static string autotranslate_usage { - get { - return ResourceManager.GetString("autotranslate_usage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to avatar av. + /// Looks up a localized string similar to av avatar. /// public static string avatar_cmd { get { @@ -609,7 +555,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Awards someone a certain amount of currency. You can also specify a role name to award currency to all users in a role.. + /// Looks up a localized string similar to Awards someone a certain amount of currency. . /// public static string award_desc { get { @@ -618,7 +564,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `{0}award 100 @person` or `{0}award 5 Role Of Gamblers`. + /// Looks up a localized string similar to `{0}award 100 @person`. /// public static string award_usage { get { @@ -3407,33 +3353,6 @@ namespace NadekoBot.Resources { } } - /// - /// Looks up a localized string similar to listquotes liqu. - /// - public static string listquotes_cmd { - get { - return ResourceManager.GetString("listquotes_cmd", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `{0}liqu` or `{0}liqu 3`. - /// - public static string listquotes_desc { - get { - return ResourceManager.GetString("listquotes_desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Lists all quotes on the server ordered alphabetically. 15 Per page.. - /// - public static string listquotes_usage { - get { - return ResourceManager.GetString("listquotes_usage", resourceCulture); - } - } - /// /// Looks up a localized string similar to liststreams ls. /// @@ -3839,6 +3758,87 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to minecraftping mcping. + /// + public static string mcping_cmd { + get { + return ResourceManager.GetString("mcping_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Pings a minecraft server.. + /// + public static string mcping_desc { + get { + return ResourceManager.GetString("mcping_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}mcping 127.0.0.1:1337`. + /// + public static string mcping_usage { + get { + return ResourceManager.GetString("mcping_usage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to minecraftquery mcquery. + /// + public static string mcquery_cmd { + get { + return ResourceManager.GetString("mcquery_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Finds information about a minecraft server.. + /// + public static string mcquery_desc { + get { + return ResourceManager.GetString("mcquery_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}mcquery server:ip`. + /// + public static string mcquery_usage { + get { + return ResourceManager.GetString("mcquery_usage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to minecraftuser mcuser. + /// + public static string mcuser_cmd { + get { + return ResourceManager.GetString("mcuser_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Finds information about a minecraft user.. + /// + public static string mcuser_desc { + get { + return ResourceManager.GetString("mcuser_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}mcuser username or uuid`. + /// + public static string mcuser_usage { + get { + return ResourceManager.GetString("mcuser_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to memegen. /// @@ -4325,60 +4325,6 @@ namespace NadekoBot.Resources { } } - /// - /// Looks up a localized string similar to place. - /// - public static string place_cmd { - get { - return ResourceManager.GetString("place_cmd", resourceCulture); - } - } - - /// - /// 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.. - /// - public static string place_desc { - get { - return ResourceManager.GetString("place_desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `{0}place Cage` or `{0}place steven 500 400`. - /// - public static string place_usage { - get { - return ResourceManager.GetString("place_usage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to placelist. - /// - public static string placelist_cmd { - get { - return ResourceManager.GetString("placelist_cmd", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Shows the list of available tags for the `{0}place` command.. - /// - public static string placelist_desc { - get { - return ResourceManager.GetString("placelist_desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `{0}placelist`. - /// - public static string placelist_usage { - get { - return ResourceManager.GetString("placelist_usage", resourceCulture); - } - } - /// /// Looks up a localized string similar to plant. /// @@ -4524,7 +4470,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Creates a poll which requires users to send the number of the voting option to the bot.. + /// Looks up a localized string similar to Creates a poll, only person who has manage server permission can do it.. /// public static string poll_desc { get { @@ -4595,33 +4541,6 @@ namespace NadekoBot.Resources { } } - /// - /// Looks up a localized string similar to publicpoll ppoll. - /// - public static string publicpoll_cmd { - get { - return ResourceManager.GetString("publicpoll_cmd", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Creates a public poll which requires users to type a number of the voting option in the channel command is ran in.. - /// - public static string publicpoll_desc { - get { - return ResourceManager.GetString("publicpoll_desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `{0}ppoll Question?;Answer1;Answ 2;A_3`. - /// - public static string publicpoll_usage { - get { - return ResourceManager.GetString("publicpoll_usage", resourceCulture); - } - } - /// /// Looks up a localized string similar to queue q yq. /// @@ -6512,33 +6431,6 @@ namespace NadekoBot.Resources { } } - /// - /// Looks up a localized string similar to togethertube totube. - /// - public static string togethertube_cmd { - get { - return ResourceManager.GetString("togethertube_cmd", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Creates a new room on <https://togethertube.com> and shows the link in the chat.. - /// - public static string togethertube_desc { - get { - return ResourceManager.GetString("togethertube_desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `{0}totube`. - /// - public static string togethertube_usage { - get { - return ResourceManager.GetString("togethertube_usage", resourceCulture); - } - } - /// /// Looks up a localized string similar to tq. /// diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 23fdb67f..799ce4dc 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -1246,10 +1246,10 @@ award - Awards someone a certain amount of currency. You can also specify a role name to award currency to all users in a role. + Awards someone a certain amount of currency. - `{0}award 100 @person` or `{0}award 5 Role Of Gamblers` + `{0}award 100 @person` take @@ -1336,7 +1336,7 @@ poll - Creates a poll which requires users to send the number of the voting option to the bot. + Creates a poll, only person who has manage server permission can do it. `{0}poll Question?;Answer1;Answ 2;A_3` @@ -1971,6 +1971,33 @@ `{0}hs Ysera` + + minecraftping mcping + + + Pings a minecraft server. + + + `{0}mcping 127.0.0.1:1337` + + + minecraftuser mcuser + + + Finds information about a minecraft user. + + + `{0}mcuser username or uuid` + + + minecraftquery mcquery + + + Finds information about a minecraft server. + + + `{0}mcquery server:ip` + urbandict ud @@ -2089,7 +2116,7 @@ `{0}videocall "@SomeGuy"` - avatar av + av avatar Shows a mentioned person's avatar. @@ -2511,67 +2538,4 @@ `{0}xkcd` or `{0}xkcd 1400` or `{0}xkcd latest` - - placelist - - - Shows the list of available tags for the `{0}place` command. - - - `{0}placelist` - - - place - - - 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. - - - `{0}place Cage` or `{0}place steven 500 400` - - - togethertube totube - - - Creates a new room on <https://togethertube.com> and shows the link in the chat. - - - `{0}totube` - - - publicpoll ppoll - - - Creates a public poll which requires users to type a number of the voting option in the channel command is ran in. - - - `{0}ppoll Question?;Answer1;Answ 2;A_3` - - - autotranslang atl - - - `{0}atl en>fr` - - - Sets your source and target language to be used with `{0}at`. Specify no arguments to remove previously set value. - - - autotrans at - - - Starts automatic translation of all messages by users who set their `{0}atl` in this channel. You can set "del" argument to automatically delete all translated user messages. - - - `{0}at` or `{0}at del` - - - listquotes liqu - - - `{0}liqu` or `{0}liqu 3` - - - Lists all quotes on the server ordered alphabetically. 15 Per page. - - \ No newline at end of file + From b7b8dfdf05cf542936daaba1177529a7e729f005 Mon Sep 17 00:00:00 2001 From: fkndean Date: Fri, 28 Oct 2016 04:12:52 -0400 Subject: [PATCH 14/58] :camel: --- .../Resources/CommandStrings.Designer.cs | 360 +++++++++++++----- src/NadekoBot/Resources/CommandStrings.resx | 127 ++++-- 2 files changed, 369 insertions(+), 118 deletions(-) diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index dfe67852..a41c6a07 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -519,7 +519,61 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to av avatar. + /// Looks up a localized string similar to autotranslang atl. + /// + public static string autotranslang_cmd { + get { + return ResourceManager.GetString("autotranslang_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}atl en>fr`. + /// + public static string autotranslang_desc { + get { + return ResourceManager.GetString("autotranslang_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sets your source and target language to be used with `{0}at`. Specify no arguments to remove previously set value.. + /// + public static string autotranslang_usage { + get { + return ResourceManager.GetString("autotranslang_usage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to autotrans at. + /// + public static string autotranslate_cmd { + get { + return ResourceManager.GetString("autotranslate_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Starts automatic translation of all messages by users who set their `{0}atl` in this channel. You can set "del" argument to automatically delete all translated user messages.. + /// + public static string autotranslate_desc { + get { + return ResourceManager.GetString("autotranslate_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}at` or `{0}at del`. + /// + public static string autotranslate_usage { + get { + return ResourceManager.GetString("autotranslate_usage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to avatar av. /// public static string avatar_cmd { get { @@ -555,7 +609,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Awards someone a certain amount of currency. . + /// Looks up a localized string similar to Awards someone a certain amount of currency. You can also specify a role name to award currency to all users in a role.. /// public static string award_desc { get { @@ -564,7 +618,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `{0}award 100 @person`. + /// Looks up a localized string similar to `{0}award 100 @person` or `{0}award 5 Role Of Gamblers`. /// public static string award_usage { get { @@ -3353,6 +3407,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to listquotes liqu. + /// + public static string listquotes_cmd { + get { + return ResourceManager.GetString("listquotes_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}liqu` or `{0}liqu 3`. + /// + public static string listquotes_desc { + get { + return ResourceManager.GetString("listquotes_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lists all quotes on the server ordered alphabetically. 15 Per page.. + /// + public static string listquotes_usage { + get { + return ResourceManager.GetString("listquotes_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to liststreams ls. /// @@ -3758,87 +3839,6 @@ namespace NadekoBot.Resources { } } - /// - /// Looks up a localized string similar to minecraftping mcping. - /// - public static string mcping_cmd { - get { - return ResourceManager.GetString("mcping_cmd", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Pings a minecraft server.. - /// - public static string mcping_desc { - get { - return ResourceManager.GetString("mcping_desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `{0}mcping 127.0.0.1:1337`. - /// - public static string mcping_usage { - get { - return ResourceManager.GetString("mcping_usage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to minecraftquery mcquery. - /// - public static string mcquery_cmd { - get { - return ResourceManager.GetString("mcquery_cmd", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Finds information about a minecraft server.. - /// - public static string mcquery_desc { - get { - return ResourceManager.GetString("mcquery_desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `{0}mcquery server:ip`. - /// - public static string mcquery_usage { - get { - return ResourceManager.GetString("mcquery_usage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to minecraftuser mcuser. - /// - public static string mcuser_cmd { - get { - return ResourceManager.GetString("mcuser_cmd", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Finds information about a minecraft user.. - /// - public static string mcuser_desc { - get { - return ResourceManager.GetString("mcuser_desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `{0}mcuser username or uuid`. - /// - public static string mcuser_usage { - get { - return ResourceManager.GetString("mcuser_usage", resourceCulture); - } - } - /// /// Looks up a localized string similar to memegen. /// @@ -4325,6 +4325,60 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to place. + /// + public static string place_cmd { + get { + return ResourceManager.GetString("place_cmd", resourceCulture); + } + } + + /// + /// 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.. + /// + public static string place_desc { + get { + return ResourceManager.GetString("place_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}place Cage` or `{0}place steven 500 400`. + /// + public static string place_usage { + get { + return ResourceManager.GetString("place_usage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to placelist. + /// + public static string placelist_cmd { + get { + return ResourceManager.GetString("placelist_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Shows the list of available tags for the `{0}place` command.. + /// + public static string placelist_desc { + get { + return ResourceManager.GetString("placelist_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}placelist`. + /// + public static string placelist_usage { + get { + return ResourceManager.GetString("placelist_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to plant. /// @@ -4470,7 +4524,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Creates a poll, only person who has manage server permission can do it.. + /// Looks up a localized string similar to Creates a poll which requires users to send the number of the voting option to the bot.. /// public static string poll_desc { get { @@ -4541,6 +4595,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to publicpoll ppoll. + /// + public static string publicpoll_cmd { + get { + return ResourceManager.GetString("publicpoll_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Creates a public poll which requires users to type a number of the voting option in the channel command is ran in.. + /// + public static string publicpoll_desc { + get { + return ResourceManager.GetString("publicpoll_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}ppoll Question?;Answer1;Answ 2;A_3`. + /// + public static string publicpoll_usage { + get { + return ResourceManager.GetString("publicpoll_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to queue q yq. /// @@ -6431,6 +6512,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to togethertube totube. + /// + public static string togethertube_cmd { + get { + return ResourceManager.GetString("togethertube_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Creates a new room on <https://togethertube.com> and shows the link in the chat.. + /// + public static string togethertube_desc { + get { + return ResourceManager.GetString("togethertube_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}totube`. + /// + public static string togethertube_usage { + get { + return ResourceManager.GetString("togethertube_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to tq. /// @@ -7321,5 +7429,85 @@ namespace NadekoBot.Resources { return ResourceManager.GetString("youtube_usage", resourceCulture); } } + /// + /// Looks up a localized string similar to minecraftping mcping. + /// + public static string mcping_cmd { + get { + return ResourceManager.GetString("mcping_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Pings a minecraft server.. + /// + public static string mcping_desc { + get { + return ResourceManager.GetString("mcping_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}mcping 127.0.0.1:1337`. + /// + public static string mcping_usage { + get { + return ResourceManager.GetString("mcping_usage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to minecraftquery mcquery. + /// + public static string mcquery_cmd { + get { + return ResourceManager.GetString("mcquery_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Finds information about a minecraft server.. + /// + public static string mcquery_desc { + get { + return ResourceManager.GetString("mcquery_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}mcquery server:ip`. + /// + public static string mcquery_usage { + get { + return ResourceManager.GetString("mcquery_usage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to minecraftuser mcuser. + /// + public static string mcuser_cmd { + get { + return ResourceManager.GetString("mcuser_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Finds information about a minecraft user.. + /// + public static string mcuser_desc { + get { + return ResourceManager.GetString("mcuser_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}mcuser username or uuid`. + /// + public static string mcuser_usage { + get { + return ResourceManager.GetString("mcuser_usage", resourceCulture); + } + } } -} +} \ No newline at end of file diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 799ce4dc..a89a5669 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -1246,10 +1246,10 @@ award - Awards someone a certain amount of currency. + Awards someone a certain amount of currency. You can also specify a role name to award currency to all users in a role. - `{0}award 100 @person` + `{0}award 100 @person` or `{0}award 5 Role Of Gamblers` take @@ -1336,7 +1336,7 @@ poll - Creates a poll, only person who has manage server permission can do it. + Creates a poll which requires users to send the number of the voting option to the bot. `{0}poll Question?;Answer1;Answ 2;A_3` @@ -1971,33 +1971,6 @@ `{0}hs Ysera` - - minecraftping mcping - - - Pings a minecraft server. - - - `{0}mcping 127.0.0.1:1337` - - - minecraftuser mcuser - - - Finds information about a minecraft user. - - - `{0}mcuser username or uuid` - - - minecraftquery mcquery - - - Finds information about a minecraft server. - - - `{0}mcquery server:ip` - urbandict ud @@ -2116,7 +2089,7 @@ `{0}videocall "@SomeGuy"` - av avatar + avatar av Shows a mentioned person's avatar. @@ -2538,4 +2511,94 @@ `{0}xkcd` or `{0}xkcd 1400` or `{0}xkcd latest` - + + placelist + + + Shows the list of available tags for the `{0}place` command. + + + `{0}placelist` + + + place + + + 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. + + + `{0}place Cage` or `{0}place steven 500 400` + + + togethertube totube + + + Creates a new room on <https://togethertube.com> and shows the link in the chat. + + + `{0}totube` + + + publicpoll ppoll + + + Creates a public poll which requires users to type a number of the voting option in the channel command is ran in. + + + `{0}ppoll Question?;Answer1;Answ 2;A_3` + + + autotranslang atl + + + `{0}atl en>fr` + + + Sets your source and target language to be used with `{0}at`. Specify no arguments to remove previously set value. + + + autotrans at + + + Starts automatic translation of all messages by users who set their `{0}atl` in this channel. You can set "del" argument to automatically delete all translated user messages. + + + `{0}at` or `{0}at del` + + + listquotes liqu + + + `{0}liqu` or `{0}liqu 3` + + + Lists all quotes on the server ordered alphabetically. 15 Per page. + + + minecraftping mcping + + + Pings a minecraft server. + + + `{0}mcping 127.0.0.1:1337` + + + minecraftuser mcuser + + + Finds information about a minecraft user. + + + `{0}mcuser username or uuid` + + + minecraftquery mcquery + + + Finds information about a minecraft server. + + + `{0}mcquery server:ip` + + \ No newline at end of file From 807fe78ea285b4fb66d3326a0932ab0cc430e9b6 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 28 Oct 2016 12:32:29 +0200 Subject: [PATCH 15/58] commandlist fix --- docs/Commands List.md | 21 ++++++++++++--------- src/NadekoBot/Modules/Help/Help.cs | 4 ++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/docs/Commands List.md b/docs/Commands List.md index 2ed4d12d..003da472 100644 --- a/docs/Commands List.md +++ b/docs/Commands List.md @@ -1,17 +1,17 @@ -######For more information and how to setup your own NadekoBot, go to: -######You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com` +For more information and how to setup your own NadekoBot, go to: +You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com` ##Table Of Contents -- [CustomReactions](#customreactions) -- [ClashOfClans](#clashofclans) - [Searches](#searches) -- [Utility](#utility) -- [Permissions](#permissions) -- [Help](#help) -- [Administration](#administration) -- [NSFW](#nsfw) - [Games](#games) +- [Permissions](#permissions) +- [Utility](#utility) - [Gambling](#gambling) +- [CustomReactions](#customreactions) - [Music](#music) +- [ClashOfClans](#clashofclans) +- [NSFW](#nsfw) +- [Administration](#administration) +- [Help](#help) ### Administration @@ -285,6 +285,9 @@ Command and aliases | Description | Usage `~color` `~clr` | Shows you what color corresponds to that hex. | `~clr 00ff00` `~videocall` | Creates a private video call link for you and other mentioned people. The link is sent to mentioned people via a private message. | `~videocall "@SomeGuy"` `~avatar` `~av` | Shows a mentioned person's avatar. | `~av "@SomeGuy"` +`~minecraftping` `~mcping` | Pings a minecraft server. | `~mcping 127.0.0.1:1337` +`~minecraftquery` `~mcquery` | Finds information about a minecraft server. | `~mcquery server:ip` +`~minecraftuser` `~mcuser` | Finds information about a minecraft user. | `~mcuser username or uuid` `~lolban` | Shows top banned champions ordered by ban rate. | `~lolban` `~memelist` | Pulls a list of memes you can use with `~memegen` from http://memegen.link/templates/ | `~memelist` `~memegen` | Generates a meme from memelist with top and bottom text. | `~memegen biw "gets iced coffee" "in the winter"` diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index a25ed111..a11e1d60 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -125,8 +125,8 @@ namespace NadekoBot.Modules.Help public Task Hgit(IUserMessage umsg) { var helpstr = new StringBuilder(); - helpstr.AppendLine(@"######For more information and how to setup your own NadekoBot, go to: -######You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com`"); + helpstr.AppendLine(@"For more information and how to setup your own NadekoBot, go to: +You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com`"); helpstr.AppendLine("##Table Of Contents"); helpstr.AppendLine(string.Join("\n", NadekoBot.CommandService.Modules.Select(m => $"- [{m.Name}](#{m.Name.ToLowerInvariant()})"))); helpstr.AppendLine(); From ee1a7931ee7eace150a05d3d3ddaf357aa406dec Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 28 Oct 2016 12:36:02 +0200 Subject: [PATCH 16/58] commandlist update --- docs/Commands List.md | 20 ++++++++++---------- src/NadekoBot/Modules/Help/Help.cs | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/Commands List.md b/docs/Commands List.md index 2ed4d12d..2088905f 100644 --- a/docs/Commands List.md +++ b/docs/Commands List.md @@ -1,17 +1,17 @@ -######For more information and how to setup your own NadekoBot, go to: -######You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com` +For more information and how to setup your own NadekoBot, go to: +You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com` ##Table Of Contents +- [Help](#help) +- [Music](#music) - [CustomReactions](#customreactions) - [ClashOfClans](#clashofclans) -- [Searches](#searches) -- [Utility](#utility) -- [Permissions](#permissions) -- [Help](#help) -- [Administration](#administration) -- [NSFW](#nsfw) -- [Games](#games) - [Gambling](#gambling) -- [Music](#music) +- [Administration](#administration) +- [Games](#games) +- [Searches](#searches) +- [Permissions](#permissions) +- [Utility](#utility) +- [NSFW](#nsfw) ### Administration diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index a25ed111..a11e1d60 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -125,8 +125,8 @@ namespace NadekoBot.Modules.Help public Task Hgit(IUserMessage umsg) { var helpstr = new StringBuilder(); - helpstr.AppendLine(@"######For more information and how to setup your own NadekoBot, go to: -######You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com`"); + helpstr.AppendLine(@"For more information and how to setup your own NadekoBot, go to: +You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com`"); helpstr.AppendLine("##Table Of Contents"); helpstr.AppendLine(string.Join("\n", NadekoBot.CommandService.Modules.Select(m => $"- [{m.Name}](#{m.Name.ToLowerInvariant()})"))); helpstr.AppendLine(); From e8f6054c5a950a66fb3e24a9a768fde80e5505dd Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 28 Oct 2016 12:44:40 +0200 Subject: [PATCH 17/58] Fixes to v+t and blacklisting --- .../Modules/Administration/Commands/VoicePlusTextCommands.cs | 5 +++-- .../Modules/Permissions/Commands/BlacklistCommands.cs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs b/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs index cd9b4bc2..1e4ca219 100644 --- a/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs @@ -114,7 +114,7 @@ namespace NadekoBot.Modules.Administration var channel = (ITextChannel)msg.Channel; var guild = channel.Guild; - var botUser = guild.GetCurrentUser(); + var botUser = await guild.GetCurrentUserAsync().ConfigureAwait(false); if (!botUser.GuildPermissions.ManageRoles || !botUser.GuildPermissions.ManageChannels) { await channel.SendMessageAsync(":anger: `I require atleast manage roles and manage channels permissions to enable this feature (preffered Administration permission).`"); @@ -166,7 +166,8 @@ namespace NadekoBot.Modules.Administration { var channel = (ITextChannel)msg.Channel; var guild = channel.Guild; - if (!guild.GetCurrentUser().GuildPermissions.Administrator) + var botUser = await guild.GetCurrentUserAsync().ConfigureAwait(false); + if (!botUser.GuildPermissions.Administrator) { await channel.SendMessageAsync("`I need Administrator permission to do that.`").ConfigureAwait(false); return; diff --git a/src/NadekoBot/Modules/Permissions/Commands/BlacklistCommands.cs b/src/NadekoBot/Modules/Permissions/Commands/BlacklistCommands.cs index e538e2a6..bbffabcf 100644 --- a/src/NadekoBot/Modules/Permissions/Commands/BlacklistCommands.cs +++ b/src/NadekoBot/Modules/Permissions/Commands/BlacklistCommands.cs @@ -80,7 +80,7 @@ namespace NadekoBot.Modules.Permissions } await uow.CompleteAsync().ConfigureAwait(false); } - if (action == AddRemove.Rem) + if (action == AddRemove.Add) { TriviaGame tg; switch (type) From bc4d37c0fa9073fdc7156530e01c7737592cb9c1 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 28 Oct 2016 13:14:16 +0200 Subject: [PATCH 18/58] Added >typelist and >typedel commands --- .../Games/Commands/SpeedTypingCommands.cs | 41 ++++++++++++++ .../Resources/CommandStrings.Designer.cs | 54 +++++++++++++++++++ src/NadekoBot/Resources/CommandStrings.resx | 18 +++++++ 3 files changed, 113 insertions(+) diff --git a/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs b/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs index 466bc23a..801b4bab 100644 --- a/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs @@ -218,6 +218,47 @@ namespace NadekoBot.Modules.Games await channel.SendMessageAsync("Added new article for typing game.").ConfigureAwait(false); } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task Typelist(IUserMessage imsg, int page = 1) + { + var channel = (ITextChannel)imsg.Channel; + + if (page < 1) + return; + + var articles = TypingArticles.Skip((page - 1) * 15).Take(15); + + if (!articles.Any()) + { + await channel.SendMessageAsync($"{imsg.Author.Mention} `No articles found on that page.`").ConfigureAwait(false); + return; + } + var i = (page - 1) * 15; + await channel.SendMessageAsync(String.Join("\n", articles.Select(a => $"`#{++i}` - {a.Text.TrimTo(50)}"))) + .ConfigureAwait(false); + } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + [OwnerOnly] + public async Task Typedel(IUserMessage imsg, int index) + { + var channel = (ITextChannel)imsg.Channel; + + index -= 1; + if (index < 0 || index >= TypingArticles.Count) + return; + + var removed = TypingArticles[index]; + TypingArticles.RemoveAt(index); + + File.WriteAllText(typingArticlesPath, JsonConvert.SerializeObject(TypingArticles)); + + await channel.SendMessageAsync($"`Removed typing article:` #{index + 1} - {removed.Text.TrimTo(50)}") + .ConfigureAwait(false); + } } } } \ No newline at end of file diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index ef639f4c..542b2cb8 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -6701,6 +6701,60 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to typedel. + /// + public static string typedel_cmd { + get { + return ResourceManager.GetString("typedel_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Deletes a typing article given the ID.. + /// + public static string typedel_desc { + get { + return ResourceManager.GetString("typedel_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}typedel 3`. + /// + public static string typedel_usage { + get { + return ResourceManager.GetString("typedel_usage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to typelist. + /// + public static string typelist_cmd { + get { + return ResourceManager.GetString("typelist_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lists added typing articles with their IDs. 15 per page.. + /// + public static string typelist_desc { + get { + return ResourceManager.GetString("typelist_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}typelist` or `{0}typelist 3`. + /// + public static string typelist_usage { + get { + return ResourceManager.GetString("typelist_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to typestart. /// diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 23fdb67f..10c72d72 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2574,4 +2574,22 @@ Lists all quotes on the server ordered alphabetically. 15 Per page. + + typedel + + + Deletes a typing article given the ID. + + + `{0}typedel 3` + + + typelist + + + Lists added typing articles with their IDs. 15 per page. + + + `{0}typelist` or `{0}typelist 3` + \ No newline at end of file From 2f82ae28216637a18d0495ae4be6ca355ffa6cb7 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 28 Oct 2016 13:31:21 +0200 Subject: [PATCH 19/58] .listservers command added --- src/NadekoBot/Modules/Utility/Utility.cs | 23 ++++++++++++++++ .../Resources/CommandStrings.Designer.cs | 27 +++++++++++++++++++ src/NadekoBot/Resources/CommandStrings.resx | 9 +++++++ 3 files changed, 59 insertions(+) diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 8634c721..6933be88 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -177,6 +177,29 @@ namespace NadekoBot.Modules.Utility await msg.Channel.SendMessageAsync(result).ConfigureAwait(false); } + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + [OwnerOnly] + public async Task ListServers(IUserMessage imsg, int page = 1) + { + var channel = (ITextChannel)imsg.Channel; + + page -= 1; + + if (page < 0) + return; + + var guilds = NadekoBot.Client.GetGuilds().OrderBy(g => g.Name).Skip((page - 1) * 15).Take(15); + + if (!guilds.Any()) + { + await channel.SendMessageAsync("`No servers found on that page.`").ConfigureAwait(false); + return; + } + + await channel.SendMessageAsync(String.Join("\n", guilds.Select(g => $"`Name:` {g.Name} `Id:` {g.Id} `Members:` {g.GetUsers().Count} `OwnerId:`{g.OwnerId}"))).ConfigureAwait(false); + } + //[NadekoCommand, Usage, Description, Aliases] //[RequireContext(ContextType.Guild)] //public async Task TextToImage(IUserMessage msg, [Remainder] string arg) diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index 542b2cb8..abb53dd0 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -3434,6 +3434,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to listservers. + /// + public static string listservers_cmd { + get { + return ResourceManager.GetString("listservers_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lists servers the bot is on with some basic info. 15 per page.. + /// + public static string listservers_desc { + get { + return ResourceManager.GetString("listservers_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}listservers 3`. + /// + public static string listservers_usage { + get { + return ResourceManager.GetString("listservers_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to liststreams ls. /// diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 10c72d72..99877fdd 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2592,4 +2592,13 @@ `{0}typelist` or `{0}typelist 3` + + listservers + + + Lists servers the bot is on with some basic info. 15 per page. + + + `{0}listservers 3` + \ No newline at end of file From 7606a20c7f303cd428813c468c4d119c395a1296 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 28 Oct 2016 13:50:55 +0200 Subject: [PATCH 20/58] Fixed repeat message format --- .../Modules/Administration/Commands/MessageRepeater.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/MessageRepeater.cs b/src/NadekoBot/Modules/Administration/Commands/MessageRepeater.cs index 713fb7a2..44459e8f 100644 --- a/src/NadekoBot/Modules/Administration/Commands/MessageRepeater.cs +++ b/src/NadekoBot/Modules/Administration/Commands/MessageRepeater.cs @@ -159,7 +159,7 @@ namespace NadekoBot.Modules.Administration return old; }); - await channel.SendMessageAsync($"Repeating \"{rep.Repeater.Message}\" every {rep.Repeater.Interval} minutes").ConfigureAwait(false); + await channel.SendMessageAsync($"Repeating \"{rep.Repeater.Message}\" every {rep.Repeater.Interval.Days} days, {rep.Repeater.Interval.Hours} hours and {rep.Repeater.Interval.Minutes} minutes.").ConfigureAwait(false); } } } From c111f4c864b6780386b2bd6abe6c7f6510f8eba2 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 28 Oct 2016 14:08:02 +0200 Subject: [PATCH 21/58] !!n can now skip multiple songs, with consequences --- src/NadekoBot/Modules/Music/Music.cs | 11 ++++++++++- src/NadekoBot/Resources/CommandStrings.Designer.cs | 4 ++-- src/NadekoBot/Resources/CommandStrings.resx | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/NadekoBot/Modules/Music/Music.cs b/src/NadekoBot/Modules/Music/Music.cs index 70af561d..be775ab0 100644 --- a/src/NadekoBot/Modules/Music/Music.cs +++ b/src/NadekoBot/Modules/Music/Music.cs @@ -38,14 +38,23 @@ namespace NadekoBot.Modules.Music [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - public Task Next(IUserMessage umsg) + public Task Next(IUserMessage umsg, int skipCount = 1) { var channel = (ITextChannel)umsg.Channel; + if (skipCount < 1) + return Task.CompletedTask; + MusicPlayer musicPlayer; if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer)) return Task.CompletedTask; if (musicPlayer.PlaybackVoiceChannel == ((IGuildUser)umsg.Author).VoiceChannel) + { + while (--skipCount > 0) + { + musicPlayer.RemoveSongAt(0); + } musicPlayer.Next(); + } return Task.CompletedTask; } diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index abb53dd0..a0eec5a2 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -4119,7 +4119,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Goes to the next song in the queue. You have to be in the same voice channel as the bot.. + /// Looks up a localized string similar to Goes to the next song in the queue. You have to be in the same voice channel as the bot. You can skip multiple songs, but in that case songs will not be requeued if {0}rcs or {0}rpl is enabled.. /// public static string next_desc { get { @@ -4128,7 +4128,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `{0}n`. + /// Looks up a localized string similar to `{0}n` or `{0}n 5`. /// public static string next_usage { get { diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 99877fdd..3ef9cbb9 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -1426,10 +1426,10 @@ next n - Goes to the next song in the queue. You have to be in the same voice channel as the bot. + Goes to the next song in the queue. You have to be in the same voice channel as the bot. You can skip multiple songs, but in that case songs will not be requeued if {0}rcs or {0}rpl is enabled. - `{0}n` + `{0}n` or `{0}n 5` stop s From 371d21e785b0ba2127a1ebea445db40c8bf6f886 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 1 Nov 2016 19:14:56 +0100 Subject: [PATCH 22/58] Fixed blacklist not working properly for guild owners --- src/NadekoBot/Services/CommandHandler.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/NadekoBot/Services/CommandHandler.cs b/src/NadekoBot/Services/CommandHandler.cs index a70eabe4..1e7f2d15 100644 --- a/src/NadekoBot/Services/CommandHandler.cs +++ b/src/NadekoBot/Services/CommandHandler.cs @@ -110,16 +110,17 @@ namespace NadekoBot.Services _log.Warn("I do not have permission to filter words in channel with id " + usrMsg.Channel.Id, ex); } } - - BlacklistItem blacklistedItem; - if ((blacklistedItem = Permissions.BlacklistCommands.BlacklistedItems.FirstOrDefault(bi => - (bi.Type == BlacklistItem.BlacklistType.Server && bi.ItemId == guild?.Id) || - (bi.Type == BlacklistItem.BlacklistType.Channel && bi.ItemId == msg.Channel.Id) || - (bi.Type == BlacklistItem.BlacklistType.User && bi.ItemId == usrMsg.Author.Id))) != null) - { - return; - } } + + BlacklistItem blacklistedItem; + if ((blacklistedItem = Permissions.BlacklistCommands.BlacklistedItems.FirstOrDefault(bi => + (bi.Type == BlacklistItem.BlacklistType.Server && bi.ItemId == guild?.Id) || + (bi.Type == BlacklistItem.BlacklistType.Channel && bi.ItemId == msg.Channel.Id) || + (bi.Type == BlacklistItem.BlacklistType.User && bi.ItemId == usrMsg.Author.Id))) != null) + { + return; + } + var throwaway = Task.Run(async () => { var sw = new Stopwatch(); From 83e0ccd226969d9a58b741a6cc6b94ba66bfaf6a Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 3 Nov 2016 13:04:15 +0100 Subject: [PATCH 23/58] lolcommands have banrate percentage now --- src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs b/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs index 2108878f..3f0f61ab 100644 --- a/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs @@ -58,7 +58,7 @@ namespace NadekoBot.Modules.Searches { if (i % 2 == 0 && i != 0) sb.AppendLine(); - sb.Append($"`{i + 1}.` **{dataList[i]["name"]}** "); + sb.Append($"`{i + 1}.` **{dataList[i]["name"]}** {dataList[i]["general"]["banRate"]}% "); //sb.AppendLine($" ({dataList[i]["general"]["banRate"]}%)"); } From 1fe0c63f52a3d6d38ae8d1ebdaeafcbe63b3a43b Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 3 Nov 2016 13:05:04 +0100 Subject: [PATCH 24/58] Changed error message for ~lolban --- src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs b/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs index 3f0f61ab..c18eecdc 100644 --- a/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs @@ -67,7 +67,7 @@ namespace NadekoBot.Modules.Searches } catch (Exception) { - await channel.SendMessageAsync($":anger: Fail: Champion.gg didsabled ban data until next patch. Sorry for the inconvenience.").ConfigureAwait(false); + await channel.SendMessageAsync($":anger: `Something went wrong.`").ConfigureAwait(false); } } } From 17e6fc909b52c9742754dff1d9d16eddfb2e99cd Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sat, 5 Nov 2016 18:03:23 +0100 Subject: [PATCH 25/58] Fixed [@]everyone and [@]here mentions in LogServer commnds --- src/NadekoBot/Modules/Administration/Commands/LogCommand.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs b/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs index 40ac1a5d..23aa8e7c 100644 --- a/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs @@ -384,7 +384,7 @@ namespace NadekoBot.Modules.Administration πŸ‘€`{msg.Author.Username}`: {msg.Resolve(userHandling: UserMentionHandling.NameAndDiscriminator)}"; if (msg.Attachments.Any()) str += $"{Environment.NewLine}`Attachements`: {string.Join(", ", msg.Attachments.Select(a => a.ProxyUrl))}"; - await logChannel.SendMessageAsync(str).ConfigureAwait(false); + await logChannel.SendMessageAsync(str.SanitizeMentions()).ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); } }); @@ -421,8 +421,8 @@ namespace NadekoBot.Modules.Administration { try { await logChannel.SendMessageAsync($@"πŸ•”`{prettyCurrentTime}` **Message** πŸ“ `#{channel.Name}` πŸ‘€`{before.Author.Username}` - `Old:` {before.Resolve(userHandling: UserMentionHandling.NameAndDiscriminator)} - `New:` {after.Resolve(userHandling: UserMentionHandling.NameAndDiscriminator)}").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); } + `Old:` {before.Resolve(userHandling: UserMentionHandling.NameAndDiscriminator).SanitizeMentions()} + `New:` {after.Resolve(userHandling: UserMentionHandling.NameAndDiscriminator).SanitizeMentions()}").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); } }); return Task.CompletedTask; From 5c20c88253b22cb21c05c5a509013657676effd6 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sat, 5 Nov 2016 18:57:34 +0100 Subject: [PATCH 26/58] ~atf added --- src/NadekoBot/Modules/NSFW/NSFW.cs | 34 +++++++++++++++++++++ src/NadekoBot/Resources/CommandStrings.resx | 9 ++++++ 2 files changed, 43 insertions(+) diff --git a/src/NadekoBot/Modules/NSFW/NSFW.cs b/src/NadekoBot/Modules/NSFW/NSFW.cs index 93834390..bd3dac2f 100644 --- a/src/NadekoBot/Modules/NSFW/NSFW.cs +++ b/src/NadekoBot/Modules/NSFW/NSFW.cs @@ -41,6 +41,20 @@ namespace NadekoBot.Modules.NSFW await channel.SendMessageAsync(String.Join("\n\n", links)).ConfigureAwait(false); } + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task ATFbooru(IUserMessage umsg, [Remainder] string tag = null) + { + var channel = (ITextChannel)umsg.Channel; + + tag = tag?.Trim() ?? ""; + var link = await GetATFbooruImageLink(tag).ConfigureAwait(false); + if (string.IsNullOrWhiteSpace(link)) + await channel.SendMessageAsync("Search yielded no results ;("); + else + await channel.SendMessageAsync(link).ConfigureAwait(false); + } + [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] public async Task Danbooru(IUserMessage umsg, [Remainder] string tag = null) @@ -255,5 +269,25 @@ namespace NadekoBot.Modules.NSFW return "Error, do you have too many tags?"; } } + + public static async Task GetATFbooruImageLink(string tag) + { + var rng = new NadekoRandom(); + + var link = $"https://atfbooru.ninja/posts?" + + $"limit=100"; + if (!string.IsNullOrWhiteSpace(tag)) + link += $"&tags={tag.Replace(" ", "+")}"; + using (var http = new HttpClient()) + { + var webpage = await http.GetStringAsync(link).ConfigureAwait(false); + var matches = Regex.Matches(webpage, "data-file-url=\"(?.*?)\""); + + if (matches.Count == 0) + return null; + return $"https://atfbooru.ninja" + + $"{matches[rng.Next(0, matches.Count)].Groups["id"].Value}"; + } + } } } diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 3ef9cbb9..a9d42d0d 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2115,6 +2115,15 @@ `{0}danbooru yuri+kissing` + + atfbooru atf + + + Shows a random hentai image from atfbooru with a given tag. Tag is optional but preferred. + + + `{0}atfbooru yuri+kissing` + gelbooru From a7fefead64fb6403c1d84dcfa277d0b2ce4e7cc2 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sat, 5 Nov 2016 20:03:50 +0100 Subject: [PATCH 27/58] Custom reactions will no longer trigger if user/server is blacklisted or if there is a filtered word or invite in it. If custom reaction is triggered, no commands will be attempted to be triggered after it (if your CR has the same name as some command, only your CR will be ran) --- .../CustomReactions/CustomReactions.cs | 75 +++++++++---------- src/NadekoBot/Services/CommandHandler.cs | 12 +++ 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs b/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs index d13b143a..2882eb11 100644 --- a/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs +++ b/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs @@ -19,6 +19,7 @@ namespace NadekoBot.Modules.CustomReactions { public static ConcurrentHashSet GlobalReactions { get; } = new ConcurrentHashSet(); public static ConcurrentDictionary> GuildReactions { get; } = new ConcurrentDictionary>(); + static CustomReactions() { using (var uow = DbHandler.UnitOfWork()) @@ -30,49 +31,43 @@ namespace NadekoBot.Modules.CustomReactions } public CustomReactions(ILocalization loc, CommandService cmds, ShardedDiscordClient client) : base(loc, cmds, client) { - client.MessageReceived += (imsg) => + } + + public static async Task TryExecuteCustomReaction(IUserMessage umsg) + { + var channel = umsg.Channel as ITextChannel; + if (channel == null) + return false; + + var content = umsg.Content.Trim().ToLowerInvariant(); + ConcurrentHashSet reactions; + GuildReactions.TryGetValue(channel.Guild.Id, out reactions); + if (reactions != null && reactions.Any()) { - var umsg = imsg as IUserMessage; - if (umsg == null || imsg.Author.IsBot) - return Task.CompletedTask; - - var channel = umsg.Channel as ITextChannel; - if (channel == null) - return Task.CompletedTask; - - var t = Task.Run(async () => + var reaction = reactions.Where(cr => { + var hasTarget = cr.Response.ToLowerInvariant().Contains("%target%"); + var trigger = cr.TriggerWithContext(umsg).Trim().ToLowerInvariant(); + return ((hasTarget && content.StartsWith(trigger + " ")) || content == trigger); + }).Shuffle().FirstOrDefault(); + if (reaction != null) { - var content = umsg.Content.Trim().ToLowerInvariant(); - ConcurrentHashSet reactions; - GuildReactions.TryGetValue(channel.Guild.Id, out reactions); - if (reactions != null && reactions.Any()) - { - var reaction = reactions.Where(cr => { - var hasTarget = cr.Response.ToLowerInvariant().Contains("%target%"); - var trigger = cr.TriggerWithContext(umsg).Trim().ToLowerInvariant(); - return ((hasTarget && content.StartsWith(trigger + " ")) || content == trigger); - }).Shuffle().FirstOrDefault(); - if (reaction != null) - { - try { await channel.SendMessageAsync(reaction.ResponseWithContext(umsg)).ConfigureAwait(false); } catch { } - return; - } - } - var greaction = GlobalReactions.Where(cr => - { - var hasTarget = cr.Response.ToLowerInvariant().Contains("%target%"); - var trigger = cr.TriggerWithContext(umsg).Trim().ToLowerInvariant(); - return ((hasTarget && content.StartsWith(trigger + " ")) || content == trigger); - }).Shuffle().FirstOrDefault(); + try { await channel.SendMessageAsync(reaction.ResponseWithContext(umsg)).ConfigureAwait(false); } catch { } + return true; + } + } + var greaction = GlobalReactions.Where(cr => + { + var hasTarget = cr.Response.ToLowerInvariant().Contains("%target%"); + var trigger = cr.TriggerWithContext(umsg).Trim().ToLowerInvariant(); + return ((hasTarget && content.StartsWith(trigger + " ")) || content == trigger); + }).Shuffle().FirstOrDefault(); - if (greaction != null) - { - try { await channel.SendMessageAsync(greaction.ResponseWithContext(umsg)).ConfigureAwait(false); } catch { } - return; - } - }); - return Task.CompletedTask; - }; + if (greaction != null) + { + try { await channel.SendMessageAsync(greaction.ResponseWithContext(umsg)).ConfigureAwait(false); } catch { } + return true; + } + return false; } [NadekoCommand, Usage, Description, Aliases] diff --git a/src/NadekoBot/Services/CommandHandler.cs b/src/NadekoBot/Services/CommandHandler.cs index 1e7f2d15..52d4ba4f 100644 --- a/src/NadekoBot/Services/CommandHandler.cs +++ b/src/NadekoBot/Services/CommandHandler.cs @@ -18,6 +18,7 @@ using static NadekoBot.Modules.Permissions.Permissions; using System.Collections.Concurrent; using NadekoBot.Modules.Help; using static NadekoBot.Modules.Administration.Administration; +using NadekoBot.Modules.CustomReactions; namespace NadekoBot.Services { @@ -121,6 +122,17 @@ namespace NadekoBot.Services return; } + try + { + // maybe this message is a custom reaction + var crExecuted = await CustomReactions.TryExecuteCustomReaction(usrMsg).ConfigureAwait(false); + + //if it was, don't execute the command + if (crExecuted) + return; + } + catch { } + var throwaway = Task.Run(async () => { var sw = new Stopwatch(); From 1408367cc2a986bc0d8b9e51ad6a1903fd27d003 Mon Sep 17 00:00:00 2001 From: ZirconiumHacker Date: Sat, 5 Nov 2016 18:20:31 -0400 Subject: [PATCH 28/58] Updated widget due to discord api changes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7bb0d57e..f1bef229 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ![img](https://ci.appveyor.com/api/projects/status/gmu6b3ltc80hr3k9?svg=true) -[![Discord](https://discordapp.com/api/servers/117523346618318850/widget.png)](https://discord.gg/0ehQwTK2RBjAxzEY) +[![Discord](https://discordapp.com/api/guilds/117523346618318850/widget.png)](https://discord.gg/0ehQwTK2RBjAxzEY) [![Documentation Status](https://readthedocs.org/projects/nadekobot/badge/?version=latest)](http://nadekobot.readthedocs.io/en/1.0/?badge=latest) # NadekoBot From 8dfa7ee1c1f4d89007fbd4cdc5c1f5c4232483ac Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 6 Nov 2016 00:59:21 +0100 Subject: [PATCH 29/58] ~hentai changed, ~hentaibomb added (buffed ~hentai) --- src/NadekoBot/Modules/NSFW/NSFW.cs | 58 ++++++++++++++++--- .../Resources/CommandStrings.Designer.cs | 58 ++++++++++++++++++- src/NadekoBot/Resources/CommandStrings.resx | 17 ++++-- .../Services/Impl/GoogleApiService.cs | 4 ++ 4 files changed, 122 insertions(+), 15 deletions(-) diff --git a/src/NadekoBot/Modules/NSFW/NSFW.cs b/src/NadekoBot/Modules/NSFW/NSFW.cs index bd3dac2f..2ae6a96e 100644 --- a/src/NadekoBot/Modules/NSFW/NSFW.cs +++ b/src/NadekoBot/Modules/NSFW/NSFW.cs @@ -30,11 +30,51 @@ namespace NadekoBot.Modules.NSFW tag = tag?.Trim() ?? ""; - var links = await Task.WhenAll(GetGelbooruImageLink("rating%3Aexplicit+" + tag), GetDanbooruImageLink("rating%3Aexplicit+" + tag)).ConfigureAwait(false); + tag = "rating%3Aexplicit+" + tag; + + var rng = new NadekoRandom(); + Task provider = Task.FromResult(""); + switch (rng.Next(0,4)) + { + case 0: + provider = GetDanbooruImageLink(tag); + break; + case 1: + provider = GetGelbooruImageLink(tag); + break; + case 2: + provider = GetATFbooruImageLink(tag); + break; + case 3: + provider = GetKonachanImageLink(tag); + break; + default: + break; + } + var link = await provider.ConfigureAwait(false); + if (string.IsNullOrWhiteSpace(link)) + await channel.SendMessageAsync("Search yielded no results ;(").ConfigureAwait(false); + else + await channel.SendMessageAsync(link).ConfigureAwait(false); + } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task HentaiBomb(IUserMessage umsg, [Remainder] string tag = null) + { + var channel = (ITextChannel)umsg.Channel; + + tag = tag?.Trim() ?? ""; + tag = "rating%3Aexplicit+" + tag; + + var links = await Task.WhenAll(GetGelbooruImageLink(tag), + GetDanbooruImageLink(tag), + GetKonachanImageLink(tag), + GetATFbooruImageLink(tag)).ConfigureAwait(false); if (links.All(l => l == null)) { - await channel.SendMessageAsync("`No results.`"); + await channel.SendMessageAsync("`No results.`").ConfigureAwait(false); return; } @@ -50,7 +90,7 @@ namespace NadekoBot.Modules.NSFW tag = tag?.Trim() ?? ""; var link = await GetATFbooruImageLink(tag).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(link)) - await channel.SendMessageAsync("Search yielded no results ;("); + await channel.SendMessageAsync("Search yielded no results ;(").ConfigureAwait(false); else await channel.SendMessageAsync(link).ConfigureAwait(false); } @@ -64,7 +104,7 @@ namespace NadekoBot.Modules.NSFW tag = tag?.Trim() ?? ""; var link = await GetDanbooruImageLink(tag).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(link)) - await channel.SendMessageAsync("Search yielded no results ;("); + await channel.SendMessageAsync("Search yielded no results ;(").ConfigureAwait(false); else await channel.SendMessageAsync(link).ConfigureAwait(false); } @@ -78,7 +118,7 @@ namespace NadekoBot.Modules.NSFW tag = tag?.Trim() ?? ""; var link = await GetKonachanImageLink(tag).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(link)) - await channel.SendMessageAsync("Search yielded no results ;("); + await channel.SendMessageAsync("Search yielded no results ;(").ConfigureAwait(false); else await channel.SendMessageAsync(link).ConfigureAwait(false); } @@ -92,7 +132,7 @@ namespace NadekoBot.Modules.NSFW tag = tag?.Trim() ?? ""; var link = await GetGelbooruImageLink(tag).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(link)) - await channel.SendMessageAsync("Search yielded no results ;("); + await channel.SendMessageAsync("Search yielded no results ;(").ConfigureAwait(false); else await channel.SendMessageAsync(link).ConfigureAwait(false); } @@ -106,7 +146,7 @@ namespace NadekoBot.Modules.NSFW tag = tag?.Trim() ?? ""; var link = await GetRule34ImageLink(tag).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(link)) - await channel.SendMessageAsync("Search yielded no results ;("); + await channel.SendMessageAsync("Search yielded no results ;(").ConfigureAwait(false); else await channel.SendMessageAsync(link).ConfigureAwait(false); } @@ -120,7 +160,7 @@ namespace NadekoBot.Modules.NSFW tag = tag?.Trim() ?? ""; var link = await GetE621ImageLink(tag).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(link)) - await channel.SendMessageAsync("Search yielded no results ;("); + await channel.SendMessageAsync("Search yielded no results ;(").ConfigureAwait(false); else await channel.SendMessageAsync(link).ConfigureAwait(false); } @@ -190,7 +230,7 @@ namespace NadekoBot.Modules.NSFW if (matches.Count == 0) return null; - return await NadekoBot.Google.ShortenUrl(matches[rng.Next(0, matches.Count)].Groups["ll"].Value).ConfigureAwait(false); + return matches[rng.Next(0, matches.Count)].Groups["ll"].Value; } } diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index a0eec5a2..b34b06f9 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -464,6 +464,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to atfbooru atf. + /// + public static string atfbooru_cmd { + get { + return ResourceManager.GetString("atfbooru_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Shows a random hentai image from atfbooru with a given tag. Tag is optional but preferred.. + /// + public static string atfbooru_desc { + get { + return ResourceManager.GetString("atfbooru_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}atfbooru yuri+kissing`. + /// + public static string atfbooru_usage { + get { + return ResourceManager.GetString("atfbooru_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to autoassignrole aar. /// @@ -2823,7 +2850,7 @@ namespace NadekoBot.Resources { } /// - /// 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.. + /// Looks up a localized string similar to Shows a hentai image from a random website (gelbooru or danbooru or konachan or atfbooru) with a given tag. Tag is optional but preferred. Only 1 tag allowed.. /// public static string hentai_desc { get { @@ -2840,6 +2867,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to hentaibomb. + /// + public static string hentaibomb_cmd { + get { + return ResourceManager.GetString("hentaibomb_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Shows a total 4 images (from gelbooru, danbooru, konachan and atfbooru). Tag is optional but preferred.. + /// + public static string hentaibomb_desc { + get { + return ResourceManager.GetString("hentaibomb_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}hentaibomb yuri`. + /// + public static string hentaibomb_usage { + get { + return ResourceManager.GetString("hentaibomb_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to hgit. /// @@ -3147,7 +3201,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Shows a random hentai image from konachan with a given tag. Tag is optional but preferred. (multiple tags are appended with +). + /// Looks up a localized string similar to Shows a random hentai image from konachan with a given tag. Tag is optional but preferred.. /// public static string konachan_desc { get { diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index a9d42d0d..e414ffe5 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2101,7 +2101,7 @@ hentai - Shows a 2 random images (from gelbooru and danbooru) with a given tag. Tag is optional but preferred. Only 1 tag allowed. + Shows a hentai image from a random website (gelbooru or danbooru or konachan or atfbooru) with a given tag. Tag is optional but preferred. Only 1 tag allowed. `{0}hentai yuri` @@ -2115,7 +2115,7 @@ `{0}danbooru yuri+kissing` - + atfbooru atf @@ -2123,7 +2123,7 @@ `{0}atfbooru yuri+kissing` - + gelbooru @@ -2461,7 +2461,7 @@ konachan - Shows a random hentai image from konachan with a given tag. Tag is optional but preferred. (multiple tags are appended with +) + Shows a random hentai image from konachan with a given tag. Tag is optional but preferred. `{0}konachan yuri` @@ -2610,4 +2610,13 @@ `{0}listservers 3` + + hentaibomb + + + Shows a total 4 images (from gelbooru, danbooru, konachan and atfbooru). Tag is optional but preferred. + + + `{0}hentaibomb yuri` + \ No newline at end of file diff --git a/src/NadekoBot/Services/Impl/GoogleApiService.cs b/src/NadekoBot/Services/Impl/GoogleApiService.cs index 5d578dc1..860a379c 100644 --- a/src/NadekoBot/Services/Impl/GoogleApiService.cs +++ b/src/NadekoBot/Services/Impl/GoogleApiService.cs @@ -91,6 +91,10 @@ namespace NadekoBot.Services.Impl { if (string.IsNullOrWhiteSpace(url)) throw new ArgumentNullException(nameof(url)); + + if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.GoogleApiKey)) + return url; + try { var response = await sh.Url.Insert(new Url { LongUrl = url }).ExecuteAsync(); From bffb9912647bbaaf8fd11ade41293df563b6b76a Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 6 Nov 2016 01:02:38 +0100 Subject: [PATCH 30/58] .sb now requires kick+manage messages instead of ban --- src/NadekoBot/Modules/Administration/Administration.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Administration/Administration.cs b/src/NadekoBot/Modules/Administration/Administration.cs index 46176fcf..d7f72186 100644 --- a/src/NadekoBot/Modules/Administration/Administration.cs +++ b/src/NadekoBot/Modules/Administration/Administration.cs @@ -311,7 +311,8 @@ namespace NadekoBot.Modules.Administration [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - [RequirePermission(GuildPermission.BanMembers)] + [RequirePermission(GuildPermission.KickMembers)] + [RequirePermission(GuildPermission.ManageMessages)] public async Task Softban(IUserMessage umsg, IGuildUser user, [Remainder] string msg = null) { var channel = (ITextChannel)umsg.Channel; From 2248298bc9252b85b45b4d0c8ea70cbd2aa85cc2 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 6 Nov 2016 20:46:17 +0100 Subject: [PATCH 31/58] Names of the people who dm the bot now properly show up when .fwmsgs is enabled --- .../Modules/Administration/Commands/DMForwardCommands.cs | 2 +- src/NadekoBot/Modules/Utility/Utility.cs | 2 -- src/NadekoBot/project.json | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/DMForwardCommands.cs b/src/NadekoBot/Modules/Administration/Commands/DMForwardCommands.cs index 9a872341..c755d34d 100644 --- a/src/NadekoBot/Modules/Administration/Commands/DMForwardCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/DMForwardCommands.cs @@ -80,7 +80,7 @@ namespace NadekoBot.Modules.Administration { var firstOwnerChannel = ownerChannels.First(); if (firstOwnerChannel.Recipient.Id != msg.Author.Id) - try { await firstOwnerChannel.SendMessageAsync(msg.Content).ConfigureAwait(false); } catch { } + try { await firstOwnerChannel.SendMessageAsync(toSend).ConfigureAwait(false); } catch { } } } } diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 6933be88..fb4a95a9 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -169,8 +169,6 @@ namespace NadekoBot.Modules.Utility { var matches = emojiFinder.Matches(emojis); - - var result = string.Join("\n", matches.Cast() .Select(m => $"`Name:` {m.Groups["name"]} `Link:` http://discordapp.com/api/emojis/{m.Groups["id"]}.png")); diff --git a/src/NadekoBot/project.json b/src/NadekoBot/project.json index 5d021051..9ed621ff 100644 --- a/src/NadekoBot/project.json +++ b/src/NadekoBot/project.json @@ -7,7 +7,7 @@ "emitEntryPoint": true, "allowUnsafe": true, "compile": { - "exclude": [ "data" ] + "exclude": [ "data", "credentials.json", "credentials_example.json" ] }, "copyToOutput": { "include": [ "data" ], From 3611817e220d04b5492879e6f87f4003f169d5a1 Mon Sep 17 00:00:00 2001 From: fkndean Date: Sun, 6 Nov 2016 16:04:24 -0500 Subject: [PATCH 32/58] Add Minecraft Commands --- src/NadekoBot/Modules/Searches/Searches.cs | 89 ++++++++++++++++++- .../Resources/CommandStrings.Designer.cs | 54 +++++++++++ src/NadekoBot/Resources/CommandStrings.resx | 18 ++++ 3 files changed, 159 insertions(+), 2 deletions(-) diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 9a370f80..5d700d6c 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -4,6 +4,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Linq; +using System.Text; using System.Net.Http; using NadekoBot.Services; using System.Threading.Tasks; @@ -225,7 +226,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 throw new KeyNotFoundException("Cannot find a card by that name"); foreach (var item in items.Where(item => item.HasValues && item["img"] != null).Take(4)) { - using (var sr =await http.GetStreamAsync(item["img"].ToString())) + using (var sr = await http.GetStreamAsync(item["img"].ToString())) { var imgStream = new MemoryStream(); await sr.CopyToAsync(imgStream); @@ -271,7 +272,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 try { var items = JObject.Parse(res); - var sb = new System.Text.StringBuilder(); + var sb = new StringBuilder(); sb.AppendLine($"`Term:` {items["list"][0]["word"].ToString()}"); sb.AppendLine($"`Definition:` {items["list"][0]["definition"].ToString()}"); sb.Append($"`Link:` <{await _google.ShortenUrl(items["list"][0]["permalink"].ToString()).ConfigureAwait(false)}>"); @@ -464,6 +465,90 @@ $@"🌍 **Weather for** 【{obj["target"]}】 } } + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task MCPing(IUserMessage umsg, [Remainder] string query = null) + { + var channel = (ITextChannel)umsg.Channel; + var arg = query; + if (string.IsNullOrWhiteSpace(arg)) + { + await channel.SendMessageAsync("πŸ’’ Please enter a `ip:port`.").ConfigureAwait(false); + return; + } + await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); + using (var http = new HttpClient()) + { + http.DefaultRequestHeaders.Clear(); + string ip = arg.Split(':')[0]; + string port = arg.Split(':')[1]; + var res = await http.GetStringAsync($"https://api.minetools.eu/ping/{Uri.EscapeUriString(ip)}/{Uri.EscapeUriString(port)}").ConfigureAwait(false); + try + { + var items = JObject.Parse(res); + var sb = new StringBuilder(); + int ping = (int)Math.Ceiling(Double.Parse(items["latency"].ToString())); + sb.AppendLine($"`Server:` {arg}"); + sb.AppendLine($"`Version:` {items["version"]["name"].ToString()} / Protocol {items["version"]["protocol"].ToString()}"); + sb.AppendLine($"`Description:` {items["description"].ToString()}"); + sb.AppendLine($"`Online Players:` {items["players"]["online"].ToString()}/{items["players"]["max"].ToString()}"); + sb.Append($"`Latency:` {ping}"); + await channel.SendMessageAsync(sb.ToString()); + } + catch + { + await channel.SendMessageAsync($"πŸ’’ Failed finding `{arg}`.").ConfigureAwait(false); + } + } + } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task MCQ(IUserMessage umsg, [Remainder] string query = null) + { + var channel = (ITextChannel)umsg.Channel; + var arg = query; + if (string.IsNullOrWhiteSpace(arg)) + { + await channel.SendMessageAsync("πŸ’’ Please enter a `ip:port`.").ConfigureAwait(false); + return; + } + await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); + using (var http = new HttpClient()) + { + http.DefaultRequestHeaders.Clear(); + try + { + string ip = arg.Split(':')[0]; + string port = arg.Split(':')[1]; + var res = await http.GetStringAsync($"https://api.minetools.eu/query/{Uri.EscapeUriString(ip)}/{Uri.EscapeUriString(port)}").ConfigureAwait(false); + var items = JObject.Parse(res); + var sb = new StringBuilder(); + sb.AppendLine($"`Server:` {arg.ToString()} γ€˜Status: {items["status"]}γ€™"); + sb.AppendLine($"`Player List:`"); + for (int i = 0; i < items["Playerlist"].Count(); i++) + { + if (i == 5) + { + break; + } + else + { + sb.AppendLine($"γ€”{i + 1}. {items["Playerlist"][i]}〕"); + } + } + sb.AppendLine($"`Online Players:` {items["Players"]} / {items["MaxPlayers"]}"); + sb.AppendLine($"`Plugins:` {items["Plugins"]}"); + sb.Append($"`Version:` {items["Version"]}"); + await channel.SendMessageAsync(sb.ToString()); + } + catch + { + await channel.SendMessageAsync($"πŸ’’ Failed finding server `{arg}`.").ConfigureAwait(false); + } + } + } + public static async Task ValidateQuery(ITextChannel ch, string query) { if (!string.IsNullOrEmpty(query.Trim())) return true; diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index b34b06f9..70df73b6 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -3937,6 +3937,60 @@ namespace NadekoBot.Resources { return ResourceManager.GetString("memegen_desc", resourceCulture); } } + + /// + /// Looks up a localized string similar to minecraftping mcping. + /// + public static string mcping_cmd { + get { + return ResourceManager.GetString("mcping_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Pings a minecraft server.. + /// + public static string mcping_desc { + get { + return ResourceManager.GetString("mcping_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}mcping 127.0.0.1:1337`. + /// + public static string mcping_usage { + get { + return ResourceManager.GetString("mcping_usage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to minecraftquery mcq. + /// + public static string mcq_cmd { + get { + return ResourceManager.GetString("mcq_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Finds information about a minecraft server.. + /// + public static string mcq_desc { + get { + return ResourceManager.GetString("mcq_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}mcq server:ip`. + /// + public static string mcq_usage { + get { + return ResourceManager.GetString("mcq_usage", resourceCulture); + } + } /// /// Looks up a localized string similar to `{0}memegen biw "gets iced coffee" "in the winter"`. diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index e414ffe5..54b18ef6 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2619,4 +2619,22 @@ `{0}hentaibomb yuri` + + minecraftping mcping + + + Pings a minecraft server. + + + `{0}mcping 127.0.0.1:25565` + + + minecraftquery mcq + + + Finds information about a minecraft server. + + + `{0}mcq server:ip` + \ No newline at end of file From ac06c9b48b8bc795ff4a4da50b1115b7feca05e5 Mon Sep 17 00:00:00 2001 From: fkndean Date: Sun, 6 Nov 2016 17:29:32 -0500 Subject: [PATCH 33/58] MCQ minor consistency fix --- src/NadekoBot/Modules/Searches/Searches.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 5d700d6c..4ee6f93b 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -524,18 +524,12 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var res = await http.GetStringAsync($"https://api.minetools.eu/query/{Uri.EscapeUriString(ip)}/{Uri.EscapeUriString(port)}").ConfigureAwait(false); var items = JObject.Parse(res); var sb = new StringBuilder(); + int i = 0; sb.AppendLine($"`Server:` {arg.ToString()} γ€˜Status: {items["status"]}γ€™"); - sb.AppendLine($"`Player List:`"); - for (int i = 0; i < items["Playerlist"].Count(); i++) + sb.AppendLine($"`Player List (First 5):`"); + foreach (var item in items["Playerlist"].Take(5)) { - if (i == 5) - { - break; - } - else - { - sb.AppendLine($"γ€”{i + 1}. {items["Playerlist"][i]}〕"); - } + sb.AppendLine($"γ€”:rosette: {item}〕"); } sb.AppendLine($"`Online Players:` {items["Players"]} / {items["MaxPlayers"]}"); sb.AppendLine($"`Plugins:` {items["Plugins"]}"); From 56eb10cf8175a9328460f5a64a8c481955c46f6a Mon Sep 17 00:00:00 2001 From: fkndean Date: Sun, 6 Nov 2016 17:30:47 -0500 Subject: [PATCH 34/58] bah :camel: --- src/NadekoBot/Modules/Searches/Searches.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 4ee6f93b..f4e0ef2c 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -524,7 +524,6 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var res = await http.GetStringAsync($"https://api.minetools.eu/query/{Uri.EscapeUriString(ip)}/{Uri.EscapeUriString(port)}").ConfigureAwait(false); var items = JObject.Parse(res); var sb = new StringBuilder(); - int i = 0; sb.AppendLine($"`Server:` {arg.ToString()} γ€˜Status: {items["status"]}γ€™"); sb.AppendLine($"`Player List (First 5):`"); foreach (var item in items["Playerlist"].Take(5)) From c06b1ae33ca1a8516103c11a390c714f68b20401 Mon Sep 17 00:00:00 2001 From: fkndean Date: Sun, 6 Nov 2016 17:58:04 -0500 Subject: [PATCH 35/58] Wikia Search --- src/NadekoBot/Modules/Searches/Searches.cs | 35 +++++++++++++++++++ .../Resources/CommandStrings.Designer.cs | 27 ++++++++++++++ src/NadekoBot/Resources/CommandStrings.resx | 9 +++++ 3 files changed, 71 insertions(+) diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index f4e0ef2c..aee7f422 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -464,6 +464,41 @@ $@"🌍 **Weather for** 【{obj["target"]}】 return matches[rng.Next(0, matches.Count)].Groups["url"].Value; } } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task Wikia(IUserMessage umsg, string targ, [Remainder] string query = null) + { + var channel = (ITextChannel)umsg.Channel; + var arg = query; + if (string.IsNullOrWhiteSpace(arg)) + { + await channel.SendMessageAsync("πŸ’’ Please enter `target query`.").ConfigureAwait(false); + return; + } + await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); + using (var http = new HttpClient()) + { + http.DefaultRequestHeaders.Clear(); + string target = targ; + string search = arg; + try + { + var res = await http.GetStringAsync($"http://www.{Uri.EscapeUriString(target)}.wikia.com/api/v1/Search/List?query={Uri.EscapeUriString(search)}&limit=25&minArticleQuality=10&batch=1&namespaces=0%2C14").ConfigureAwait(false); + var items = JObject.Parse(res); + var sb = new StringBuilder(); + sb.AppendLine($"`Found:` {items["items"][0]["title"].ToString()}"); + sb.AppendLine($"`Total Found:` {items["total"].ToString()}"); + sb.AppendLine($"`Batch:` {items["currentBatch"].ToString()}/{items["batches"].ToString()}"); + sb.Append($"`URL:` <{await _google.ShortenUrl(items["items"][0]["url"].ToString()).ConfigureAwait(false)}> / `Quality`: {items["items"][0]["quality"].ToString()}"); + await channel.SendMessageAsync(sb.ToString()); + } + catch + { + await channel.SendMessageAsync($"πŸ’’ Failed finding `{arg}`.").ConfigureAwait(false); + } + } + } [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index 70df73b6..15c84b56 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -7510,6 +7510,33 @@ namespace NadekoBot.Resources { return ResourceManager.GetString("wiki_usage", resourceCulture); } } + + /// + /// Looks up a localized string similar to wikia. + /// + public static string wikia_cmd { + get { + return ResourceManager.GetString("wikia_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Gives you back a wikia link. + /// + public static string wikia_desc { + get { + return ResourceManager.GetString("wikia_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}wikia target query`. + /// + public static string wikia_usage { + get { + return ResourceManager.GetString("wikia_usage", resourceCulture); + } + } /// /// Looks up a localized string similar to wowjoke. diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 54b18ef6..98faafae 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2637,4 +2637,13 @@ `{0}mcq server:ip` + + wikia + + + Gives you back a wikia link + + + `{0}wikia target query` + \ No newline at end of file From f9fb9d2f7631344c4ee2b0c0206806750c1d7435 Mon Sep 17 00:00:00 2001 From: fkndean Date: Mon, 7 Nov 2016 07:29:36 -0500 Subject: [PATCH 36/58] also check targ for null or whitespace --- src/NadekoBot/Modules/Searches/Searches.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index aee7f422..76edb462 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -471,7 +471,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 { var channel = (ITextChannel)umsg.Channel; var arg = query; - if (string.IsNullOrWhiteSpace(arg)) + if (string.IsNullOrWhiteSpace(targ) || string.IsNullOrWhiteSpace(arg)) { await channel.SendMessageAsync("πŸ’’ Please enter `target query`.").ConfigureAwait(false); return; From 3677fe2ff1c964e4e6225ef4b7d63808fda9bdb1 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 7 Nov 2016 22:50:00 +0100 Subject: [PATCH 37/58] >cleverbot added --- .../20161107213222_Cleverbot.Designer.cs | 781 ++++++++++++++++++ .../Migrations/20161107213222_Cleverbot.cs | 25 + .../NadekoSqliteContextModelSnapshot.cs | 2 + .../Games/Commands/CleverBotCommands.cs | 171 ++++ src/NadekoBot/Resources/CommandStrings.resx | 9 + src/NadekoBot/Services/CommandHandler.cs | 10 + .../Services/Database/Models/GuildConfig.cs | 1 + .../Repositories/IGuildConfigRepository.cs | 1 + .../Impl/GuildConfigRepository.cs | 10 + src/NadekoBot/Services/Impl/BotCredentials.cs | 6 + src/NadekoBot/credentials_example.json | 4 +- 11 files changed, 1019 insertions(+), 1 deletion(-) create mode 100644 src/NadekoBot/Migrations/20161107213222_Cleverbot.Designer.cs create mode 100644 src/NadekoBot/Migrations/20161107213222_Cleverbot.cs create mode 100644 src/NadekoBot/Modules/Games/Commands/CleverBotCommands.cs diff --git a/src/NadekoBot/Migrations/20161107213222_Cleverbot.Designer.cs b/src/NadekoBot/Migrations/20161107213222_Cleverbot.Designer.cs new file mode 100644 index 00000000..18f9b61a --- /dev/null +++ b/src/NadekoBot/Migrations/20161107213222_Cleverbot.Designer.cs @@ -0,0 +1,781 @@ +ο»Ώusing System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using NadekoBot.Services.Database.Impl; + +namespace NadekoBot.Migrations +{ + [DbContext(typeof(NadekoSqliteContext))] + [Migration("20161107213222_Cleverbot")] + partial class Cleverbot + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.0.0-rtm-21431"); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.BlacklistItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("ItemId"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("BlacklistItem"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.BotConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BufferSize"); + + b.Property("CurrencyGenerationChance"); + + b.Property("CurrencyGenerationCooldown"); + + b.Property("CurrencyName"); + + b.Property("CurrencyPluralName"); + + b.Property("CurrencySign"); + + b.Property("DMHelpString"); + + b.Property("ForwardMessages"); + + b.Property("ForwardToAllOwners"); + + b.Property("HelpString"); + + b.Property("MigrationVersion"); + + b.Property("RemindMessageFormat"); + + b.Property("RotatingStatuses"); + + b.HasKey("Id"); + + b.ToTable("BotConfig"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashCaller", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BaseDestroyed"); + + b.Property("CallUser"); + + b.Property("ClashWarId"); + + b.Property("SequenceNumber"); + + b.Property("Stars"); + + b.Property("TimeAdded"); + + b.HasKey("Id"); + + b.HasIndex("ClashWarId"); + + b.ToTable("ClashCallers"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashWar", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("EnemyClan"); + + b.Property("GuildId"); + + b.Property("Size"); + + b.Property("StartedAt"); + + b.Property("WarState"); + + b.HasKey("Id"); + + b.ToTable("ClashOfClans"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CommandCooldown", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CommandName"); + + b.Property("GuildConfigId"); + + b.Property("Seconds"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("CommandCooldown"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ConvertUnit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("InternalTrigger"); + + b.Property("Modifier"); + + b.Property("UnitType"); + + b.HasKey("Id"); + + b.ToTable("ConversionUnits"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Currency"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CurrencyTransaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("Reason"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.ToTable("CurrencyTransactions"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CustomReaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("GuildId"); + + b.Property("IsRegex"); + + b.Property("OwnerOnly"); + + b.Property("Response"); + + b.Property("Trigger"); + + b.HasKey("Id"); + + b.ToTable("CustomReactions"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Donator", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("Name"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Donators"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.EightBallResponse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("Text"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("EightBallResponses"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FilterChannelId", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("GuildConfigId"); + + b.Property("GuildConfigId1"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.HasIndex("GuildConfigId1"); + + b.ToTable("FilterChannelId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FilteredWord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("GuildConfigId"); + + b.Property("Word"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("FilteredWord"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FollowedStream", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("GuildConfigId"); + + b.Property("GuildId"); + + b.Property("Type"); + + b.Property("Username"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("FollowedStream"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.GCChannelId", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("GuildConfigId"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("GCChannelId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.GuildConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AutoAssignRoleId"); + + b.Property("AutoDeleteByeMessages"); + + b.Property("AutoDeleteGreetMessages"); + + b.Property("AutoDeleteGreetMessagesTimer"); + + b.Property("AutoDeleteSelfAssignedRoleMessages"); + + b.Property("ByeMessageChannelId"); + + b.Property("ChannelByeMessageText"); + + b.Property("ChannelGreetMessageText"); + + b.Property("CleverbotEnabled"); + + b.Property("DefaultMusicVolume"); + + b.Property("DeleteMessageOnCommand"); + + b.Property("DmGreetMessageText"); + + b.Property("ExclusiveSelfAssignedRoles"); + + b.Property("FilterInvites"); + + b.Property("FilterWords"); + + b.Property("GreetMessageChannelId"); + + b.Property("GuildId"); + + b.Property("LogSettingId"); + + b.Property("MuteRoleName"); + + b.Property("PermissionRole"); + + b.Property("RootPermissionId"); + + b.Property("SendChannelByeMessage"); + + b.Property("SendChannelGreetMessage"); + + b.Property("SendDmGreetMessage"); + + b.Property("VerbosePermissions"); + + b.Property("VoicePlusTextEnabled"); + + b.HasKey("Id"); + + b.HasIndex("GuildId") + .IsUnique(); + + b.HasIndex("LogSettingId"); + + b.HasIndex("RootPermissionId"); + + b.ToTable("GuildConfigs"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredLogChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("LogSettingId"); + + b.HasKey("Id"); + + b.HasIndex("LogSettingId"); + + b.ToTable("IgnoredLogChannels"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredVoicePresenceChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("LogSettingId"); + + b.HasKey("Id"); + + b.HasIndex("LogSettingId"); + + b.ToTable("IgnoredVoicePresenceCHannels"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.LogSetting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelCreated"); + + b.Property("ChannelDestroyed"); + + b.Property("ChannelId"); + + b.Property("ChannelUpdated"); + + b.Property("IsLogging"); + + b.Property("LogUserPresence"); + + b.Property("LogVoicePresence"); + + b.Property("MessageDeleted"); + + b.Property("MessageUpdated"); + + b.Property("UserBanned"); + + b.Property("UserJoined"); + + b.Property("UserLeft"); + + b.Property("UserPresenceChannelId"); + + b.Property("UserUnbanned"); + + b.Property("UserUpdated"); + + b.Property("VoicePresenceChannelId"); + + b.HasKey("Id"); + + b.ToTable("LogSettings"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ModulePrefix", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("ModuleName"); + + b.Property("Prefix"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("ModulePrefixes"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.MusicPlaylist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Author"); + + b.Property("AuthorId"); + + b.Property("Name"); + + b.HasKey("Id"); + + b.ToTable("MusicPlaylists"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("NextId"); + + b.Property("PrimaryTarget"); + + b.Property("PrimaryTargetId"); + + b.Property("SecondaryTarget"); + + b.Property("SecondaryTargetName"); + + b.Property("State"); + + b.HasKey("Id"); + + b.HasIndex("NextId") + .IsUnique(); + + b.ToTable("Permission"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.PlayingStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("Status"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("PlayingStatus"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.PlaylistSong", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("MusicPlaylistId"); + + b.Property("Provider"); + + b.Property("ProviderType"); + + b.Property("Query"); + + b.Property("Title"); + + b.Property("Uri"); + + b.HasKey("Id"); + + b.HasIndex("MusicPlaylistId"); + + b.ToTable("PlaylistSong"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Quote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AuthorId"); + + b.Property("AuthorName") + .IsRequired(); + + b.Property("GuildId"); + + b.Property("Keyword") + .IsRequired(); + + b.Property("Text") + .IsRequired(); + + b.HasKey("Id"); + + b.ToTable("Quotes"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.RaceAnimal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("Icon"); + + b.Property("Name"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("RaceAnimals"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Reminder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("IsPrivate"); + + b.Property("Message"); + + b.Property("ServerId"); + + b.Property("UserId"); + + b.Property("When"); + + b.HasKey("Id"); + + b.ToTable("Reminders"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Repeater", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("GuildId"); + + b.Property("Interval"); + + b.Property("Message"); + + b.HasKey("Id"); + + b.HasIndex("ChannelId") + .IsUnique(); + + b.ToTable("Repeaters"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.SelfAssignedRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("GuildId"); + + b.Property("RoleId"); + + b.HasKey("Id"); + + b.HasIndex("GuildId", "RoleId") + .IsUnique(); + + b.ToTable("SelfAssignableRoles"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.BlacklistItem", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("Blacklist") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashCaller", b => + { + b.HasOne("NadekoBot.Services.Database.Models.ClashWar", "ClashWar") + .WithMany("Bases") + .HasForeignKey("ClashWarId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CommandCooldown", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("CommandCooldowns") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.EightBallResponse", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("EightBallResponses") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FilterChannelId", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("FilterInvitesChannelIds") + .HasForeignKey("GuildConfigId"); + + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("FilterWordsChannelIds") + .HasForeignKey("GuildConfigId1"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FilteredWord", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("FilteredWords") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FollowedStream", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("FollowedStreams") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.GCChannelId", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("GenerateCurrencyChannelIds") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.GuildConfig", b => + { + b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") + .WithMany() + .HasForeignKey("LogSettingId"); + + b.HasOne("NadekoBot.Services.Database.Models.Permission", "RootPermission") + .WithMany() + .HasForeignKey("RootPermissionId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredLogChannel", b => + { + b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") + .WithMany("IgnoredChannels") + .HasForeignKey("LogSettingId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredVoicePresenceChannel", b => + { + b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") + .WithMany("IgnoredVoicePresenceChannelIds") + .HasForeignKey("LogSettingId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ModulePrefix", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("ModulePrefixes") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Permission", b => + { + b.HasOne("NadekoBot.Services.Database.Models.Permission", "Next") + .WithOne("Previous") + .HasForeignKey("NadekoBot.Services.Database.Models.Permission", "NextId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.PlayingStatus", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("RotatingStatusMessages") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.PlaylistSong", b => + { + b.HasOne("NadekoBot.Services.Database.Models.MusicPlaylist") + .WithMany("Songs") + .HasForeignKey("MusicPlaylistId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.RaceAnimal", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("RaceAnimals") + .HasForeignKey("BotConfigId"); + }); + } + } +} diff --git a/src/NadekoBot/Migrations/20161107213222_Cleverbot.cs b/src/NadekoBot/Migrations/20161107213222_Cleverbot.cs new file mode 100644 index 00000000..383bd250 --- /dev/null +++ b/src/NadekoBot/Migrations/20161107213222_Cleverbot.cs @@ -0,0 +1,25 @@ +ο»Ώusing System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace NadekoBot.Migrations +{ + public partial class Cleverbot : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CleverbotEnabled", + table: "GuildConfigs", + nullable: false, + defaultValue: false); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CleverbotEnabled", + table: "GuildConfigs"); + } + } +} diff --git a/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs b/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs index ddab89f1..13be0b66 100644 --- a/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs +++ b/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs @@ -332,6 +332,8 @@ namespace NadekoBot.Migrations b.Property("ChannelGreetMessageText"); + b.Property("CleverbotEnabled"); + b.Property("DefaultMusicVolume"); b.Property("DeleteMessageOnCommand"); diff --git a/src/NadekoBot/Modules/Games/Commands/CleverBotCommands.cs b/src/NadekoBot/Modules/Games/Commands/CleverBotCommands.cs new file mode 100644 index 00000000..a192a528 --- /dev/null +++ b/src/NadekoBot/Modules/Games/Commands/CleverBotCommands.cs @@ -0,0 +1,171 @@ +ο»Ώusing Discord; +using Discord.Commands; +using NadekoBot.Attributes; +using NadekoBot.Services; +using NadekoBot.Services.Database; +using Newtonsoft.Json; +using NLog; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; + +namespace NadekoBot.Modules.Games +{ + public partial class Games + { + [Group] + public class CleverBotCommands + { + private Logger _log { get; } + + class CleverAnswer { + public string Status { get; set; } + public string Response { get; set; } + } + public CleverBotCommands() + { + _log = LogManager.GetCurrentClassLogger(); + } + + //user#discrim is the key + public static ConcurrentHashSet ChannelsInConversation { get; } = new ConcurrentHashSet(); + public static ConcurrentHashSet CleverbotGuilds { get; } = new ConcurrentHashSet(); + + static CleverBotCommands() + { + using (var uow = DbHandler.UnitOfWork()) + { + CleverbotGuilds = new ConcurrentHashSet(uow.GuildConfigs.GetAll().Where(gc => gc.CleverbotEnabled).Select(gc => gc.GuildId)); + } + } + + public static async Task TryAsk(IUserMessage msg) { + var channel = msg.Channel as ITextChannel; + + if (channel == null) + return false; + + var nick = msg.Channel.Id + "NadekoBot"; + + if (!ChannelsInConversation.Contains(nick) && !CleverbotGuilds.Contains(channel.Guild.Id)) + return false; + + var nadekoId = NadekoBot.Client.GetCurrentUser().Id; + var normalMention = $"<@{nadekoId}> "; + var nickMention = $"<@!{nadekoId}> "; + string message; + if (msg.Content.StartsWith(normalMention)) + { + message = msg.Content.Substring(normalMention.Length); + } + else if (msg.Content.StartsWith(nickMention)) + { + message = msg.Content.Substring(nickMention.Length); + } + else + { + return false; + } + + await msg.Channel.TriggerTypingAsync().ConfigureAwait(false); + + using (var http = new HttpClient()) + { + var content = new FormUrlEncodedContent(new Dictionary + { + { "user", NadekoBot.Credentials.CleverbotApiUser}, + { "key", NadekoBot.Credentials.CleverbotApiKey}, + { "nick", nick}, + { "text", message}, + }); + var res = await http.PostAsync("https://cleverbot.io/1.0/ask", content).ConfigureAwait(false); + + if (res.StatusCode == System.Net.HttpStatusCode.OK) + { + try + { + var answer = JsonConvert.DeserializeObject(await res.Content.ReadAsStringAsync().ConfigureAwait(false)); + try + { + await msg.Channel.SendMessageAsync(WebUtility.HtmlDecode(answer.Response)).ConfigureAwait(false); + } + catch + { + await msg.Channel.SendMessageAsync(answer.Response).ConfigureAwait(false); // try twice :\ + } + } + catch { } + return true; + } + return false; + } + } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + [RequirePermission(ChannelPermission.ManageMessages)] + public async Task Cleverbot(IUserMessage imsg, string all = null) + { + var channel = (ITextChannel)imsg.Channel; + + if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.CleverbotApiKey) || + string.IsNullOrWhiteSpace(NadekoBot.Credentials.CleverbotApiKey)) + { + await channel.SendMessageAsync(":anger: `Bot owner didn't setup Cleverbot Api keys. Session will not start.`").ConfigureAwait(false); + return; + } + + if (all?.Trim().ToLowerInvariant() == "all") + { + var cleverbotEnabled = CleverbotGuilds.Add(channel.Guild.Id); + if (!cleverbotEnabled) + CleverbotGuilds.TryRemove(channel.Guild.Id); + + using (var uow = DbHandler.UnitOfWork()) + { + uow.GuildConfigs.SetCleverbotEnabled(channel.Guild.Id, cleverbotEnabled); + await uow.CompleteAsync().ConfigureAwait(false); + } + + await channel.SendMessageAsync($"{imsg.Author.Mention} `{(cleverbotEnabled ? "Enabled" : "Disabled")} cleverbot for all users.`").ConfigureAwait(false); + return; + } + + + var nick = channel.Id + "NadekoBot"; + + if (ChannelsInConversation.TryRemove(nick)) + { + await channel.SendMessageAsync($"{imsg.Author.Mention} `I will no longer reply to your messages starting with my mention.`").ConfigureAwait(false); + return; + } + + using (var http = new HttpClient()) + { + var content = new FormUrlEncodedContent(new Dictionary() + { + { "user", NadekoBot.Credentials.CleverbotApiUser}, + { "key", NadekoBot.Credentials.CleverbotApiKey}, + { "nick", nick}, + }); + var res = await http.PostAsync("https://cleverbot.io/1.0/create", content).ConfigureAwait(false); + if (res.StatusCode != System.Net.HttpStatusCode.OK) + { + await channel.SendMessageAsync($"{imsg.Author.Mention} `Something went wrong in starting your cleverbot session :\\`"); + _log.Warn(await res.Content.ReadAsStringAsync()); + return; + } + + ChannelsInConversation.Add(nick); + } + await channel.SendMessageAsync($"{imsg.Author.Mention} `I will reply to your messages starting with my mention.`").ConfigureAwait(false); + } + + } + } +} diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index e414ffe5..2c5db911 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2619,4 +2619,13 @@ `{0}hentaibomb yuri` + + cleverbot + + + Toggles cleverbot session. When enabled, the bot will reply to messages starting with bot mention in the channel this command is ran in. You can specify "all" parameter to enable it in the whole server. Custom reactions starting with %mention% won't work if cleverbot is enabled.' + + + `{0}cleverbot` + \ No newline at end of file diff --git a/src/NadekoBot/Services/CommandHandler.cs b/src/NadekoBot/Services/CommandHandler.cs index 52d4ba4f..f3f53855 100644 --- a/src/NadekoBot/Services/CommandHandler.cs +++ b/src/NadekoBot/Services/CommandHandler.cs @@ -19,6 +19,7 @@ using System.Collections.Concurrent; using NadekoBot.Modules.Help; using static NadekoBot.Modules.Administration.Administration; using NadekoBot.Modules.CustomReactions; +using NadekoBot.Modules.Games; namespace NadekoBot.Services { @@ -122,6 +123,15 @@ namespace NadekoBot.Services return; } + try + { + var cleverbotExecuted = await Games.CleverBotCommands.TryAsk(usrMsg); + + if (cleverbotExecuted) + return; + } + catch (Exception ex) { _log.Warn(ex, "Error in cleverbot"); } + try { // maybe this message is a custom reaction diff --git a/src/NadekoBot/Services/Database/Models/GuildConfig.cs b/src/NadekoBot/Services/Database/Models/GuildConfig.cs index c9cf16db..fc2bbe43 100644 --- a/src/NadekoBot/Services/Database/Models/GuildConfig.cs +++ b/src/NadekoBot/Services/Database/Models/GuildConfig.cs @@ -59,6 +59,7 @@ namespace NadekoBot.Services.Database.Models public HashSet FilterWordsChannelIds { get; set; } = new HashSet(); public string MuteRoleName { get; set; } + public bool CleverbotEnabled { get; set; } } public class FilterChannelId :DbEntity diff --git a/src/NadekoBot/Services/Database/Repositories/IGuildConfigRepository.cs b/src/NadekoBot/Services/Database/Repositories/IGuildConfigRepository.cs index 7a780380..8ca24dde 100644 --- a/src/NadekoBot/Services/Database/Repositories/IGuildConfigRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/IGuildConfigRepository.cs @@ -15,5 +15,6 @@ namespace NadekoBot.Services.Database.Repositories IEnumerable PermissionsForAll(); GuildConfig SetNewRootPermission(ulong guildId, Permission p); IEnumerable GetAllFollowedStreams(); + void SetCleverbotEnabled(ulong id, bool cleverbotEnabled); } } diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigRepository.cs b/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigRepository.cs index 1b3c1501..32f88f9d 100644 --- a/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigRepository.cs @@ -121,5 +121,15 @@ namespace NadekoBot.Services.Database.Repositories.Impl data.RootPermission = p; return data; } + + public void SetCleverbotEnabled(ulong id, bool cleverbotEnabled) + { + var conf = _set.FirstOrDefault(gc => gc.GuildId == id); + + if (conf == null) + return; + + conf.CleverbotEnabled = cleverbotEnabled; + } } } diff --git a/src/NadekoBot/Services/Impl/BotCredentials.cs b/src/NadekoBot/Services/Impl/BotCredentials.cs index d52e8ad7..a5f326eb 100644 --- a/src/NadekoBot/Services/Impl/BotCredentials.cs +++ b/src/NadekoBot/Services/Impl/BotCredentials.cs @@ -26,6 +26,8 @@ namespace NadekoBot.Services.Impl public string LoLApiKey { get; } public string OsuApiKey { get; } public string SoundCloudClientId { get; } + public string CleverbotApiUser { get; } + public string CleverbotApiKey { get; } public DB Db { get; } public int TotalShards { get; } @@ -50,6 +52,8 @@ namespace NadekoBot.Services.Impl ClientId = cm.ClientId; SoundCloudClientId = cm.SoundCloudClientId; CarbonKey = cm.CarbonKey; + CleverbotApiKey = cm.CleverbotApiKey; + CleverbotApiUser = cm.CleverbotApiUser; if (cm.Db == null) Db = new DB("sqlite", ""); else @@ -77,6 +81,8 @@ namespace NadekoBot.Services.Impl public string CarbonKey { get; set; } = ""; public DB Db { get; set; } public int TotalShards { get; set; } = 1; + public string CleverbotApiUser { get; set; } + public string CleverbotApiKey { get; set; } } private class DbModel diff --git a/src/NadekoBot/credentials_example.json b/src/NadekoBot/credentials_example.json index 34925301..50577cd6 100644 --- a/src/NadekoBot/credentials_example.json +++ b/src/NadekoBot/credentials_example.json @@ -12,5 +12,7 @@ "SoundCloudClientId": "", "CarbonKey": "", "Db": null, - "TotalShards": 1 + "TotalShards": 1, + "CleverbotApiUser": null, + "CleverbotApiKey": null } \ No newline at end of file From ccdd19d6ff78f0108602780a685c77c14bc69bdd Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 7 Nov 2016 23:11:34 +0100 Subject: [PATCH 38/58] commandlist updated --- docs/Commands List.md | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/docs/Commands List.md b/docs/Commands List.md index 2088905f..38be823c 100644 --- a/docs/Commands List.md +++ b/docs/Commands List.md @@ -1,17 +1,17 @@ For more information and how to setup your own NadekoBot, go to: You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com` ##Table Of Contents -- [Help](#help) +- [Searches](#searches) +- [NSFW](#nsfw) - [Music](#music) -- [CustomReactions](#customreactions) -- [ClashOfClans](#clashofclans) +- [Help](#help) +- [Permissions](#permissions) - [Gambling](#gambling) - [Administration](#administration) -- [Games](#games) -- [Searches](#searches) -- [Permissions](#permissions) - [Utility](#utility) -- [NSFW](#nsfw) +- [ClashOfClans](#clashofclans) +- [CustomReactions](#customreactions) +- [Games](#games) ### Administration @@ -26,7 +26,7 @@ Command and aliases | Description | Usage `.createrole` `.cr` | Creates a role with a given name. **Requires ManageRoles server permission.** | `.cr Awesome Role` `.rolecolor` `.rc` | Set a role's color to the hex or 0-255 rgb color value provided. **Requires ManageRoles server permission.** | `.rc Admin 255 200 100` or `.rc Admin ffba55` `.ban` `.b` | Bans a user by ID or name with an optional message. **Requires BanMembers server permission.** | `.b "@some Guy" Your behaviour is toxic.` -`.softban` `.sb` | Bans and then unbans a user by ID or name with an optional message. **Requires BanMembers server permission.** | `.sb "@some Guy" Your behaviour is toxic.` +`.softban` `.sb` | Bans and then unbans a user by ID or name with an optional message. **Requires KickMembers server permission.** **Requires ManageMessages server permission.** | `.sb "@some Guy" Your behaviour is toxic.` `.kick` `.k` | Kicks a mentioned user. **Requires KickMembers server permission.** | `.k "@some Guy" Your behaviour is toxic.` `.setmuterole` | Sets a name of the role which will be assigned to people who should be muted. Default is nadeko-mute. After specifying this role, restart commands which use mute as punishment. **Requires ManageRoles server permission.** | `.setmuterole Silenced` `.mute` | Mutes a mentioned user both from speaking and chatting. **Requires ManageRoles server permission.** **Requires MuteMembers server permission.** | `.mute @Someone` @@ -154,12 +154,15 @@ Command and aliases | Description | Usage `>poll` | Creates a poll which requires users to send the number of the voting option to the bot. **Requires ManageMessages server permission.** | `>poll Question?;Answer1;Answ 2;A_3` `>publicpoll` `>ppoll` | Creates a public poll which requires users to type a number of the voting option in the channel command is ran in. **Requires ManageMessages server permission.** | `>ppoll Question?;Answer1;Answ 2;A_3` `>pollend` | Stops active poll on this server and prints the results in this channel. **Requires ManageMessages server permission.** | `>pollend` +`>cleverbot` | Toggles cleverbot session. When enabled, the bot will reply to messages starting with bot mention in the channel this command is ran in. You can specify "all" parameter to enable it in the whole server. Custom reactions starting with %mention% won't work if cleverbot is enabled.' **Requires ManageMessages server permission.** | `>cleverbot` `>pick` | Picks the currency planted in this channel. | `>pick` `>plant` | Spend a unit of currency to plant it in this channel. (If bot is restarted or crashes, the currency will be lost) | `>plant` `>gencurrency` `>gc` | Toggles currency generation on this channel. Every posted message will have chance to spawn currency. Chance is specified by the Bot Owner. (default is 2%) **Requires ManageMessages server permission.** | `>gc` `>typestart` | Starts a typing contest. | `>typestart` `>typestop` | Stops a typing contest on the current channel. | `>typestop` `>typeadd` | Adds a new article to the typing contest. **Bot owner only.** | `>typeadd wordswords` +`>typelist` | Lists added typing articles with their IDs. 15 per page. | `>typelist` or `>typelist 3` +`>typedel` | Deletes a typing article given the ID. **Bot owner only.** | `>typedel 3` `>trivia` `>t` | Starts a game of trivia. You can add nohint to prevent hints.First player to get to 10 points wins by default. You can specify a different number. 30 seconds per question. | `>t` or `>t 5 nohint` `>tl` | Shows a current trivia leaderboard. | `>tl` `>tq` | Quits current trivia after current question. | `>tq` @@ -181,7 +184,7 @@ Command and aliases | Description | Usage ### Music Command and aliases | Description | Usage ----------------|--------------|------- -`!!next` `!!n` | Goes to the next song in the queue. You have to be in the same voice channel as the bot. | `!!n` +`!!next` `!!n` | Goes to the next song in the queue. You have to be in the same voice channel as the bot. You can skip multiple songs, but in that case songs will not be requeued if !!rcs or !!rpl is enabled. | `!!n` or `!!n 5` `!!stop` `!!s` | Stops the music and clears the playlist. Stays in the channel. | `!!s` `!!destroy` `!!d` | Completely stops the music and unbinds the bot from the channel. (may cause weird behaviour) | `!!d` `!!pause` `!!p` | Pauses or Unpauses the song. | `!!p` @@ -216,9 +219,11 @@ Command and aliases | Description | Usage ### NSFW Command and aliases | Description | Usage ----------------|--------------|------- -`~hentai` | Shows a 2 random images (from gelbooru and danbooru) with a given tag. Tag is optional but preferred. Only 1 tag allowed. | `~hentai yuri` +`~hentai` | Shows a hentai image from a random website (gelbooru or danbooru or konachan or atfbooru) with a given tag. Tag is optional but preferred. Only 1 tag allowed. | `~hentai yuri` +`~hentaibomb` | Shows a total 4 images (from gelbooru, danbooru, konachan and atfbooru). Tag is optional but preferred. | `~hentaibomb yuri` +`~atfbooru` `~atf` | Shows a random hentai image from atfbooru with a given tag. Tag is optional but preferred. | `~atfbooru yuri+kissing` `~danbooru` | Shows a random hentai image from danbooru with a given tag. Tag is optional but preferred. (multiple tags are appended with +) | `~danbooru yuri+kissing` -`~konachan` | Shows a random hentai image from konachan with a given tag. Tag is optional but preferred. (multiple tags are appended with +) | `~konachan yuri` +`~konachan` | Shows a random hentai image from konachan with a given tag. Tag is optional but preferred. | `~konachan yuri` `~gelbooru` | Shows a random hentai image from gelbooru with a given tag. Tag is optional but preferred. (multiple tags are appended with +) | `~gelbooru yuri+kissing` `~rule34` | Shows a random image from rule34.xx with a given tag. Tag is optional but preferred. (multiple tags are appended with +) | `~rule34 yuri+kissing` `~e621` | Shows a random hentai image from e621.net with a given tag. Tag is optional but preferred. Use spaces for multiple tags. | `~e621 yuri kissing` @@ -329,6 +334,7 @@ Command and aliases | Description | Usage `.channeltopic` `.ct` | Sends current channel's topic as a message. | `.ct` `.stats` | Shows some basic stats for Nadeko. | `.stats` `.showemojis` `.se` | Shows a name and a link to every SPECIAL emoji in the message. | `.se A message full of SPECIAL emojis` +`.listservers` | Lists servers the bot is on with some basic info. 15 per page. **Bot owner only.** | `.listservers 3` `.calculate` `.calc` | Evaluate a mathematical expression. | `.calc 1+1` `.calcops` | Shows all available operations in .calc command | `.calcops` `.togethertube` `.totube` | Creates a new room on and shows the link in the chat. | `.totube` From 12ab3ceb84d174ce6f07e9ebdabbfd3fd06e6697 Mon Sep 17 00:00:00 2001 From: miraai Date: Tue, 8 Nov 2016 00:39:19 +0100 Subject: [PATCH 39/58] added CleverBot feature --- docs/JSON Explanations.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/JSON Explanations.md b/docs/JSON Explanations.md index 3a49dead..ba9477e5 100644 --- a/docs/JSON Explanations.md +++ b/docs/JSON Explanations.md @@ -17,7 +17,9 @@ If you do not see `credentials.json` you will need to rename `credentials_exampl "SoundCloudClientId": "", "CarbonKey": "", "Db": null, - "TotalShards": 1 + "TotalShards": 1, + "CleverbotApiUser": null, + "CleverbotApiKey": null } ``` ####Required Parts @@ -48,6 +50,7 @@ Setting up your API keys - You can get this key [here](https://osu.ppy.sh/p/api) **You will need to log in and like the soundcloud it may take a few tries** - **CarbonKey** -This key is for Carobnitex.net stats. - Most likely unnecessary **Needed only if your bot is listed on Carbonitex.net** +- **CleverbotApiUser and CleverbotApiKey** - API Keys for CleverBot feature, you can get your keys here: [CleverBot APIs][CleverBot APIs] Additional options ==================== @@ -63,3 +66,5 @@ In the folder where `NadekoBot.exe` is located you should also see a `Data` fold `config.json` contains user specific commands, such as: if DM's sent to the bot are forwarded to you, Blacklisted Ids, Servers, and channels...etc. **If you do not see** `config.json` **you need to rename** `config_example.json` **to** `config.json` + +[CleverBot APIs]: https://cleverbot.io/keys From 2e917910256864e7228eb27ddb79ed6a06092230 Mon Sep 17 00:00:00 2001 From: miraai Date: Tue, 8 Nov 2016 01:10:06 +0100 Subject: [PATCH 40/58] fix --- docs/JSON Explanations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/JSON Explanations.md b/docs/JSON Explanations.md index ba9477e5..2b1ca7f8 100644 --- a/docs/JSON Explanations.md +++ b/docs/JSON Explanations.md @@ -18,8 +18,8 @@ If you do not see `credentials.json` you will need to rename `credentials_exampl "CarbonKey": "", "Db": null, "TotalShards": 1, - "CleverbotApiUser": null, - "CleverbotApiKey": null + "CleverbotApiUser": "", + "CleverbotApiKey": "" } ``` ####Required Parts From eab28824ef70db547df6c181e5067a535999e09e Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 8 Nov 2016 19:27:44 +0100 Subject: [PATCH 41/58] Cleverbot reworked --- .../Games/Commands/CleverBotCommands.cs | 116 +++++--------- src/NadekoBot/Resources/CommandStrings.resx | 82 +++++----- .../Services/CleverBotApi/ChatterBot.cs | 25 +++ .../CleverBotApi/ChatterBotFactory.cs | 45 ++++++ .../CleverBotApi/ChatterBotSession.cs | 28 ++++ .../CleverBotApi/ChatterBotThought.cs | 26 +++ .../Services/CleverBotApi/ChatterBotType.cs | 27 ++++ .../Services/CleverBotApi/Cleverbot.cs | 116 ++++++++++++++ .../Services/CleverBotApi/Pandorabots.cs | 68 ++++++++ src/NadekoBot/Services/CleverBotApi/Utils.cs | 148 ++++++++++++++++++ src/NadekoBot/Services/Impl/BotCredentials.cs | 6 - src/NadekoBot/credentials_example.json | 4 +- src/NadekoBot/project.json | 3 +- 13 files changed, 562 insertions(+), 132 deletions(-) create mode 100644 src/NadekoBot/Services/CleverBotApi/ChatterBot.cs create mode 100644 src/NadekoBot/Services/CleverBotApi/ChatterBotFactory.cs create mode 100644 src/NadekoBot/Services/CleverBotApi/ChatterBotSession.cs create mode 100644 src/NadekoBot/Services/CleverBotApi/ChatterBotThought.cs create mode 100644 src/NadekoBot/Services/CleverBotApi/ChatterBotType.cs create mode 100644 src/NadekoBot/Services/CleverBotApi/Cleverbot.cs create mode 100644 src/NadekoBot/Services/CleverBotApi/Pandorabots.cs create mode 100644 src/NadekoBot/Services/CleverBotApi/Utils.cs diff --git a/src/NadekoBot/Modules/Games/Commands/CleverBotCommands.cs b/src/NadekoBot/Modules/Games/Commands/CleverBotCommands.cs index a192a528..5858fb63 100644 --- a/src/NadekoBot/Modules/Games/Commands/CleverBotCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/CleverBotCommands.cs @@ -5,6 +5,7 @@ using NadekoBot.Services; using NadekoBot.Services.Database; using Newtonsoft.Json; using NLog; +using Services.CleverBotApi; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -21,26 +22,27 @@ namespace NadekoBot.Modules.Games [Group] public class CleverBotCommands { - private Logger _log { get; } + private static Logger _log { get; } class CleverAnswer { public string Status { get; set; } public string Response { get; set; } } - public CleverBotCommands() - { - _log = LogManager.GetCurrentClassLogger(); - } - //user#discrim is the key public static ConcurrentHashSet ChannelsInConversation { get; } = new ConcurrentHashSet(); - public static ConcurrentHashSet CleverbotGuilds { get; } = new ConcurrentHashSet(); + public static ConcurrentDictionary CleverbotGuilds { get; } = new ConcurrentDictionary(); static CleverBotCommands() { + _log = LogManager.GetCurrentClassLogger(); + using (var uow = DbHandler.UnitOfWork()) { - CleverbotGuilds = new ConcurrentHashSet(uow.GuildConfigs.GetAll().Where(gc => gc.CleverbotEnabled).Select(gc => gc.GuildId)); + var bot = ChatterBotFactory.Create(ChatterBotType.CLEVERBOT); + CleverbotGuilds = new ConcurrentDictionary( + uow.GuildConfigs.GetAll() + .Where(gc => gc.CleverbotEnabled) + .ToDictionary(gc => gc.GuildId, gc => bot.CreateSession())); } } @@ -50,9 +52,8 @@ namespace NadekoBot.Modules.Games if (channel == null) return false; - var nick = msg.Channel.Id + "NadekoBot"; - - if (!ChannelsInConversation.Contains(nick) && !CleverbotGuilds.Contains(channel.Guild.Id)) + ChatterBotSession cleverbot; + if (!CleverbotGuilds.TryGetValue(channel.Guild.Id, out cleverbot)) return false; var nadekoId = NadekoBot.Client.GetCurrentUser().Id; @@ -61,11 +62,11 @@ namespace NadekoBot.Modules.Games string message; if (msg.Content.StartsWith(normalMention)) { - message = msg.Content.Substring(normalMention.Length); + message = msg.Content.Substring(normalMention.Length).Trim(); } else if (msg.Content.StartsWith(nickMention)) { - message = msg.Content.Substring(nickMention.Length); + message = msg.Content.Substring(nickMention.Length).Trim(); } else { @@ -74,98 +75,51 @@ namespace NadekoBot.Modules.Games await msg.Channel.TriggerTypingAsync().ConfigureAwait(false); - using (var http = new HttpClient()) + var response = await cleverbot.Think(message).ConfigureAwait(false); + try { - var content = new FormUrlEncodedContent(new Dictionary - { - { "user", NadekoBot.Credentials.CleverbotApiUser}, - { "key", NadekoBot.Credentials.CleverbotApiKey}, - { "nick", nick}, - { "text", message}, - }); - var res = await http.PostAsync("https://cleverbot.io/1.0/ask", content).ConfigureAwait(false); - - if (res.StatusCode == System.Net.HttpStatusCode.OK) - { - try - { - var answer = JsonConvert.DeserializeObject(await res.Content.ReadAsStringAsync().ConfigureAwait(false)); - try - { - await msg.Channel.SendMessageAsync(WebUtility.HtmlDecode(answer.Response)).ConfigureAwait(false); - } - catch - { - await msg.Channel.SendMessageAsync(answer.Response).ConfigureAwait(false); // try twice :\ - } - } - catch { } - return true; - } - return false; + await msg.Channel.SendMessageAsync(response).ConfigureAwait(false); } + catch (Exception ex) + { + _log.Warn(ex, "Eror sending response"); + await msg.Channel.SendMessageAsync(response).ConfigureAwait(false); // try twice :\ + } + return true; } [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] [RequirePermission(ChannelPermission.ManageMessages)] - public async Task Cleverbot(IUserMessage imsg, string all = null) + public async Task Cleverbot(IUserMessage imsg) { var channel = (ITextChannel)imsg.Channel; - - if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.CleverbotApiKey) || - string.IsNullOrWhiteSpace(NadekoBot.Credentials.CleverbotApiKey)) - { - await channel.SendMessageAsync(":anger: `Bot owner didn't setup Cleverbot Api keys. Session will not start.`").ConfigureAwait(false); - return; - } - if (all?.Trim().ToLowerInvariant() == "all") + ChatterBotSession throwaway; + if (CleverbotGuilds.TryRemove(channel.Guild.Id, out throwaway)) { - var cleverbotEnabled = CleverbotGuilds.Add(channel.Guild.Id); - if (!cleverbotEnabled) - CleverbotGuilds.TryRemove(channel.Guild.Id); - using (var uow = DbHandler.UnitOfWork()) { - uow.GuildConfigs.SetCleverbotEnabled(channel.Guild.Id, cleverbotEnabled); + uow.GuildConfigs.SetCleverbotEnabled(channel.Guild.Id, false); await uow.CompleteAsync().ConfigureAwait(false); } - - await channel.SendMessageAsync($"{imsg.Author.Mention} `{(cleverbotEnabled ? "Enabled" : "Disabled")} cleverbot for all users.`").ConfigureAwait(false); + await channel.SendMessageAsync($"{imsg.Author.Mention} `Disabled cleverbot on this server.`").ConfigureAwait(false); return; } + var cleverbot = ChatterBotFactory.Create(ChatterBotType.CLEVERBOT); + var session = cleverbot.CreateSession(); - var nick = channel.Id + "NadekoBot"; + CleverbotGuilds.TryAdd(channel.Guild.Id, session); - if (ChannelsInConversation.TryRemove(nick)) + using (var uow = DbHandler.UnitOfWork()) { - await channel.SendMessageAsync($"{imsg.Author.Mention} `I will no longer reply to your messages starting with my mention.`").ConfigureAwait(false); - return; + uow.GuildConfigs.SetCleverbotEnabled(channel.Guild.Id, true); + await uow.CompleteAsync().ConfigureAwait(false); } - using (var http = new HttpClient()) - { - var content = new FormUrlEncodedContent(new Dictionary() - { - { "user", NadekoBot.Credentials.CleverbotApiUser}, - { "key", NadekoBot.Credentials.CleverbotApiKey}, - { "nick", nick}, - }); - var res = await http.PostAsync("https://cleverbot.io/1.0/create", content).ConfigureAwait(false); - if (res.StatusCode != System.Net.HttpStatusCode.OK) - { - await channel.SendMessageAsync($"{imsg.Author.Mention} `Something went wrong in starting your cleverbot session :\\`"); - _log.Warn(await res.Content.ReadAsStringAsync()); - return; - } - - ChannelsInConversation.Add(nick); - } - await channel.SendMessageAsync($"{imsg.Author.Mention} `I will reply to your messages starting with my mention.`").ConfigureAwait(false); + await channel.SendMessageAsync($"{imsg.Author.Mention} `Enabled cleverbot on this server.`").ConfigureAwait(false); } - } } } diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 2c5db911..c14896e3 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -166,7 +166,7 @@ greetdel grdel - Toggles automatic deletion of greet messages. + Toggles automatic deletion of greet messages. `{0}greetdel` @@ -175,7 +175,7 @@ greet - Toggles anouncements on the current channel when someone joins the server. + Toggles anouncements on the current channel when someone joins the server. `{0}greet` @@ -184,7 +184,7 @@ greetmsg - Sets a new join announcement message which will be shown in the server's channel. Type %user% if you want to mention the new member. Using it with no message will show the current greet message. + Sets a new join announcement message which will be shown in the server's channel. Type %user% if you want to mention the new member. Using it with no message will show the current greet message. `{0}greetmsg Welcome, %user%.` @@ -202,7 +202,7 @@ byemsg - Sets a new leave announcement message. Type %user% if you want to mention the new member. Using it with no message will show the current bye message. + Sets a new leave announcement message. Type %user% if you want to mention the new member. Using it with no message will show the current bye message. `{0}byemsg %user% has left.` @@ -211,7 +211,7 @@ byedel - Toggles automatic deletion of bye messages. + Toggles automatic deletion of bye messages. `{0}byedel` @@ -220,7 +220,7 @@ greetdm - Toggles whether the greet messages will be sent in a DM (This is separate from greet - you can have both, any or neither enabled). + Toggles whether the greet messages will be sent in a DM (This is separate from greet - you can have both, any or neither enabled). `{0}greetdm` @@ -247,7 +247,7 @@ userpresence - Starts logging to this channel when someone from the server goes online/offline/idle. + Starts logging to this channel when someone from the server goes online/offline/idle. `{0}userpresence` @@ -256,7 +256,7 @@ voicepresence - Toggles logging to this channel whenever someone joins or leaves a voice channel you are currently in. + Toggles logging to this channel whenever someone joins or leaves a voice channel you are currently in. `{0}voicepresence` @@ -265,7 +265,7 @@ repeatinvoke repinv - Immediately shows the repeat message and restarts the timer. + Immediately shows the repeat message and restarts the timer. `{0}repinv` @@ -310,7 +310,7 @@ removeplaying rmpl repl - Removes a playing string on a given number. + Removes a playing string on a given number. `{0}rmpl` @@ -337,7 +337,7 @@ voice+text v+t - Creates a text channel for each voice channel only users in that voice channel can see.If you are server owner, keep in mind you will see them all the time regardless. + Creates a text channel for each voice channel only users in that voice channel can see.If you are server owner, keep in mind you will see them all the time regardless. `{0}voice+text` @@ -355,7 +355,7 @@ jcsc - Joins current channel to an instance of cross server channel using the token. + Joins current channel to an instance of cross server channel using the token. `{0}jcsc TokenHere` @@ -364,7 +364,7 @@ lcsc - Leaves Cross server channel instance from this channel. + Leaves Cross server channel instance from this channel. `{0}lcsc` @@ -463,7 +463,7 @@ autoassignrole aar - Automaticaly assigns a specified role to every user who joins the server. + Automaticaly assigns a specified role to every user who joins the server. `{0}aar` to disable, `{0}aar Role Name` to enable @@ -472,7 +472,7 @@ leave - Makes Nadeko leave the server. Either name or id required. + Makes Nadeko leave the server. Either name or id required. `{0}leave 123123123331` @@ -499,7 +499,7 @@ setrole sr - Sets a role for a given user. + Sets a role for a given user. `{0}sr @User Guest` @@ -508,7 +508,7 @@ removerole rr - Removes a role from a given user. + Removes a role from a given user. `{0}rr @User Admin` @@ -526,7 +526,7 @@ removeallroles rar - Removes all roles from a mentioned user. + Removes all roles from a mentioned user. `{0}rar @User` @@ -535,7 +535,7 @@ createrole cr - Creates a role with a given name. + Creates a role with a given name. `{0}cr Awesome Role` @@ -544,7 +544,7 @@ rolecolor rc - Set a role's color to the hex or 0-255 rgb color value provided. + Set a role's color to the hex or 0-255 rgb color value provided. `{0}rc Admin 255 200 100` or `{0}rc Admin ffba55` @@ -562,7 +562,7 @@ softban sb - Bans and then unbans a user by ID or name with an optional message. + Bans and then unbans a user by ID or name with an optional message. `{0}sb "@some Guy" Your behaviour is toxic.` @@ -571,7 +571,7 @@ kick k - Kicks a mentioned user. + Kicks a mentioned user. `{0}k "@some Guy" Your behaviour is toxic.` @@ -589,7 +589,7 @@ voiceunmute - Gives a previously voice-muted user a permission to speak. + Gives a previously voice-muted user a permission to speak. `{0}voiceunmute @Someguy` @@ -598,7 +598,7 @@ deafen deaf - Deafens mentioned user or users. + Deafens mentioned user or users. `{0}deaf "@Someguy"` or `{0}deaf "@Someguy" "@Someguy"` @@ -607,7 +607,7 @@ undeafen undef - Undeafens mentioned user or users. + Undeafens mentioned user or users. `{0}undef "@Someguy"` or `{0}undef "@Someguy" "@Someguy"` @@ -616,7 +616,7 @@ delvoichanl dvch - Deletes a voice channel with a given name. + Deletes a voice channel with a given name. `{0}dvch VoiceChannelName` @@ -625,7 +625,7 @@ creatvoichanl cvch - Creates a new voice channel with a given name. + Creates a new voice channel with a given name. `{0}cvch VoiceChannelName` @@ -634,7 +634,7 @@ deltxtchanl dtch - Deletes a text channel with a given name. + Deletes a text channel with a given name. `{0}dtch TextChannelName` @@ -643,7 +643,7 @@ creatxtchanl ctch - Creates a new text channel with a given name. + Creates a new text channel with a given name. `{0}ctch TextChannelName` @@ -652,7 +652,7 @@ settopic st - Sets a topic on the current channel. + Sets a topic on the current channel. `{0}st My new topic` @@ -661,7 +661,7 @@ setchanlname schn - Changes the name of the current channel. + Changes the name of the current channel. `{0}schn NewName` @@ -670,7 +670,7 @@ prune clr - `{0}prune` removes all nadeko's messages in the last 100 messages.`{0}prune X` removes last X messages from the channel (up to 100)`{0}prune @Someone` removes all Someone's messages in the last 100 messages.`{0}prune @Someone X` removes last X 'Someone's' messages in the channel. + `{0}prune` removes all nadeko's messages in the last 100 messages.`{0}prune X` removes last X messages from the channel (up to 100)`{0}prune @Someone` removes all Someone's messages in the last 100 messages.`{0}prune @Someone X` removes last X 'Someone's' messages in the channel. `{0}prune` or `{0}prune 5` or `{0}prune @Someone` or `{0}prune @Someone X` @@ -688,7 +688,7 @@ setname newnm - Gives the bot a new name. + Gives the bot a new name. `{0}newnm BotName` @@ -697,7 +697,7 @@ setavatar setav - Sets a new avatar image for the NadekoBot. Argument is a direct link to an image. + Sets a new avatar image for the NadekoBot. Argument is a direct link to an image. `{0}setav http://i.imgur.com/xTG3a1I.jpg` @@ -706,7 +706,7 @@ setgame - Sets the bots game. + Sets the bots game. `{0}setgame with snakes` @@ -733,7 +733,7 @@ unstuck - Clears the message queue. + Clears the message queue. `{0}unstuck` @@ -787,7 +787,7 @@ remindtemplate - Sets message for when the remind is triggered. Available placeholders are %user% - user who ran the command, %message% - Message specified in the remind, %target% - target channel of the remind. + Sets message for when the remind is triggered. Available placeholders are %user% - user who ran the command, %message% - Message specified in the remind, %target% - target channel of the remind. `{0}remindtemplate %user%, you gotta do %message%!` @@ -1255,7 +1255,7 @@ take - Takes a certain amount of currency from someone. + Takes a certain amount of currency from someone. `{0}take 1 "@someguy"` @@ -1615,7 +1615,7 @@ cleanup - Cleans up hanging voice connections. + Cleans up hanging voice connections. `{0}cleanup` @@ -2311,7 +2311,7 @@ `{0}greetdmmsg Welcome to the server, %user%`. - Sets a new join announcement message which will be sent to the user who joined. Type %user% if you want to mention the new member. Using it with no message will show the current DM greet message. + Sets a new join announcement message which will be sent to the user who joined. Type %user% if you want to mention the new member. Using it with no message will show the current DM greet message. Check how much currency a person has. (Defaults to yourself) @@ -2623,7 +2623,7 @@ cleverbot - Toggles cleverbot session. When enabled, the bot will reply to messages starting with bot mention in the channel this command is ran in. You can specify "all" parameter to enable it in the whole server. Custom reactions starting with %mention% won't work if cleverbot is enabled.' + Toggles cleverbot session. When enabled, the bot will reply to messages starting with bot mention in the server. Custom reactions starting with %mention% won't work if cleverbot is enabled. `{0}cleverbot` diff --git a/src/NadekoBot/Services/CleverBotApi/ChatterBot.cs b/src/NadekoBot/Services/CleverBotApi/ChatterBot.cs new file mode 100644 index 00000000..746b44aa --- /dev/null +++ b/src/NadekoBot/Services/CleverBotApi/ChatterBot.cs @@ -0,0 +1,25 @@ + /* + ChatterBotAPI + Copyright (C) 2011 pierredavidbelanger@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +namespace Services.CleverBotApi +{ + public interface ChatterBot + { + ChatterBotSession CreateSession(); + } +} \ No newline at end of file diff --git a/src/NadekoBot/Services/CleverBotApi/ChatterBotFactory.cs b/src/NadekoBot/Services/CleverBotApi/ChatterBotFactory.cs new file mode 100644 index 00000000..642b2a23 --- /dev/null +++ b/src/NadekoBot/Services/CleverBotApi/ChatterBotFactory.cs @@ -0,0 +1,45 @@ +using System; + +/* + ChatterBotAPI + Copyright (C) 2011 pierredavidbelanger@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +namespace Services.CleverBotApi +{ + public class ChatterBotFactory + { + public static ChatterBot Create(ChatterBotType type) + { + return Create(type, null); + } + + public static ChatterBot Create(ChatterBotType type, object arg) + { + switch (type) + { + case ChatterBotType.CLEVERBOT: + return new Cleverbot("http://www.cleverbot.com/", "http://www.cleverbot.com/webservicemin?uc=165", 26); + case ChatterBotType.JABBERWACKY: + return new Cleverbot("http://jabberwacky.com", "http://jabberwacky.com/webservicemin", 20); + case ChatterBotType.PANDORABOTS: + if (arg == null) throw new ArgumentException("PANDORABOTS needs a botid arg", nameof(arg)); + return new Pandorabots(arg.ToString()); + } + return null; + } + } +} \ No newline at end of file diff --git a/src/NadekoBot/Services/CleverBotApi/ChatterBotSession.cs b/src/NadekoBot/Services/CleverBotApi/ChatterBotSession.cs new file mode 100644 index 00000000..0f063571 --- /dev/null +++ b/src/NadekoBot/Services/CleverBotApi/ChatterBotSession.cs @@ -0,0 +1,28 @@ +/* + ChatterBotAPI + Copyright (C) 2011 pierredavidbelanger@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +using System.Threading.Tasks; + +namespace Services.CleverBotApi +{ + public interface ChatterBotSession + { + Task Think(ChatterBotThought thought); + Task Think(string text); + } +} \ No newline at end of file diff --git a/src/NadekoBot/Services/CleverBotApi/ChatterBotThought.cs b/src/NadekoBot/Services/CleverBotApi/ChatterBotThought.cs new file mode 100644 index 00000000..1a385642 --- /dev/null +++ b/src/NadekoBot/Services/CleverBotApi/ChatterBotThought.cs @@ -0,0 +1,26 @@ +/* + ChatterBotAPI + Copyright (C) 2011 pierredavidbelanger@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +namespace Services.CleverBotApi +{ + public class ChatterBotThought + { + public string[] Emotions { get; set; } + public string Text { get; set; } + } +} \ No newline at end of file diff --git a/src/NadekoBot/Services/CleverBotApi/ChatterBotType.cs b/src/NadekoBot/Services/CleverBotApi/ChatterBotType.cs new file mode 100644 index 00000000..e4e8fab8 --- /dev/null +++ b/src/NadekoBot/Services/CleverBotApi/ChatterBotType.cs @@ -0,0 +1,27 @@ +/* + ChatterBotAPI + Copyright (C) 2011 pierredavidbelanger@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +namespace Services.CleverBotApi +{ + public enum ChatterBotType + { + CLEVERBOT, + JABBERWACKY, + PANDORABOTS + } +} \ No newline at end of file diff --git a/src/NadekoBot/Services/CleverBotApi/Cleverbot.cs b/src/NadekoBot/Services/CleverBotApi/Cleverbot.cs new file mode 100644 index 00000000..328c0500 --- /dev/null +++ b/src/NadekoBot/Services/CleverBotApi/Cleverbot.cs @@ -0,0 +1,116 @@ +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; + +/* + ChatterBotAPI + Copyright (C) 2011 pierredavidbelanger@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +namespace Services.CleverBotApi +{ + internal class Cleverbot : ChatterBot + { + private readonly int endIndex; + private readonly string baseUrl; + private readonly string url; + + public Cleverbot(string baseUrl, string url, int endIndex) + { + this.baseUrl = baseUrl; + this.url = url; + this.endIndex = endIndex; + } + + public ChatterBotSession CreateSession() + { + return new CleverbotSession(baseUrl, url, endIndex); + } + } + + internal class CleverbotSession : ChatterBotSession + { + private readonly int endIndex; + private readonly string url; + private readonly IDictionary vars; + private readonly CookieCollection cookies; + + public CleverbotSession(string baseUrl, string url, int endIndex) + { + this.url = url; + this.endIndex = endIndex; + vars = new Dictionary(); + //vars["start"] = "y"; + vars["stimulus"] = ""; + vars["islearning"] = "1"; + vars["icognoid"] = "wsf"; + //vars["fno"] = "0"; + //vars["sub"] = "Say"; + //vars["cleanslate"] = "false"; + cookies = Utils.GetCookies(baseUrl); + } + + public async Task Think(ChatterBotThought thought) + { + vars["stimulus"] = thought.Text; + + var formData = Utils.ParametersToWWWFormURLEncoded(vars); + var formDataToDigest = formData.Substring(9, endIndex); + var formDataDigest = Utils.MD5(formDataToDigest); + vars["icognocheck"] = formDataDigest; + + var response = await Utils.Post(url, vars, cookies).ConfigureAwait(false); + + var responseValues = response.Split('\r'); + + //vars[""] = Utils.StringAtIndex(responseValues, 0); ?? + vars["sessionid"] = Utils.StringAtIndex(responseValues, 1); + vars["logurl"] = Utils.StringAtIndex(responseValues, 2); + vars["vText8"] = Utils.StringAtIndex(responseValues, 3); + vars["vText7"] = Utils.StringAtIndex(responseValues, 4); + vars["vText6"] = Utils.StringAtIndex(responseValues, 5); + vars["vText5"] = Utils.StringAtIndex(responseValues, 6); + vars["vText4"] = Utils.StringAtIndex(responseValues, 7); + vars["vText3"] = Utils.StringAtIndex(responseValues, 8); + vars["vText2"] = Utils.StringAtIndex(responseValues, 9); + vars["prevref"] = Utils.StringAtIndex(responseValues, 10); + //vars[""] = Utils.StringAtIndex(responseValues, 11); ?? +// vars["emotionalhistory"] = Utils.StringAtIndex(responseValues, 12); +// vars["ttsLocMP3"] = Utils.StringAtIndex(responseValues, 13); +// vars["ttsLocTXT"] = Utils.StringAtIndex(responseValues, 14); +// vars["ttsLocTXT3"] = Utils.StringAtIndex(responseValues, 15); +// vars["ttsText"] = Utils.StringAtIndex(responseValues, 16); +// vars["lineRef"] = Utils.StringAtIndex(responseValues, 17); +// vars["lineURL"] = Utils.StringAtIndex(responseValues, 18); +// vars["linePOST"] = Utils.StringAtIndex(responseValues, 19); +// vars["lineChoices"] = Utils.StringAtIndex(responseValues, 20); +// vars["lineChoicesAbbrev"] = Utils.StringAtIndex(responseValues, 21); +// vars["typingData"] = Utils.StringAtIndex(responseValues, 22); +// vars["divert"] = Utils.StringAtIndex(responseValues, 23); + + var responseThought = new ChatterBotThought(); + + responseThought.Text = Utils.StringAtIndex(responseValues, 0); + + return responseThought; + } + + public async Task Think(string text) + { + return (await Think(new ChatterBotThought {Text = text}).ConfigureAwait(false)).Text; + } + } +} \ No newline at end of file diff --git a/src/NadekoBot/Services/CleverBotApi/Pandorabots.cs b/src/NadekoBot/Services/CleverBotApi/Pandorabots.cs new file mode 100644 index 00000000..384b2e63 --- /dev/null +++ b/src/NadekoBot/Services/CleverBotApi/Pandorabots.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +/* + ChatterBotAPI + Copyright (C) 2011 pierredavidbelanger@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +namespace Services.CleverBotApi +{ + internal class Pandorabots : ChatterBot + { + private readonly string botid; + + public Pandorabots(string botid) + { + this.botid = botid; + } + + public ChatterBotSession CreateSession() + { + return new PandorabotsSession(botid); + } + } + + internal class PandorabotsSession : ChatterBotSession + { + private readonly IDictionary vars; + + public PandorabotsSession(string botid) + { + vars = new Dictionary(); + vars["botid"] = botid; + vars["custid"] = Guid.NewGuid().ToString(); + } + + public async Task Think(ChatterBotThought thought) + { + vars["input"] = thought.Text; + + var response = await Utils.Post("http://www.pandorabots.com/pandora/talk-xml", vars, null).ConfigureAwait(false); + + var responseThought = new ChatterBotThought(); + responseThought.Text = Utils.XPathSearch(response, "//result/that/text()"); + + return responseThought; + } + + public async Task Think(string text) + { + return (await Think(new ChatterBotThought {Text = text}).ConfigureAwait(false)).Text; + } + } +} \ No newline at end of file diff --git a/src/NadekoBot/Services/CleverBotApi/Utils.cs b/src/NadekoBot/Services/CleverBotApi/Utils.cs new file mode 100644 index 00000000..3f4596a7 --- /dev/null +++ b/src/NadekoBot/Services/CleverBotApi/Utils.cs @@ -0,0 +1,148 @@ +using NadekoBot.Extensions; +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using System.Xml.XPath; + +/* + ChatterBotAPI + Copyright (C) 2011 pierredavidbelanger@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +namespace Services.CleverBotApi +{ + internal static class Utils + { + public static string ParametersToWWWFormURLEncoded(IDictionary parameters) + { + string wwwFormUrlEncoded = null; + foreach (var parameterKey in parameters.Keys) + { + var parameterValue = parameters[parameterKey]; + var parameter = string.Format("{0}={1}", System.Uri.EscapeDataString(parameterKey), System.Uri.EscapeDataString(parameterValue)); + if (wwwFormUrlEncoded == null) + { + wwwFormUrlEncoded = parameter; + } + else + { + wwwFormUrlEncoded = string.Format("{0}&{1}", wwwFormUrlEncoded, parameter); + } + } + return wwwFormUrlEncoded; + } + + public static string MD5(string input) + { + // step 1, calculate MD5 hash from input + var md5 = System.Security.Cryptography.MD5.Create(); + var inputBytes = Encoding.ASCII.GetBytes(input); + var hash = md5.ComputeHash(inputBytes); + + // step 2, convert byte array to hex string + var sb = new StringBuilder(); + for (var i = 0; i < hash.Length; i++) + { + sb.Append(hash[i].ToString("X2")); + } + return sb.ToString(); + + } + + public static CookieCollection GetCookies(string url) + { + CookieContainer container = new CookieContainer(); + + HttpResponseMessage res; + using (var handler = new HttpClientHandler() { CookieContainer = container }) + using (var http = new HttpClient(handler)) + { + http.AddFakeHeaders(); + http.DefaultRequestHeaders.Add("ContentType", "text/html"); + res = http.GetAsync(url).GetAwaiter().GetResult(); + } + var response = res.Content.ReadAsStringAsync().GetAwaiter().GetResult(); + + return container.GetCookies(res.RequestMessage.RequestUri); + } + + public static async Task Post(string url, IDictionary parameters, CookieCollection cookies) + { + var postData = ParametersToWWWFormURLEncoded(parameters); + var postDataBytes = Encoding.ASCII.GetBytes(postData); + + var request = (HttpWebRequest)WebRequest.Create(url); + + if (cookies != null) + { + var container = new CookieContainer(); + container.Add(new Uri(url), cookies); + request.CookieContainer = container; + } + + + request.Method = "POST"; + request.ContentType = "application/x-www-form-urlencoded"; + + using (var outputStream = await request.GetRequestStreamAsync()) + { + outputStream.Write(postDataBytes, 0, postDataBytes.Length); + outputStream.Flush(); + + var response = (HttpWebResponse)await request.GetResponseAsync(); + using (var responseStreamReader = new StreamReader(response.GetResponseStream())) + { + return responseStreamReader.ReadToEnd().Trim(); + } + } + + //HttpClientHandler handler; + //var uri = new Uri(url); + //if (cookies == null) + // handler = new HttpClientHandler(); + //else + //{ + // var cookieContainer = new CookieContainer(); + // cookieContainer.Add(uri, cookies); + // handler = new HttpClientHandler() { CookieContainer = cookieContainer }; + //} + //using (handler) + //using (var http = new HttpClient(handler)) + //{ + // var res = await http.PostAsync(url, new FormUrlEncodedContent(parameters)).ConfigureAwait(false); + // return await res.Content.ReadAsStringAsync().ConfigureAwait(false); + //} + } + + + public static string XPathSearch(string input, string expression) + { + var document = new XPathDocument(new MemoryStream(Encoding.ASCII.GetBytes(input))); + var navigator = document.CreateNavigator(); + return navigator.SelectSingleNode(expression).Value.Trim(); + } + + public static string StringAtIndex(string[] strings, int index) + { + if (index >= strings.Length) return ""; + return strings[index]; + } + } +} \ No newline at end of file diff --git a/src/NadekoBot/Services/Impl/BotCredentials.cs b/src/NadekoBot/Services/Impl/BotCredentials.cs index a5f326eb..d52e8ad7 100644 --- a/src/NadekoBot/Services/Impl/BotCredentials.cs +++ b/src/NadekoBot/Services/Impl/BotCredentials.cs @@ -26,8 +26,6 @@ namespace NadekoBot.Services.Impl public string LoLApiKey { get; } public string OsuApiKey { get; } public string SoundCloudClientId { get; } - public string CleverbotApiUser { get; } - public string CleverbotApiKey { get; } public DB Db { get; } public int TotalShards { get; } @@ -52,8 +50,6 @@ namespace NadekoBot.Services.Impl ClientId = cm.ClientId; SoundCloudClientId = cm.SoundCloudClientId; CarbonKey = cm.CarbonKey; - CleverbotApiKey = cm.CleverbotApiKey; - CleverbotApiUser = cm.CleverbotApiUser; if (cm.Db == null) Db = new DB("sqlite", ""); else @@ -81,8 +77,6 @@ namespace NadekoBot.Services.Impl public string CarbonKey { get; set; } = ""; public DB Db { get; set; } public int TotalShards { get; set; } = 1; - public string CleverbotApiUser { get; set; } - public string CleverbotApiKey { get; set; } } private class DbModel diff --git a/src/NadekoBot/credentials_example.json b/src/NadekoBot/credentials_example.json index 50577cd6..34925301 100644 --- a/src/NadekoBot/credentials_example.json +++ b/src/NadekoBot/credentials_example.json @@ -12,7 +12,5 @@ "SoundCloudClientId": "", "CarbonKey": "", "Db": null, - "TotalShards": 1, - "CleverbotApiUser": null, - "CleverbotApiKey": null + "TotalShards": 1 } \ No newline at end of file diff --git a/src/NadekoBot/project.json b/src/NadekoBot/project.json index 9ed621ff..e44b0284 100644 --- a/src/NadekoBot/project.json +++ b/src/NadekoBot/project.json @@ -41,7 +41,8 @@ }, "Discord.Net": { "target": "project" - } + }, + "System.Xml.XPath": "4.0.1" }, "tools": { "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final" From 1217162def6a917eac020f444c5addd1db422279 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 8 Nov 2016 19:28:18 +0100 Subject: [PATCH 42/58] Autotranslate QOL + fix --- src/NadekoBot/Modules/Searches/Commands/Translator.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Searches/Commands/Translator.cs b/src/NadekoBot/Modules/Searches/Commands/Translator.cs index f82b1a98..8c588cf0 100644 --- a/src/NadekoBot/Modules/Searches/Commands/Translator.cs +++ b/src/NadekoBot/Modules/Searches/Commands/Translator.cs @@ -59,7 +59,7 @@ namespace NadekoBot.Modules.Searches .ConfigureAwait(false); if (autoDelete) try { await umsg.DeleteAsync().ConfigureAwait(false); } catch { } - await umsg.Channel.SendMessageAsync($"{umsg.Author.Mention} `said:` "+text.Replace("<@ ", "<@").Replace("<@! ", "<@!")).ConfigureAwait(false); + await umsg.Channel.SendMessageAsync($"{umsg.Author.Mention} `:` "+text.Replace("<@ ", "<@").Replace("<@! ", "<@!")).ConfigureAwait(false); } catch { } @@ -161,6 +161,7 @@ namespace NadekoBot.Modules.Searches if (!GoogleTranslator.Instance.Languages.Contains(from) || !GoogleTranslator.Instance.Languages.Contains(to)) { try { await channel.SendMessageAsync("`Invalid source and/or target Language.`").ConfigureAwait(false); } catch { } + return; } UserLanguages.AddOrUpdate(ucp, langs, (key, val) => langs); From 6350efd7f94553168b585f57291001976201b4e6 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 8 Nov 2016 20:30:34 +0100 Subject: [PATCH 43/58] Alphabetical TOC in commandlist. Removed whitespaces --- docs/Commands List.md | 90 +++++++++++++++--------------- src/NadekoBot/Modules/Help/Help.cs | 2 +- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/docs/Commands List.md b/docs/Commands List.md index 38be823c..f159a7ca 100644 --- a/docs/Commands List.md +++ b/docs/Commands List.md @@ -1,17 +1,17 @@ For more information and how to setup your own NadekoBot, go to: You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com` ##Table Of Contents -- [Searches](#searches) -- [NSFW](#nsfw) -- [Music](#music) - [Help](#help) -- [Permissions](#permissions) -- [Gambling](#gambling) - [Administration](#administration) -- [Utility](#utility) - [ClashOfClans](#clashofclans) - [CustomReactions](#customreactions) +- [Gambling](#gambling) - [Games](#games) +- [Music](#music) +- [NSFW](#nsfw) +- [Permissions](#permissions) +- [Searches](#searches) +- [Utility](#utility) ### Administration @@ -19,35 +19,35 @@ Command and aliases | Description | Usage ----------------|--------------|------- `.resetperms` | Resets BOT's permissions module on this server to the default value. **Requires Administrator server permission.** | `.resetperms` `.delmsgoncmd` | Toggles the automatic deletion of user's successful command message to prevent chat flood. **Requires Administrator server permission.** | `.delmsgoncmd` -`.setrole` `.sr` | Sets a role for a given user. **Requires ManageRoles server permission.** | `.sr @User Guest` -`.removerole` `.rr` | Removes a role from a given user. **Requires ManageRoles server permission.** | `.rr @User Admin` +`.setrole` `.sr` | Sets a role for a given user. **Requires ManageRoles server permission.** | `.sr @User Guest` +`.removerole` `.rr` | Removes a role from a given user. **Requires ManageRoles server permission.** | `.rr @User Admin` `.renamerole` `.renr` | Renames a role. Roles you are renaming must be lower than bot's highest role. **Requires ManageRoles server permission.** | `.renr "First role" SecondRole` -`.removeallroles` `.rar` | Removes all roles from a mentioned user. **Requires ManageRoles server permission.** | `.rar @User` -`.createrole` `.cr` | Creates a role with a given name. **Requires ManageRoles server permission.** | `.cr Awesome Role` -`.rolecolor` `.rc` | Set a role's color to the hex or 0-255 rgb color value provided. **Requires ManageRoles server permission.** | `.rc Admin 255 200 100` or `.rc Admin ffba55` +`.removeallroles` `.rar` | Removes all roles from a mentioned user. **Requires ManageRoles server permission.** | `.rar @User` +`.createrole` `.cr` | Creates a role with a given name. **Requires ManageRoles server permission.** | `.cr Awesome Role` +`.rolecolor` `.rc` | Set a role's color to the hex or 0-255 rgb color value provided. **Requires ManageRoles server permission.** | `.rc Admin 255 200 100` or `.rc Admin ffba55` `.ban` `.b` | Bans a user by ID or name with an optional message. **Requires BanMembers server permission.** | `.b "@some Guy" Your behaviour is toxic.` -`.softban` `.sb` | Bans and then unbans a user by ID or name with an optional message. **Requires KickMembers server permission.** **Requires ManageMessages server permission.** | `.sb "@some Guy" Your behaviour is toxic.` -`.kick` `.k` | Kicks a mentioned user. **Requires KickMembers server permission.** | `.k "@some Guy" Your behaviour is toxic.` +`.softban` `.sb` | Bans and then unbans a user by ID or name with an optional message. **Requires KickMembers server permission.** **Requires ManageMessages server permission.** | `.sb "@some Guy" Your behaviour is toxic.` +`.kick` `.k` | Kicks a mentioned user. **Requires KickMembers server permission.** | `.k "@some Guy" Your behaviour is toxic.` `.setmuterole` | Sets a name of the role which will be assigned to people who should be muted. Default is nadeko-mute. After specifying this role, restart commands which use mute as punishment. **Requires ManageRoles server permission.** | `.setmuterole Silenced` `.mute` | Mutes a mentioned user both from speaking and chatting. **Requires ManageRoles server permission.** **Requires MuteMembers server permission.** | `.mute @Someone` `.unmute` | Unmutes a mentioned user previously muted with `.mute` command. **Requires ManageRoles server permission.** **Requires MuteMembers server permission.** | `.unmute @Someone` `.chatmute` | Prevents a mentioned user from chatting in text channels. **Requires ManageRoles server permission.** | `.chatmute @Someone` `.chatunmute` | Removes a mute role previously set on a mentioned user with `.chatmute` which prevented him from chatting in text channels. **Requires ManageRoles server permission.** | `.chatunmute @Someone` `.voicemute` | Prevents a mentioned user from speaking in voice channels. **Requires MuteMembers server permission.** | `.voicemute @Someone` -`.voiceunmute` | Gives a previously voice-muted user a permission to speak. **Requires MuteMembers server permission.** | `.voiceunmute @Someguy` -`.deafen` `.deaf` | Deafens mentioned user or users. **Requires DeafenMembers server permission.** | `.deaf "@Someguy"` or `.deaf "@Someguy" "@Someguy"` -`.undeafen` `.undef` | Undeafens mentioned user or users. **Requires DeafenMembers server permission.** | `.undef "@Someguy"` or `.undef "@Someguy" "@Someguy"` -`.delvoichanl` `.dvch` | Deletes a voice channel with a given name. **Requires ManageChannels server permission.** | `.dvch VoiceChannelName` -`.creatvoichanl` `.cvch` | Creates a new voice channel with a given name. **Requires ManageChannels server permission.** | `.cvch VoiceChannelName` -`.deltxtchanl` `.dtch` | Deletes a text channel with a given name. **Requires ManageChannels server permission.** | `.dtch TextChannelName` -`.creatxtchanl` `.ctch` | Creates a new text channel with a given name. **Requires ManageChannels server permission.** | `.ctch TextChannelName` -`.settopic` `.st` | Sets a topic on the current channel. **Requires ManageChannels server permission.** | `.st My new topic` -`.setchanlname` `.schn` | Changes the name of the current channel. **Requires ManageChannels server permission.** | `.schn NewName` -`.prune` `.clr` | `.prune` removes all nadeko's messages in the last 100 messages.`.prune X` removes last X messages from the channel (up to 100)`.prune @Someone` removes all Someone's messages in the last 100 messages.`.prune @Someone X` removes last X 'Someone's' messages in the channel. | `.prune` or `.prune 5` or `.prune @Someone` or `.prune @Someone X` +`.voiceunmute` | Gives a previously voice-muted user a permission to speak. **Requires MuteMembers server permission.** | `.voiceunmute @Someguy` +`.deafen` `.deaf` | Deafens mentioned user or users. **Requires DeafenMembers server permission.** | `.deaf "@Someguy"` or `.deaf "@Someguy" "@Someguy"` +`.undeafen` `.undef` | Undeafens mentioned user or users. **Requires DeafenMembers server permission.** | `.undef "@Someguy"` or `.undef "@Someguy" "@Someguy"` +`.delvoichanl` `.dvch` | Deletes a voice channel with a given name. **Requires ManageChannels server permission.** | `.dvch VoiceChannelName` +`.creatvoichanl` `.cvch` | Creates a new voice channel with a given name. **Requires ManageChannels server permission.** | `.cvch VoiceChannelName` +`.deltxtchanl` `.dtch` | Deletes a text channel with a given name. **Requires ManageChannels server permission.** | `.dtch TextChannelName` +`.creatxtchanl` `.ctch` | Creates a new text channel with a given name. **Requires ManageChannels server permission.** | `.ctch TextChannelName` +`.settopic` `.st` | Sets a topic on the current channel. **Requires ManageChannels server permission.** | `.st My new topic` +`.setchanlname` `.schn` | Changes the name of the current channel. **Requires ManageChannels server permission.** | `.schn NewName` +`.prune` `.clr` | `.prune` removes all nadeko's messages in the last 100 messages.`.prune X` removes last X messages from the channel (up to 100)`.prune @Someone` removes all Someone's messages in the last 100 messages.`.prune @Someone X` removes last X 'Someone's' messages in the channel. | `.prune` or `.prune 5` or `.prune @Someone` or `.prune @Someone X` `.die` | Shuts the bot down. **Bot owner only.** | `.die` -`.setname` `.newnm` | Gives the bot a new name. **Bot owner only.** | `.newnm BotName` -`.setavatar` `.setav` | Sets a new avatar image for the NadekoBot. Argument is a direct link to an image. **Bot owner only.** | `.setav http://i.imgur.com/xTG3a1I.jpg` -`.setgame` | Sets the bots game. **Bot owner only.** | `.setgame with snakes` +`.setname` `.newnm` | Gives the bot a new name. **Bot owner only.** | `.newnm BotName` +`.setavatar` `.setav` | Sets a new avatar image for the NadekoBot. Argument is a direct link to an image. **Bot owner only.** | `.setav http://i.imgur.com/xTG3a1I.jpg` +`.setgame` | Sets the bots game. **Bot owner only.** | `.setgame with snakes` `.setstream` | Sets the bots stream. First argument is the twitch link, second argument is stream name. **Bot owner only.** | `.setstream https://www.twitch.tv/masterkwoth Developing Nakedo` `.send` | 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:`. **Bot owner only.** | `.send serverid|c:channelid` or `.send serverid|u:userid` `.announce` | Sends a message to all servers' general channel bot is connected to. **Bot owner only.** | `.announce Useless spam` @@ -57,23 +57,23 @@ Command and aliases | Description | Usage `.donadd` | Add a donator to the database. **Bot owner only.** | `.donadd Donate Amount` `.antiraid` | Sets an anti-raid protection on the server. First argument is number of people which will trigger the protection. Second one is a time interval in which that number of people needs to join in order to trigger the protection, and third argument is punishment for those people (Kick, Ban, Mute) **Requires Administrator server permission.** | `.antiraid 5 20 Kick` `.antispam` | Stops people from repeating same message X times in a row. You can specify to either mute, kick or ban the offenders. **Requires Administrator server permission.** | `.antispam 3 Mute` or `.antispam 4 Kick` or `.antispam 6 Ban` -`.autoassignrole` `.aar` | Automaticaly assigns a specified role to every user who joins the server. **Requires ManageRoles server permission.** | `.aar` to disable, `.aar Role Name` to enable +`.autoassignrole` `.aar` | Automaticaly assigns a specified role to every user who joins the server. **Requires ManageRoles server permission.** | `.aar` to disable, `.aar Role Name` to enable `.scsc` | Starts an instance of cross server channel. You will get a token as a DM that other people will use to tune in to the same instance. **Bot owner only.** | `.scsc` -`.jcsc` | Joins current channel to an instance of cross server channel using the token. **Requires ManageServer server permission.** | `.jcsc TokenHere` -`.lcsc` | Leaves Cross server channel instance from this channel. **Requires ManageServer server permission.** | `.lcsc` +`.jcsc` | Joins current channel to an instance of cross server channel using the token. **Requires ManageServer server permission.** | `.jcsc TokenHere` +`.lcsc` | Leaves Cross server channel instance from this channel. **Requires ManageServer server permission.** | `.lcsc` `.fwmsgs` | Toggles forwarding of non-command messages sent to bot's DM to the bot owners **Bot owner only.** | `.fwmsgs` `.fwtoall` | Toggles whether messages will be forwarded to all bot owners or only to the first one specified in the credentials.json **Bot owner only.** | `.fwtoall` `.logserver` | Logs server activity in this channel. **Requires Administrator server permission.** **Bot owner only.** | `.logserver` `.logignore` | Toggles whether the .logserver command ignores this channel. Useful if you have hidden admin channel and public log channel. **Requires Administrator server permission.** **Bot owner only.** | `.logignore` -`.userpresence` | Starts logging to this channel when someone from the server goes online/offline/idle. **Requires Administrator server permission.** | `.userpresence` -`.voicepresence` | Toggles logging to this channel whenever someone joins or leaves a voice channel you are currently in. **Requires Administrator server permission.** | `.voicepresence` -`.repeatinvoke` `.repinv` | Immediately shows the repeat message and restarts the timer. **Requires ManageMessages server permission.** | `.repinv` +`.userpresence` | Starts logging to this channel when someone from the server goes online/offline/idle. **Requires Administrator server permission.** | `.userpresence` +`.voicepresence` | Toggles logging to this channel whenever someone joins or leaves a voice channel you are currently in. **Requires Administrator server permission.** | `.voicepresence` +`.repeatinvoke` `.repinv` | Immediately shows the repeat message and restarts the timer. **Requires ManageMessages server permission.** | `.repinv` `.repeat` | Repeat a message every X minutes. If no parameters are specified, repeat is disabled. | `.repeat 5 Hello there` `.migratedata` | Migrate data from old bot configuration **Bot owner only.** | `.migratedata` `.rotateplaying` `.ropl` | Toggles rotation of playing status of the dynamic strings you previously specified. **Bot owner only.** | `.ropl` `.addplaying` `.adpl` | Adds a specified string to the list of playing strings to rotate. Supported placeholders: %servers%, %users%, %playing%, %queued% **Bot owner only.** | `.adpl` `.listplaying` `.lipl` | Lists all playing statuses with their corresponding number. **Bot owner only.** | `.lipl` -`.removeplaying` `.rmpl` `.repl` | Removes a playing string on a given number. **Bot owner only.** | `.rmpl` +`.removeplaying` `.rmpl` `.repl` | Removes a playing string on a given number. **Bot owner only.** | `.rmpl` `.slowmode` | Toggles slowmode. Disable by specifying no parameters. To enable, specify a number of messages each user can send, and an interval in seconds. For example 1 message every 5 seconds. **Requires ManageMessages server permission.** | `.slowmode 1 5` or `.slowmode` `.adsarm` | Toggles the automatic deletion of confirmations for .iam and .iamn commands. **Requires ManageMessages server permission.** | `.adsarm` `.asar` | Adds a role to the list of self-assignable roles. **Requires ManageRoles server permission.** | `.asar Gamer` @@ -82,16 +82,16 @@ Command and aliases | Description | Usage `.togglexclsar` `.tesar` | Toggles whether the self-assigned roles are exclusive. (So that any person can have only one of the self assignable roles) **Requires ManageRoles server permission.** | `.tesar` `.iam` | Adds a role to you that you choose. Role must be on a list of self-assignable roles. | `.iam Gamer` `.iamnot` `.iamn` | Removes a role to you that you choose. Role must be on a list of self-assignable roles. | `.iamn Gamer` -`.leave` | Makes Nadeko leave the server. Either name or id required. **Bot owner only.** | `.leave 123123123331` -`.greetdel` `.grdel` | Toggles automatic deletion of greet messages. **Requires ManageServer server permission.** | `.greetdel` -`.greet` | Toggles anouncements on the current channel when someone joins the server. **Requires ManageServer server permission.** | `.greet` -`.greetmsg` | Sets a new join announcement message which will be shown in the server's channel. Type %user% if you want to mention the new member. Using it with no message will show the current greet message. **Requires ManageServer server permission.** | `.greetmsg Welcome, %user%.` -`.greetdm` | Toggles whether the greet messages will be sent in a DM (This is separate from greet - you can have both, any or neither enabled). **Requires ManageServer server permission.** | `.greetdm` -`.greetdmmsg` | Sets a new join announcement message which will be sent to the user who joined. Type %user% if you want to mention the new member. Using it with no message will show the current DM greet message. **Requires ManageServer server permission.** | `.greetdmmsg Welcome to the server, %user%`. +`.leave` | Makes Nadeko leave the server. Either name or id required. **Bot owner only.** | `.leave 123123123331` +`.greetdel` `.grdel` | Toggles automatic deletion of greet messages. **Requires ManageServer server permission.** | `.greetdel` +`.greet` | Toggles anouncements on the current channel when someone joins the server. **Requires ManageServer server permission.** | `.greet` +`.greetmsg` | Sets a new join announcement message which will be shown in the server's channel. Type %user% if you want to mention the new member. Using it with no message will show the current greet message. **Requires ManageServer server permission.** | `.greetmsg Welcome, %user%.` +`.greetdm` | Toggles whether the greet messages will be sent in a DM (This is separate from greet - you can have both, any or neither enabled). **Requires ManageServer server permission.** | `.greetdm` +`.greetdmmsg` | Sets a new join announcement message which will be sent to the user who joined. Type %user% if you want to mention the new member. Using it with no message will show the current DM greet message. **Requires ManageServer server permission.** | `.greetdmmsg Welcome to the server, %user%`. `.bye` | Toggles anouncements on the current channel when someone leaves the server. **Requires ManageServer server permission.** | `.bye` -`.byemsg` | Sets a new leave announcement message. Type %user% if you want to mention the new member. Using it with no message will show the current bye message. **Requires ManageServer server permission.** | `.byemsg %user% has left.` -`.byedel` | Toggles automatic deletion of bye messages. **Requires ManageServer server permission.** | `.byedel` -`.voice+text` `.v+t` | Creates a text channel for each voice channel only users in that voice channel can see.If you are server owner, keep in mind you will see them all the time regardless. **Requires ManageRoles server permission.** **Requires ManageChannels server permission.** | `.voice+text` +`.byemsg` | Sets a new leave announcement message. Type %user% if you want to mention the new member. Using it with no message will show the current bye message. **Requires ManageServer server permission.** | `.byemsg %user% has left.` +`.byedel` | Toggles automatic deletion of bye messages. **Requires ManageServer server permission.** | `.byedel` +`.voice+text` `.v+t` | Creates a text channel for each voice channel only users in that voice channel can see.If you are server owner, keep in mind you will see them all the time regardless. **Requires ManageRoles server permission.** **Requires ManageChannels server permission.** | `.voice+text` `.cleanvplust` `.cv+t` | Deletes all text channels ending in `-voice` for which voicechannels are not found. Use at your own risk. **Requires ManageChannels server permission.** **Requires ManageRoles server permission.** | `.cleanv+t` ###### [Back to TOC](#table-of-contents) @@ -128,7 +128,7 @@ Command and aliases | Description | Usage `$cash` `$$$` | Check how much currency a person has. (Defaults to yourself) | `$$$` or `$$$ @SomeGuy` `$give` | Give someone a certain amount of currency. | `$give 1 "@SomeGuy"` `$award` | Awards someone a certain amount of currency. You can also specify a role name to award currency to all users in a role. **Bot owner only.** | `$award 100 @person` or `$award 5 Role Of Gamblers` -`$take` | Takes a certain amount of currency from someone. **Bot owner only.** | `$take 1 "@someguy"` +`$take` | Takes a certain amount of currency from someone. **Bot owner only.** | `$take 1 "@someguy"` `$betroll` `$br` | Bets a certain amount of currency and rolls a dice. Rolling over 66 yields x2 of your currency, over 90 - x3 and 100 x10. | `$br 5` `$leaderboard` `$lb` | Displays bot currency leaderboard. | `$lb` `$race` | Starts a new animal race. | `$race` @@ -154,7 +154,7 @@ Command and aliases | Description | Usage `>poll` | Creates a poll which requires users to send the number of the voting option to the bot. **Requires ManageMessages server permission.** | `>poll Question?;Answer1;Answ 2;A_3` `>publicpoll` `>ppoll` | Creates a public poll which requires users to type a number of the voting option in the channel command is ran in. **Requires ManageMessages server permission.** | `>ppoll Question?;Answer1;Answ 2;A_3` `>pollend` | Stops active poll on this server and prints the results in this channel. **Requires ManageMessages server permission.** | `>pollend` -`>cleverbot` | Toggles cleverbot session. When enabled, the bot will reply to messages starting with bot mention in the channel this command is ran in. You can specify "all" parameter to enable it in the whole server. Custom reactions starting with %mention% won't work if cleverbot is enabled.' **Requires ManageMessages server permission.** | `>cleverbot` +`>cleverbot` | Toggles cleverbot session. When enabled, the bot will reply to messages starting with bot mention in the server. Custom reactions starting with %mention% won't work if cleverbot is enabled. **Requires ManageMessages server permission.** | `>cleverbot` `>pick` | Picks the currency planted in this channel. | `>pick` `>plant` | Spend a unit of currency to plant it in this channel. (If bot is restarted or crashes, the currency will be lost) | `>plant` `>gencurrency` `>gc` | Toggles currency generation on this channel. Every posted message will have chance to spawn currency. Chance is specified by the Bot Owner. (default is 2%) **Requires ManageMessages server permission.** | `>gc` @@ -347,6 +347,6 @@ Command and aliases | Description | Usage `.deletequote` `.delq` | 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` `.delallq` `.daq` | Deletes all quotes on a specified keyword. **Requires Administrator server permission.** | `.delallq kek` `.remind` | Sends a message to you or a channel after certain amount of time. First argument is me/here/'channelname'. Second argument is time in a descending order (mo>w>d>h>m) example: 1w5d3h10m. Third argument is a (multiword)message. | `.remind me 1d5h Do something` or `.remind #general Start now!` -`.remindtemplate` | Sets message for when the remind is triggered. Available placeholders are %user% - user who ran the command, %message% - Message specified in the remind, %target% - target channel of the remind. **Bot owner only.** | `.remindtemplate %user%, you gotta do %message%!` +`.remindtemplate` | Sets message for when the remind is triggered. Available placeholders are %user% - user who ran the command, %message% - Message specified in the remind, %target% - target channel of the remind. **Bot owner only.** | `.remindtemplate %user%, you gotta do %message%!` `.convertlist` | List of the convertible dimensions and currencies. | `.convertlist` `.convert` | Convert quantities. Use `.convertlist` to see supported dimensions and currencies. | `.convert m km 1000` diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index a11e1d60..7728fa81 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -128,7 +128,7 @@ namespace NadekoBot.Modules.Help helpstr.AppendLine(@"For more information and how to setup your own NadekoBot, go to: You can support the project on patreon: or paypal: `nadekodiscordbot@gmail.com`"); helpstr.AppendLine("##Table Of Contents"); - helpstr.AppendLine(string.Join("\n", NadekoBot.CommandService.Modules.Select(m => $"- [{m.Name}](#{m.Name.ToLowerInvariant()})"))); + helpstr.AppendLine(string.Join("\n", NadekoBot.CommandService.Modules.Where(m => m.Name.ToLowerInvariant() != "help").OrderBy(m => m.Name).Prepend(NadekoBot.CommandService.Modules.FirstOrDefault(m=>m.Name.ToLowerInvariant()=="help")).Select(m => $"- [{m.Name}](#{m.Name.ToLowerInvariant()})"))); helpstr.AppendLine(); string lastModule = null; foreach (var com in _commands.Commands.OrderBy(com=>com.Module.Name).GroupBy(c=>c.Text).Select(g=>g.First())) From f9bf74b7f2a59a259ef08fd50a88563da337eb6e Mon Sep 17 00:00:00 2001 From: miraai Date: Tue, 8 Nov 2016 21:34:12 +0100 Subject: [PATCH 44/58] fix fix --- docs/JSON Explanations.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/JSON Explanations.md b/docs/JSON Explanations.md index 2b1ca7f8..91416939 100644 --- a/docs/JSON Explanations.md +++ b/docs/JSON Explanations.md @@ -17,9 +17,7 @@ If you do not see `credentials.json` you will need to rename `credentials_exampl "SoundCloudClientId": "", "CarbonKey": "", "Db": null, - "TotalShards": 1, - "CleverbotApiUser": "", - "CleverbotApiKey": "" + "TotalShards": 1 } ``` ####Required Parts @@ -50,7 +48,6 @@ Setting up your API keys - You can get this key [here](https://osu.ppy.sh/p/api) **You will need to log in and like the soundcloud it may take a few tries** - **CarbonKey** -This key is for Carobnitex.net stats. - Most likely unnecessary **Needed only if your bot is listed on Carbonitex.net** -- **CleverbotApiUser and CleverbotApiKey** - API Keys for CleverBot feature, you can get your keys here: [CleverBot APIs][CleverBot APIs] Additional options ==================== From c6bab91c4000e6f30f8e16e81a46cbdf710691b7 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 8 Nov 2016 22:05:04 +0100 Subject: [PATCH 45/58] Error message when mashape isn't specified --- src/NadekoBot/Modules/Searches/Searches.cs | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 9a370f80..38d398ed 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -206,9 +206,16 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var arg = name; if (string.IsNullOrWhiteSpace(arg)) { - await channel.SendMessageAsync("πŸ’’ Please enter a card name to search for.").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’ `Please enter a card name to search for.`").ConfigureAwait(false); return; } + + if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.MashapeKey)) + { + await channel.SendMessageAsync("πŸ’’ `Bot owner didn't specify MashapeApiKey. You can't use this functionality.`").ConfigureAwait(false); + return; + } + await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); string response = ""; using (var http = new HttpClient()) @@ -256,10 +263,16 @@ $@"🌍 **Weather for** 【{obj["target"]}】 { 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 search term.").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’ `Please enter a search term.`").ConfigureAwait(false); return; } await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); @@ -293,9 +306,15 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var arg = query; if (string.IsNullOrWhiteSpace(arg)) { - await channel.SendMessageAsync("πŸ’’ Please enter a search term.").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’ `Please enter a search term.`").ConfigureAwait(false); return; } + if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.MashapeKey)) + { + await channel.SendMessageAsync("πŸ’’ `Bot owner didn't specify MashapeApiKey. You can't use this functionality.`").ConfigureAwait(false); + return; + } + await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); string res = ""; using (var http = new HttpClient()) From 19bf146e4a601e903d9f17c14dccfcdd53fc8747 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 8 Nov 2016 22:22:39 +0100 Subject: [PATCH 46/58] AntiRaid/Antispam now log to .logserver instead of guild owner DM --- .../Modules/Administration/Administration.cs | 8 +- .../Commands/AntiRaidCommands.cs | 86 +++++++++---------- .../Administration/Commands/LogCommand.cs | 55 +++++++++--- 3 files changed, 89 insertions(+), 60 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Administration.cs b/src/NadekoBot/Modules/Administration/Administration.cs index d7f72186..912d457d 100644 --- a/src/NadekoBot/Modules/Administration/Administration.cs +++ b/src/NadekoBot/Modules/Administration/Administration.cs @@ -88,8 +88,12 @@ namespace NadekoBot.Modules.Administration foreach (var toOverwrite in guild.GetTextChannels()) { - await toOverwrite.AddPermissionOverwriteAsync(muteRole, new OverwritePermissions(sendMessages: PermValue.Deny, attachFiles: PermValue.Deny)) - .ConfigureAwait(false); + try + { + await toOverwrite.AddPermissionOverwriteAsync(muteRole, new OverwritePermissions(sendMessages: PermValue.Deny, attachFiles: PermValue.Deny)) + .ConfigureAwait(false); + } + catch { } await Task.Delay(200).ConfigureAwait(false); } } diff --git a/src/NadekoBot/Modules/Administration/Commands/AntiRaidCommands.cs b/src/NadekoBot/Modules/Administration/Commands/AntiRaidCommands.cs index 2550a94d..07d3b775 100644 --- a/src/NadekoBot/Modules/Administration/Commands/AntiRaidCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/AntiRaidCommands.cs @@ -114,9 +114,9 @@ namespace NadekoBot.Modules.Administration { if (spamSettings.UserStats.TryRemove(msg.Author.Id, out stats)) { - var log = await PunishUser((IGuildUser)msg.Author, spamSettings.Action, spamSettings.MuteRole, ProtectionType.Spamming) + await PunishUsers(spamSettings.Action, spamSettings.MuteRole, ProtectionType.Spamming, (IGuildUser)msg.Author) .ConfigureAwait(false); - await channel.Guild.SendMessageToOwnerAsync(log).ConfigureAwait(false); } + } } } catch { } @@ -142,16 +142,11 @@ namespace NadekoBot.Modules.Administration if (settings.UsersCount >= settings.UserThreshold) { - var users = settings.RaidUsers.ToList(); + var users = settings.RaidUsers.ToArray(); settings.RaidUsers.Clear(); - string msg = ""; - foreach (var gu in users) - { - msg += await PunishUser(gu, settings.Action, settings.MuteRole, ProtectionType.Raiding).ConfigureAwait(false); - } - try { await usr.Guild.SendMessageToOwnerAsync(msg).ConfigureAwait(false); } catch { } - } + await PunishUsers(settings.Action, settings.MuteRole, ProtectionType.Raiding, users).ConfigureAwait(false); + } await Task.Delay(1000 * settings.Seconds).ConfigureAwait(false); settings.RaidUsers.TryRemove(usr); @@ -161,50 +156,49 @@ namespace NadekoBot.Modules.Administration return Task.CompletedTask; }; } - - private async Task PunishUser(IGuildUser gu, PunishmentAction action, IRole muteRole, ProtectionType pt) + + private async Task PunishUsers(PunishmentAction action, IRole muteRole, ProtectionType pt, params IGuildUser[] gus) { - switch (action) + foreach (var gu in gus) { - case PunishmentAction.Mute: - try - { - await gu.AddRolesAsync(muteRole); - return $"{Format.Bold(gu.ToString())} was **MUTED** due to `{pt}` protection on **{gu.Guild.Name}** server.\n"; - } - catch (Exception ex) { _log.Warn(ex, "I can't apply punishement"); } - break; - case PunishmentAction.Kick: - try - { - await gu.Guild.AddBanAsync(gu, 7); + switch (action) + { + case PunishmentAction.Mute: try { - await gu.Guild.RemoveBanAsync(gu); + await gu.AddRolesAsync(muteRole); } - catch + catch (Exception ex) { _log.Warn(ex, "I can't apply punishement"); } + break; + case PunishmentAction.Kick: + try { - await gu.Guild.RemoveBanAsync(gu); - // try it twice, really don't want to ban user if - // only kick has been specified as the punishement + await gu.Guild.AddBanAsync(gu, 7); + try + { + await gu.Guild.RemoveBanAsync(gu); + } + catch + { + await gu.Guild.RemoveBanAsync(gu); + // try it twice, really don't want to ban user if + // only kick has been specified as the punishement + } } - return $"{Format.Bold(gu.ToString())} was **KICKED** due to `{pt}` protection on **{gu.Guild.Name}** server.\n"; - - } - catch (Exception ex) { _log.Warn(ex, "I can't apply punishment"); } - break; - case PunishmentAction.Ban: - try - { - await gu.Guild.AddBanAsync(gu, 7); - return $"{Format.Bold(gu.ToString())} was **BANNED** due to `{pt}` protection on **{gu.Guild.Name}** server.\n"; - } - catch (Exception ex) { _log.Warn(ex, "I can't apply punishment"); } - break; - default: - break; + catch (Exception ex) { _log.Warn(ex, "I can't apply punishment"); } + break; + case PunishmentAction.Ban: + try + { + await gu.Guild.AddBanAsync(gu, 7); + } + catch (Exception ex) { _log.Warn(ex, "I can't apply punishment"); } + break; + default: + break; + } } - return String.Empty; + await LogCommands.TriggeredAntiProtection(gus, action, pt).ConfigureAwait(false); } diff --git a/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs b/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs index 23aa8e7c..a366baef 100644 --- a/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs @@ -22,21 +22,20 @@ namespace NadekoBot.Modules.Administration [Group] public class LogCommands { - private ShardedDiscordClient _client { get; } - private Logger _log { get; } + private static ShardedDiscordClient _client { get; } + private static Logger _log { get; } - private string prettyCurrentTime => $"【{DateTime.Now:HH:mm:ss}】"; + private static string prettyCurrentTime => $"【{DateTime.Now:HH:mm:ss}】"; - public ConcurrentDictionary GuildLogSettings { get; } + public static ConcurrentDictionary GuildLogSettings { get; } - private ConcurrentDictionary> UserPresenceUpdates { get; } = new ConcurrentDictionary>(); - private Timer t; + private static ConcurrentDictionary> UserPresenceUpdates { get; } = new ConcurrentDictionary>(); + private static Timer timerReference { get; } private IGoogleApiService _google { get; } - public LogCommands(ShardedDiscordClient client, IGoogleApiService google) + static LogCommands() { - _client = client; - _google = google; + _client = NadekoBot.Client; _log = LogManager.GetCurrentClassLogger(); using (var uow = DbHandler.UnitOfWork()) @@ -45,7 +44,7 @@ namespace NadekoBot.Modules.Administration .ToDictionary(g => g.GuildId, g => g.LogSetting)); } - t = new Timer(async (state) => + timerReference = new Timer(async (state) => { try { @@ -63,8 +62,10 @@ namespace NadekoBot.Modules.Administration _log.Warn(ex); } }, null, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10)); - + } + public LogCommands(ShardedDiscordClient client) + { //_client.MessageReceived += _client_MessageReceived; _client.MessageUpdated += _client_MessageUpdated; _client.MessageDeleted += _client_MessageDeleted; @@ -81,6 +82,36 @@ namespace NadekoBot.Modules.Administration _client.ChannelUpdated += _client_ChannelUpdated; } + public static async Task TriggeredAntiProtection(IGuildUser[] users, PunishmentAction action, ProtectionType protection) + { + if (users.Length == 0) + return; + + LogSetting logSetting; + if (!GuildLogSettings.TryGetValue(users.First().Guild.Id, out logSetting) + || !logSetting.IsLogging) + return; + ITextChannel logChannel; + if ((logChannel = TryGetLogChannel(users.First().Guild, logSetting)) == null) + return; + + var punishment = ""; + if (action == PunishmentAction.Mute) + { + punishment = "MUTED"; + } + else if (action == PunishmentAction.Kick) + { + punishment = "KICKED"; + } + else if (action == PunishmentAction.Ban) + { + punishment = "BANNED"; + } + await logChannel.SendMessageAsync(String.Join("\n",users.Select(user=>$"{Format.Bold(user.ToString())} was **{punishment}** due to `{protection}` protection on **{user.Guild.Name}** server."))) + .ConfigureAwait(false); + } + private Task _client_UserUpdated(IGuildUser before, IGuildUser after) { LogSetting logSetting; @@ -461,7 +492,7 @@ namespace NadekoBot.Modules.Administration // } private enum LogChannelType { Text, Voice, UserPresence }; - private ITextChannel TryGetLogChannel(IGuild guild, LogSetting logSetting, LogChannelType logChannelType = LogChannelType.Text) + private static ITextChannel TryGetLogChannel(IGuild guild, LogSetting logSetting, LogChannelType logChannelType = LogChannelType.Text) { ulong id = 0; switch (logChannelType) From b1b4afc0e881ac816757b547d1b31a131fe9bc78 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 8 Nov 2016 22:31:46 +0100 Subject: [PATCH 47/58] Cleverbot now mentions person it is talking to --- src/NadekoBot/Modules/Games/Commands/CleverBotCommands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Games/Commands/CleverBotCommands.cs b/src/NadekoBot/Modules/Games/Commands/CleverBotCommands.cs index 5858fb63..8ee2d9b0 100644 --- a/src/NadekoBot/Modules/Games/Commands/CleverBotCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/CleverBotCommands.cs @@ -83,7 +83,7 @@ namespace NadekoBot.Modules.Games catch (Exception ex) { _log.Warn(ex, "Eror sending response"); - await msg.Channel.SendMessageAsync(response).ConfigureAwait(false); // try twice :\ + await msg.Channel.SendMessageAsync(msg.Author.Mention+" "+response).ConfigureAwait(false); // try twice :\ } return true; } From 47bc2088262d932c98498367957cf59dbf12e591 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 8 Nov 2016 22:40:20 +0100 Subject: [PATCH 48/58] changing mute role no longer requires restart of .antispam/.antiraid --- .../Commands/AntiRaidCommands.cs | 24 ++++++++++++------- src/NadekoBot/Resources/CommandStrings.resx | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/AntiRaidCommands.cs b/src/NadekoBot/Modules/Administration/Commands/AntiRaidCommands.cs index 07d3b775..60b6b412 100644 --- a/src/NadekoBot/Modules/Administration/Commands/AntiRaidCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/AntiRaidCommands.cs @@ -36,7 +36,6 @@ namespace NadekoBot.Modules.Administration public int UserThreshold { get; set; } public int Seconds { get; set; } public PunishmentAction Action { get; set; } - public IRole MuteRole { get; set; } public int UsersCount { get; set; } public ConcurrentHashSet RaidUsers { get; set; } = new ConcurrentHashSet(); } @@ -45,7 +44,6 @@ namespace NadekoBot.Modules.Administration { public PunishmentAction Action { get; set; } public int MessageThreshold { get; set; } = 3; - public IRole MuteRole { get; set; } public ConcurrentDictionary UserStats { get; set; } = new ConcurrentDictionary(); } @@ -114,7 +112,7 @@ namespace NadekoBot.Modules.Administration { if (spamSettings.UserStats.TryRemove(msg.Author.Id, out stats)) { - await PunishUsers(spamSettings.Action, spamSettings.MuteRole, ProtectionType.Spamming, (IGuildUser)msg.Author) + await PunishUsers(spamSettings.Action, await GetMuteRole(channel.Guild), ProtectionType.Spamming, (IGuildUser)msg.Author) .ConfigureAwait(false); } } @@ -145,7 +143,7 @@ namespace NadekoBot.Modules.Administration var users = settings.RaidUsers.ToArray(); settings.RaidUsers.Clear(); - await PunishUsers(settings.Action, settings.MuteRole, ProtectionType.Raiding, users).ConfigureAwait(false); + await PunishUsers(settings.Action, await GetMuteRole(usr.Guild), ProtectionType.Raiding, users).ConfigureAwait(false); } await Task.Delay(1000 * settings.Seconds).ConfigureAwait(false); @@ -221,10 +219,9 @@ namespace NadekoBot.Modules.Administration return; } - IRole muteRole; try { - muteRole = await GetMuteRole(channel.Guild).ConfigureAwait(false); + await GetMuteRole(channel.Guild).ConfigureAwait(false); } catch (Exception ex) { @@ -240,7 +237,6 @@ namespace NadekoBot.Modules.Administration Action = action, Seconds = seconds, UserThreshold = userThreshold, - MuteRole = muteRole, }; antiRaidGuilds.AddOrUpdate(channel.Guild.Id, setting, (id, old) => setting); @@ -265,10 +261,22 @@ namespace NadekoBot.Modules.Administration } else { + try + { + await GetMuteRole(channel.Guild).ConfigureAwait(false); + } + catch (Exception ex) + { + await channel.SendMessageAsync("Failed creating a mute role. Give me ManageRoles permission" + + "or create 'nadeko-mute' role with disabled SendMessages and try again.") + .ConfigureAwait(false); + _log.Warn(ex); + return; + } + if (antiSpamGuilds.TryAdd(channel.Guild.Id, new AntiSpamSetting() { Action = action, - MuteRole = await GetMuteRole(channel.Guild).ConfigureAwait(false), MessageThreshold = messageCount, })) await channel.SendMessageAsync("`Anti-Spam feature enabled on this server.`").ConfigureAwait(false); diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index c14896e3..ad45c5ee 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2470,7 +2470,7 @@ setmuterole - Sets a name of the role which will be assigned to people who should be muted. Default is nadeko-mute. After specifying this role, restart commands which use mute as punishment. + Sets a name of the role which will be assigned to people who should be muted. Default is nadeko-mute. `{0}setmuterole Silenced` From 94ecd8f6b1f1044dd543f26899d2d7086d352c94 Mon Sep 17 00:00:00 2001 From: miraai Date: Wed, 9 Nov 2016 00:42:48 +0100 Subject: [PATCH 49/58] removed dots --- docs/JSON Explanations.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/JSON Explanations.md b/docs/JSON Explanations.md index 91416939..e89be978 100644 --- a/docs/JSON Explanations.md +++ b/docs/JSON Explanations.md @@ -34,20 +34,20 @@ Setting up your API keys ==================== ####This part is completely optional, **However it is necessary for music to work properly** - **GoogleAPIKey** - Required for Youtube Song Search, Playlist queuing, and URL Shortener. `~i` and `~img`. - - You can get this api Key [here](https://console.developers.google.com/apis) + You can get this api Key [here](https://console.developers.google.com/apis) - **SoundCloudClientID** - Required to queue soundloud songs from sc links. - - You will need to create a new app [here](http://soundcloud.com/you/apps). **Please note you must be logged into SoundCloud** + You will need to create a new app [here](http://soundcloud.com/you/apps). **Please note you must be logged into SoundCloud** - Simply click Register a new application and enter a name. - Copy the Client ID and click "save app" then paste the Client Id it into your `credentials.json` - **MashapeKey** - Required for Urban Disctionary, Hashtag search, and Hearthstone cards. - - You need to create an account on their [api marketplace](https://market.mashape.com/), after that go to `market.mashape.com/YOURNAMEHERE/applications/default-application` and press **Get the keys** in the top right corner. + You need to create an account on their [api marketplace](https://market.mashape.com/), after that go to `market.mashape.com/YOURNAMEHERE/applications/default-application` and press **Get the keys** in the top right corner. - Copy the key and paste it into `credentials.json` - **LOLAPIKey** - Required for all League of Legends commands. - - You can get this key [here](http://api.champion.gg/) + You can get this key [here](http://api.champion.gg/) - **OsuAPIKey** - Required for Osu commands - - You can get this key [here](https://osu.ppy.sh/p/api) **You will need to log in and like the soundcloud it may take a few tries** + You can get this key [here](https://osu.ppy.sh/p/api) **You will need to log in and like the soundcloud it may take a few tries** - **CarbonKey** -This key is for Carobnitex.net stats. - - Most likely unnecessary **Needed only if your bot is listed on Carbonitex.net** + Most likely unnecessary **Needed only if your bot is listed on Carbonitex.net** Additional options ==================== From 64f80d80d02dd5295a2ee5c46d3aee2f897b2eea Mon Sep 17 00:00:00 2001 From: miraai Date: Wed, 9 Nov 2016 01:32:47 +0100 Subject: [PATCH 50/58] removed ones i missed --- docs/JSON Explanations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/JSON Explanations.md b/docs/JSON Explanations.md index e89be978..dd05e63a 100644 --- a/docs/JSON Explanations.md +++ b/docs/JSON Explanations.md @@ -52,7 +52,7 @@ Setting up your API keys Additional options ==================== - **TotalShards** - Required if the bot will be connected to more than 2500 servers - - Most likely unnecessary to change until your bot is added to more than 2000 servers + Most likely unnecessary to change until your bot is added to more than 2000 servers [//]: # (- **Db** - Allows for advanced database configuration ) [//]: # ( - Leave this with the `null` value for standard operation - change this to `examples` to [This is only a comment so doesn't need proper detail]) From d7eca59a74e2c5245db48c56a20d2e14ed1afe91 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 9 Nov 2016 07:30:20 +0100 Subject: [PATCH 51/58] Added ~shorten, updated commandlist with fixed --- docs/Commands List.md | 7 ++++--- src/NadekoBot/Modules/Searches/Searches.cs | 10 ++++++++++ src/NadekoBot/Resources/CommandStrings.resx | 13 +++++++++++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/docs/Commands List.md b/docs/Commands List.md index f159a7ca..54562a88 100644 --- a/docs/Commands List.md +++ b/docs/Commands List.md @@ -28,7 +28,7 @@ Command and aliases | Description | Usage `.ban` `.b` | Bans a user by ID or name with an optional message. **Requires BanMembers server permission.** | `.b "@some Guy" Your behaviour is toxic.` `.softban` `.sb` | Bans and then unbans a user by ID or name with an optional message. **Requires KickMembers server permission.** **Requires ManageMessages server permission.** | `.sb "@some Guy" Your behaviour is toxic.` `.kick` `.k` | Kicks a mentioned user. **Requires KickMembers server permission.** | `.k "@some Guy" Your behaviour is toxic.` -`.setmuterole` | Sets a name of the role which will be assigned to people who should be muted. Default is nadeko-mute. After specifying this role, restart commands which use mute as punishment. **Requires ManageRoles server permission.** | `.setmuterole Silenced` +`.setmuterole` | Sets a name of the role which will be assigned to people who should be muted. Default is nadeko-mute. **Requires ManageRoles server permission.** | `.setmuterole Silenced` `.mute` | Mutes a mentioned user both from speaking and chatting. **Requires ManageRoles server permission.** **Requires MuteMembers server permission.** | `.mute @Someone` `.unmute` | Unmutes a mentioned user previously muted with `.mute` command. **Requires ManageRoles server permission.** **Requires MuteMembers server permission.** | `.unmute @Someone` `.chatmute` | Prevents a mentioned user from chatting in text channels. **Requires ManageRoles server permission.** | `.chatmute @Someone` @@ -48,7 +48,7 @@ Command and aliases | Description | Usage `.setname` `.newnm` | Gives the bot a new name. **Bot owner only.** | `.newnm BotName` `.setavatar` `.setav` | Sets a new avatar image for the NadekoBot. Argument is a direct link to an image. **Bot owner only.** | `.setav http://i.imgur.com/xTG3a1I.jpg` `.setgame` | Sets the bots game. **Bot owner only.** | `.setgame with snakes` -`.setstream` | Sets the bots stream. First argument is the twitch link, second argument is stream name. **Bot owner only.** | `.setstream https://www.twitch.tv/masterkwoth Developing Nakedo` +`.setstream` | Sets the bots stream. First argument is the twitch link, second argument is stream name. **Bot owner only.** | `.setstream TWITCHLINK Hello` `.send` | 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:`. **Bot owner only.** | `.send serverid|c:channelid` or `.send serverid|u:userid` `.announce` | Sends a message to all servers' general channel bot is connected to. **Bot owner only.** | `.announce Useless spam` `.savechat` | Saves a number of messages to a text file and sends it to you. **Bot owner only.** | `.savechat 150` @@ -278,6 +278,7 @@ Command and aliases | Description | Usage `~img` `~i` | Pulls the first image found using a search parameter. Use ~ir for different results. | `~i cute kitten` `~ir` | Pulls a random image using a search parameter. | `~ir cute kitten` `~lmgtfy` | Google something for an idiot. | `~lmgtfy query` +`~shorten` | Attempts to shorten an URL, if it fails, returns the input URL. | `~shorten https://google.com` `~google` `~g` | Get a google search link for some terms. | `~google query` `~hearthstone` `~hs` | Searches for a Hearthstone card and shows its image. Takes a while to complete. | `~hs Ysera` `~urbandict` `~ud` | Searches Urban Dictionary for a word. | `~ud Pineapple` @@ -347,6 +348,6 @@ Command and aliases | Description | Usage `.deletequote` `.delq` | 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` `.delallq` `.daq` | Deletes all quotes on a specified keyword. **Requires Administrator server permission.** | `.delallq kek` `.remind` | Sends a message to you or a channel after certain amount of time. First argument is me/here/'channelname'. Second argument is time in a descending order (mo>w>d>h>m) example: 1w5d3h10m. Third argument is a (multiword)message. | `.remind me 1d5h Do something` or `.remind #general Start now!` -`.remindtemplate` | Sets message for when the remind is triggered. Available placeholders are %user% - user who ran the command, %message% - Message specified in the remind, %target% - target channel of the remind. **Bot owner only.** | `.remindtemplate %user%, you gotta do %message%!` +`.remindtemplate` | Sets message for when the remind is triggered. Available placeholders are %user% - user who ran the command, %message% - Message specified in the remind, %target% - target channel of the remind. **Bot owner only.** | `.remindtemplate %user%, do %message%!` `.convertlist` | List of the convertible dimensions and currencies. | `.convertlist` `.convert` | Convert quantities. Use `.convertlist` to see supported dimensions and currencies. | `.convert m km 1000` diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 38d398ed..4de3f465 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -184,6 +184,16 @@ $@"🌍 **Weather for** 【{obj["target"]}】 .ConfigureAwait(false); } + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task Shorten(IUserMessage msg, [Remainder] string arg) + { + if (string.IsNullOrWhiteSpace(arg)) + return; + + await msg.Channel.SendMessageAsync(await NadekoBot.Google.ShortenUrl(arg).ConfigureAwait(false)); + } + [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] public async Task Google(IUserMessage umsg, [Remainder] string terms = null) diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index ad45c5ee..a9835904 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -790,7 +790,7 @@ Sets message for when the remind is triggered. Available placeholders are %user% - user who ran the command, %message% - Message specified in the remind, %target% - target channel of the remind. - `{0}remindtemplate %user%, you gotta do %message%!` + `{0}remindtemplate %user%, do %message%!` serverinfo sinfo @@ -2491,7 +2491,7 @@ Sets the bots stream. First argument is the twitch link, second argument is stream name. - `{0}setstream https://www.twitch.tv/masterkwoth Developing Nakedo` + `{0}setstream TWITCHLINK Hello` chatunmute @@ -2628,4 +2628,13 @@ `{0}cleverbot` + + shorten + + + Attempts to shorten an URL, if it fails, returns the input URL. + + + `{0}shorten https://google.com` + \ No newline at end of file From 1039983fa7f4ebb7577e6ca75d68c863e801829e Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 9 Nov 2016 17:59:44 +0100 Subject: [PATCH 52/58] fixed mistake in merge --- src/NadekoBot/Modules/Searches/Searches.cs | 159 ++------------------- 1 file changed, 9 insertions(+), 150 deletions(-) diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index a8784889..fe7302fd 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -496,11 +496,10 @@ $@"🌍 **Weather for** 【{obj["target"]}】 [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - public async Task Wikia(IUserMessage umsg, string targ, [Remainder] string query = null) + public async Task Wikia(IUserMessage umsg, string target, [Remainder] string query = null) { var channel = (ITextChannel)umsg.Channel; - var arg = query; - if (string.IsNullOrWhiteSpace(targ) || string.IsNullOrWhiteSpace(arg)) + if (string.IsNullOrWhiteSpace(target) || string.IsNullOrWhiteSpace(query)) { await channel.SendMessageAsync("πŸ’’ Please enter `target query`.").ConfigureAwait(false); return; @@ -509,22 +508,19 @@ $@"🌍 **Weather for** 【{obj["target"]}】 using (var http = new HttpClient()) { http.DefaultRequestHeaders.Clear(); - string target = targ; - string search = arg; try { - var res = await http.GetStringAsync($"http://www.{Uri.EscapeUriString(target)}.wikia.com/api/v1/Search/List?query={Uri.EscapeUriString(search)}&limit=25&minArticleQuality=10&batch=1&namespaces=0%2C14").ConfigureAwait(false); + var res = await http.GetStringAsync($"http://www.{Uri.EscapeUriString(target)}.wikia.com/api/v1/Search/List?query={Uri.EscapeUriString(query)}&limit=25&minArticleQuality=10&batch=1&namespaces=0%2C14").ConfigureAwait(false); var items = JObject.Parse(res); - var sb = new StringBuilder(); - sb.AppendLine($"`Found:` {items["items"][0]["title"].ToString()}"); - sb.AppendLine($"`Total Found:` {items["total"].ToString()}"); - sb.AppendLine($"`Batch:` {items["currentBatch"].ToString()}/{items["batches"].ToString()}"); - sb.Append($"`URL:` <{await _google.ShortenUrl(items["items"][0]["url"].ToString()).ConfigureAwait(false)}> / `Quality`: {items["items"][0]["quality"].ToString()}"); - await channel.SendMessageAsync(sb.ToString()); + var response = $@"`Found:` {items["items"][0]["title"].ToString()} +`Total Found:` {items["total"].ToString()} +`Batch:` {items["currentBatch"].ToString()}/{items["batches"].ToString()} +`URL:` <{await _google.ShortenUrl(items["items"][0]["url"].ToString()).ConfigureAwait(false)}> / `Quality`: {items["items"][0]["quality"].ToString()}"; + await channel.SendMessageAsync(response); } catch { - await channel.SendMessageAsync($"πŸ’’ Failed finding `{arg}`.").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ’’ Failed finding `{query}`.").ConfigureAwait(false); } } } @@ -606,143 +602,6 @@ $@"🌍 **Weather for** 【{obj["target"]}】 } } - [NadekoCommand, Usage, Description, Aliases] - [RequireContext(ContextType.Guild)] - public async Task MCPing(IUserMessage umsg, [Remainder] string query = null) - { - var channel = (ITextChannel)umsg.Channel; - var arg = query; - if (string.IsNullOrWhiteSpace(arg)) - { - await channel.SendMessageAsync("πŸ’’ Please enter a ip:port.").ConfigureAwait(false); - return; - } - await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); - using (var http = new HttpClient()) - { - http.DefaultRequestHeaders.Clear(); - string ip = arg.Split(':')[0]; - string port = arg.Split(':')[1]; - var res = await http.GetStringAsync($"https://api.minetools.eu/ping/{Uri.EscapeUriString(ip)}/{Uri.EscapeUriString(port)}").ConfigureAwait(false); - try - { - var items = JObject.Parse(res); - var sb = new System.Text.StringBuilder(); - int ping = (int)Math.Ceiling(Double.Parse(items["latency"].ToString())); - sb.AppendLine($"`Server:` {arg}"); - sb.AppendLine($"`Version:` {items["version"]["name"].ToString()} / Protocol {items["version"]["protocol"].ToString()}"); - sb.AppendLine($"`Description:` {items["description"].ToString()}"); - sb.AppendLine($"`Online Players:` {items["players"]["online"].ToString()}/{items["players"]["max"].ToString()}"); - sb.Append($"`Latency:` {ping}"); - await channel.SendMessageAsync(sb.ToString()); - } - catch - { - await channel.SendMessageAsync($"πŸ’’ [MINECRAFT] Failed finding {arg}.").ConfigureAwait(false); - } - } - } - - [NadekoCommand, Usage, Description, Aliases] - [RequireContext(ContextType.Guild)] - public async Task MCQuery(IUserMessage umsg, [Remainder] string query = null) - { - var channel = (ITextChannel)umsg.Channel; - var arg = query; - if (string.IsNullOrWhiteSpace(arg)) - { - await channel.SendMessageAsync("πŸ’’ Please enter a ip:port.").ConfigureAwait(false); - return; - } - await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); - using (var http = new HttpClient()) - { - http.DefaultRequestHeaders.Clear(); - try - { - string ip = arg.Split(':')[0]; - string port = arg.Split(':')[1]; - var res = await http.GetStringAsync($"https://api.minetools.eu/query/{Uri.EscapeUriString(ip)}/{Uri.EscapeUriString(port)}").ConfigureAwait(false); - var items = JObject.Parse(res); - var sb = new System.Text.StringBuilder(); - sb.AppendLine($"`Server:` {arg.ToString()} γ€˜Status: {items["status"]}γ€™"); - sb.AppendLine($"`Player List:`"); - for (int i=0;i < items["Playerlist"].Count();i++) - { - if (i == 5) - { - break; - } else - { - sb.AppendLine($"γ€”{i+1}. {items["Playerlist"][i]}〕"); - } - } - sb.AppendLine($"`Online Players:` {items["Players"]} / {items["MaxPlayers"]}"); - sb.AppendLine($"`Plugins:` {items["Plugins"]}"); - sb.Append($"`Version:` {items["Version"]}"); - await channel.SendMessageAsync(sb.ToString()); - } - catch - { - await channel.SendMessageAsync($"πŸ’’ [MINECRAFT] Failed finding server: `{arg}`.").ConfigureAwait(false); - } - } - } - - [NadekoCommand, Usage, Description, Aliases] - [RequireContext(ContextType.Guild)] - public async Task MCUser(IUserMessage umsg, [Remainder] string query = null) - { - var channel = (ITextChannel)umsg.Channel; - var arg = query; - if (string.IsNullOrWhiteSpace(arg)) - { - await channel.SendMessageAsync("πŸ’’ Please enter a name or uuid.").ConfigureAwait(false); - return; - } - await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); - using (var http = new HttpClient()) - { - http.DefaultRequestHeaders.Clear(); - var res = await http.GetStringAsync($"https://api.minetools.eu/uuid/{Uri.EscapeUriString(arg)}").ConfigureAwait(false); - try - { - var items = JObject.Parse(res); - var sb = new System.Text.StringBuilder(); - if (items["uuid"].ToString() == "null") - { - sb.Append($"πŸ’’ [MINECRAFT] Failed finding a name/uuid going by {Uri.EscapeUriString(arg)}, bugger off!"); - } - else - { - using (var httpkek = new HttpClient()) - { - httpkek.DefaultRequestHeaders.Clear(); - var uuid = items["uuid"].ToString(); - var reskek = await http.GetStringAsync($"https://api.minetools.eu/profile/{Uri.EscapeUriString(uuid)}").ConfigureAwait(false); - try - { - var itemskek = JObject.Parse(reskek); - sb.AppendLine($"`Profile ID:` {itemskek["decoded"]["profileId"].ToString()}"); - sb.AppendLine($"`Profile Name:` {itemskek["decoded"]["profileName"].ToString()}"); - sb.AppendLine($"`Textures (CAPE):` {await _google.ShortenUrl(itemskek["decoded"]["textures"]["CAPE"]["url"].ToString()).ConfigureAwait(false)}"); - sb.AppendLine($"`Textures (SKIN):` {await _google.ShortenUrl(itemskek["decoded"]["textures"]["SKIN"]["url"].ToString()).ConfigureAwait(false)}"); - sb.Append($"`Timestamp:` {Convert.ToDateTime(itemskek["decoded"]["timestamp"].ToString())}"); - } - catch - { - } - } - } - await channel.SendMessageAsync(sb.ToString()); - } - catch - { - await channel.SendMessageAsync("πŸ’’ [MINECRAFT] Failed finding user.").ConfigureAwait(false); - } - } - } - public static async Task ValidateQuery(ITextChannel ch, string query) { if (!string.IsNullOrEmpty(query.Trim())) return true; From 72608fae28d260158538de99ea01bc7aeaa42117 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 9 Nov 2016 18:01:14 +0100 Subject: [PATCH 53/58] More mistakes --- .../Resources/CommandStrings.Designer.cs | 262 ++++++++---------- 1 file changed, 118 insertions(+), 144 deletions(-) diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index 6fe768c9..de807056 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -501,7 +501,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Automaticaly assigns a specified role to every user who joins the server. . + /// Looks up a localized string similar to Automaticaly assigns a specified role to every user who joins the server.. /// public static string autoassignrole_desc { get { @@ -852,7 +852,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Toggles automatic deletion of bye messages. . + /// Looks up a localized string similar to Toggles automatic deletion of bye messages.. /// public static string byedel_desc { get { @@ -879,7 +879,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Sets a new leave announcement message. Type %user% if you want to mention the new member. Using it with no message will show the current bye message. . + /// Looks up a localized string similar to Sets a new leave announcement message. Type %user% if you want to mention the new member. Using it with no message will show the current bye message.. /// public static string byemsg_desc { get { @@ -1500,7 +1500,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Cleans up hanging voice connections. . + /// Looks up a localized string similar to Cleans up hanging voice connections.. /// public static string cleanup_desc { get { @@ -1544,6 +1544,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to cleverbot. + /// + public static string cleverbot_cmd { + get { + return ResourceManager.GetString("cleverbot_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Toggles cleverbot session. When enabled, the bot will reply to messages starting with bot mention in the server. Custom reactions starting with %mention% won't work if cleverbot is enabled.. + /// + public static string cleverbot_desc { + get { + return ResourceManager.GetString("cleverbot_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}cleverbot`. + /// + public static string cleverbot_usage { + get { + return ResourceManager.GetString("cleverbot_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to cmdcooldown cmdcd. /// @@ -1716,7 +1743,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Creates a role with a given name. . + /// Looks up a localized string similar to Creates a role with a given name.. /// public static string createrole_desc { get { @@ -1770,7 +1797,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Creates a new voice channel with a given name. . + /// Looks up a localized string similar to Creates a new voice channel with a given name.. /// public static string creatvoichanl_desc { get { @@ -1797,7 +1824,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Creates a new text channel with a given name. . + /// Looks up a localized string similar to Creates a new text channel with a given name.. /// public static string creatxtchanl_desc { get { @@ -1851,7 +1878,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Deafens mentioned user or users. . + /// Looks up a localized string similar to Deafens mentioned user or users.. /// public static string deafen_desc { get { @@ -2040,7 +2067,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Deletes a text channel with a given name. . + /// Looks up a localized string similar to Deletes a text channel with a given name.. /// public static string deltxtchanl_desc { get { @@ -2067,7 +2094,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Deletes a voice channel with a given name. . + /// Looks up a localized string similar to Deletes a voice channel with a given name.. /// public static string delvoichanl_desc { get { @@ -2580,7 +2607,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Toggles anouncements on the current channel when someone joins the server. . + /// Looks up a localized string similar to Toggles anouncements on the current channel when someone joins the server.. /// public static string greet_desc { get { @@ -2607,7 +2634,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Toggles automatic deletion of greet messages. . + /// Looks up a localized string similar to Toggles automatic deletion of greet messages.. /// public static string greetdel_desc { get { @@ -2634,7 +2661,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Toggles whether the greet messages will be sent in a DM (This is separate from greet - you can have both, any or neither enabled). . + /// Looks up a localized string similar to Toggles whether the greet messages will be sent in a DM (This is separate from greet - you can have both, any or neither enabled).. /// public static string greetdm_desc { get { @@ -2661,7 +2688,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Sets a new join announcement message which will be sent to the user who joined. Type %user% if you want to mention the new member. Using it with no message will show the current DM greet message. . + /// Looks up a localized string similar to Sets a new join announcement message which will be sent to the user who joined. Type %user% if you want to mention the new member. Using it with no message will show the current DM greet message.. /// public static string greetdmmsg_desc { get { @@ -2688,7 +2715,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Sets a new join announcement message which will be shown in the server's channel. Type %user% if you want to mention the new member. Using it with no message will show the current greet message. . + /// Looks up a localized string similar to Sets a new join announcement message which will be shown in the server's channel. Type %user% if you want to mention the new member. Using it with no message will show the current greet message.. /// public static string greetmsg_desc { get { @@ -3120,7 +3147,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Joins current channel to an instance of cross server channel using the token. . + /// Looks up a localized string similar to Joins current channel to an instance of cross server channel using the token.. /// public static string jcsc_desc { get { @@ -3174,7 +3201,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Kicks a mentioned user. . + /// Looks up a localized string similar to Kicks a mentioned user.. /// public static string kick_desc { get { @@ -3228,7 +3255,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Leaves Cross server channel instance from this channel. . + /// Looks up a localized string similar to Leaves Cross server channel instance from this channel.. /// public static string lcsc_desc { get { @@ -3282,7 +3309,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Makes Nadeko leave the server. Either name or id required. . + /// Looks up a localized string similar to Makes Nadeko leave the server. Either name or id required.. /// public static string leave_desc { get { @@ -3920,24 +3947,6 @@ namespace NadekoBot.Resources { } } - /// - /// Looks up a localized string similar to memegen. - /// - public static string memegen_cmd { - get { - return ResourceManager.GetString("memegen_cmd", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Generates a meme from memelist with top and bottom text.. - /// - public static string memegen_desc { - get { - return ResourceManager.GetString("memegen_desc", resourceCulture); - } - } - /// /// Looks up a localized string similar to minecraftping mcping. /// @@ -3957,7 +3966,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `{0}mcping 127.0.0.1:1337`. + /// Looks up a localized string similar to `{0}mcping 127.0.0.1:25565`. /// public static string mcping_usage { get { @@ -3992,6 +4001,24 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to memegen. + /// + public static string memegen_cmd { + get { + return ResourceManager.GetString("memegen_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Generates a meme from memelist with top and bottom text.. + /// + public static string memegen_desc { + get { + return ResourceManager.GetString("memegen_desc", resourceCulture); + } + } + /// /// Looks up a localized string similar to `{0}memegen biw "gets iced coffee" "in the winter"`. /// @@ -4713,7 +4740,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `{0}prune` removes all nadeko's messages in the last 100 messages.`{0}prune X` removes last X messages from the channel (up to 100)`{0}prune @Someone` removes all Someone's messages in the last 100 messages.`{0}prune @Someone X` removes last X 'Someone's' messages in the channel. . + /// Looks up a localized string similar to `{0}prune` removes all nadeko's messages in the last 100 messages.`{0}prune X` removes last X messages from the channel (up to 100)`{0}prune @Someone` removes all Someone's messages in the last 100 messages.`{0}prune @Someone X` removes last X 'Someone's' messages in the channel.. /// public static string prune_desc { get { @@ -4983,7 +5010,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Sets message for when the remind is triggered. Available placeholders are %user% - user who ran the command, %message% - Message specified in the remind, %target% - target channel of the remind. . + /// Looks up a localized string similar to Sets message for when the remind is triggered. Available placeholders are %user% - user who ran the command, %message% - Message specified in the remind, %target% - target channel of the remind.. /// public static string remindtemplate_desc { get { @@ -4992,7 +5019,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `{0}remindtemplate %user%, you gotta do %message%!`. + /// Looks up a localized string similar to `{0}remindtemplate %user%, do %message%!`. /// public static string remindtemplate_usage { get { @@ -5037,7 +5064,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Removes all roles from a mentioned user. . + /// Looks up a localized string similar to Removes all roles from a mentioned user.. /// public static string removeallroles_desc { get { @@ -5091,7 +5118,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Removes a playing string on a given number. . + /// Looks up a localized string similar to Removes a playing string on a given number.. /// public static string removeplaying_desc { get { @@ -5118,7 +5145,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Removes a role from a given user. . + /// Looks up a localized string similar to Removes a role from a given user.. /// public static string removerole_desc { get { @@ -5226,7 +5253,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Immediately shows the repeat message and restarts the timer. . + /// Looks up a localized string similar to Immediately shows the repeat message and restarts the timer.. /// public static string repeatinvoke_desc { get { @@ -5442,7 +5469,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Set a role's color to the hex or 0-255 rgb color value provided. . + /// Looks up a localized string similar to Set a role's color to the hex or 0-255 rgb color value provided.. /// public static string rolecolor_desc { get { @@ -5901,7 +5928,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Sets a new avatar image for the NadekoBot. Argument is a direct link to an image. . + /// Looks up a localized string similar to Sets a new avatar image for the NadekoBot. Argument is a direct link to an image.. /// public static string setavatar_desc { get { @@ -5928,7 +5955,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Changes the name of the current channel. . + /// Looks up a localized string similar to Changes the name of the current channel.. /// public static string setchanlname_desc { get { @@ -5955,7 +5982,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Sets the bots game. . + /// Looks up a localized string similar to Sets the bots game.. /// public static string setgame_desc { get { @@ -6009,7 +6036,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Sets a name of the role which will be assigned to people who should be muted. Default is nadeko-mute. After specifying this role, restart commands which use mute as punishment.. + /// Looks up a localized string similar to Sets a name of the role which will be assigned to people who should be muted. Default is nadeko-mute.. /// public static string setmuterole_desc { get { @@ -6036,7 +6063,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Gives the bot a new name. . + /// Looks up a localized string similar to Gives the bot a new name.. /// public static string setname_desc { get { @@ -6063,7 +6090,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Sets a role for a given user. . + /// Looks up a localized string similar to Sets a role for a given user.. /// public static string setrole_desc { get { @@ -6099,7 +6126,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `{0}setstream https://www.twitch.tv/masterkwoth Developing Nakedo`. + /// Looks up a localized string similar to `{0}setstream TWITCHLINK Hello`. /// public static string setstream_usage { get { @@ -6117,7 +6144,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Sets a topic on the current channel. . + /// Looks up a localized string similar to Sets a topic on the current channel.. /// public static string settopic_desc { get { @@ -6134,6 +6161,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to shorten. + /// + public static string shorten_cmd { + get { + return ResourceManager.GetString("shorten_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Attempts to shorten an URL, if it fails, returns the input URL.. + /// + public static string shorten_desc { + get { + return ResourceManager.GetString("shorten_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}shorten https://google.com`. + /// + public static string shorten_usage { + get { + return ResourceManager.GetString("shorten_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to showcustreact scr. /// @@ -6306,7 +6360,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Bans and then unbans a user by ID or name with an optional message. . + /// Looks up a localized string similar to Bans and then unbans a user by ID or name with an optional message.. /// public static string softban_desc { get { @@ -6576,7 +6630,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Takes a certain amount of currency from someone. . + /// Looks up a localized string similar to Takes a certain amount of currency from someone.. /// public static string take_desc { get { @@ -6981,7 +7035,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Undeafens mentioned user or users. . + /// Looks up a localized string similar to Undeafens mentioned user or users.. /// public static string undeafen_desc { get { @@ -7035,7 +7089,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Clears the message queue. . + /// Looks up a localized string similar to Clears the message queue.. /// public static string unstuck_desc { get { @@ -7170,7 +7224,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Starts logging to this channel when someone from the server goes online/offline/idle. . + /// Looks up a localized string similar to Starts logging to this channel when someone from the server goes online/offline/idle.. /// public static string userpresence_desc { get { @@ -7332,7 +7386,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Creates a text channel for each voice channel only users in that voice channel can see.If you are server owner, keep in mind you will see them all the time regardless. . + /// Looks up a localized string similar to Creates a text channel for each voice channel only users in that voice channel can see.If you are server owner, keep in mind you will see them all the time regardless.. /// public static string voiceplustext_desc { get { @@ -7359,7 +7413,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Toggles logging to this channel whenever someone joins or leaves a voice channel you are currently in. . + /// Looks up a localized string similar to Toggles logging to this channel whenever someone joins or leaves a voice channel you are currently in.. /// public static string voicepresence_desc { get { @@ -7386,7 +7440,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Gives a previously voice-muted user a permission to speak. . + /// Looks up a localized string similar to Gives a previously voice-muted user a permission to speak.. /// public static string voiceunmute_desc { get { @@ -7510,7 +7564,7 @@ namespace NadekoBot.Resources { return ResourceManager.GetString("wiki_usage", resourceCulture); } } - + /// /// Looks up a localized string similar to wikia. /// @@ -7645,85 +7699,5 @@ namespace NadekoBot.Resources { return ResourceManager.GetString("youtube_usage", resourceCulture); } } - /// - /// Looks up a localized string similar to minecraftping mcping. - /// - public static string mcping_cmd { - get { - return ResourceManager.GetString("mcping_cmd", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Pings a minecraft server.. - /// - public static string mcping_desc { - get { - return ResourceManager.GetString("mcping_desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `{0}mcping 127.0.0.1:1337`. - /// - public static string mcping_usage { - get { - return ResourceManager.GetString("mcping_usage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to minecraftquery mcquery. - /// - public static string mcquery_cmd { - get { - return ResourceManager.GetString("mcquery_cmd", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Finds information about a minecraft server.. - /// - public static string mcquery_desc { - get { - return ResourceManager.GetString("mcquery_desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `{0}mcquery server:ip`. - /// - public static string mcquery_usage { - get { - return ResourceManager.GetString("mcquery_usage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to minecraftuser mcuser. - /// - public static string mcuser_cmd { - get { - return ResourceManager.GetString("mcuser_cmd", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Finds information about a minecraft user.. - /// - public static string mcuser_desc { - get { - return ResourceManager.GetString("mcuser_desc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `{0}mcuser username or uuid`. - /// - public static string mcuser_usage { - get { - return ResourceManager.GetString("mcuser_usage", resourceCulture); - } - } } -} \ No newline at end of file +} From cc08f71bc61a89d69ced1298568421b93da86142 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 9 Nov 2016 19:28:26 +0100 Subject: [PATCH 54/58] Improvements --- src/NadekoBot/Modules/Searches/Searches.cs | 16 ++++++++-------- .../Resources/CommandStrings.Designer.cs | 2 +- src/NadekoBot/Resources/CommandStrings.resx | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index fe7302fd..4a120f3b 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -493,7 +493,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 return matches[rng.Next(0, matches.Count)].Groups["url"].Value; } } - + [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] public async Task Wikia(IUserMessage umsg, string target, [Remainder] string query = null) @@ -501,21 +501,21 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var channel = (ITextChannel)umsg.Channel; if (string.IsNullOrWhiteSpace(target) || string.IsNullOrWhiteSpace(query)) { - await channel.SendMessageAsync("πŸ’’ Please enter `target query`.").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’ Please enter a target wikia, followed by search query.").ConfigureAwait(false); return; } await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); using (var http = new HttpClient()) { http.DefaultRequestHeaders.Clear(); - try + try { - var res = await http.GetStringAsync($"http://www.{Uri.EscapeUriString(target)}.wikia.com/api/v1/Search/List?query={Uri.EscapeUriString(query)}&limit=25&minArticleQuality=10&batch=1&namespaces=0%2C14").ConfigureAwait(false); + var res = await http.GetStringAsync($"http://www.{Uri.EscapeUriString(target)}.wikia.com/api/v1/Search/List?query={Uri.EscapeUriString(query)}&limit=25&minArticleQuality=10&batch=1&namespaces=0%2C14").ConfigureAwait(false); var items = JObject.Parse(res); - var response = $@"`Found:` {items["items"][0]["title"].ToString()} -`Total Found:` {items["total"].ToString()} -`Batch:` {items["currentBatch"].ToString()}/{items["batches"].ToString()} -`URL:` <{await _google.ShortenUrl(items["items"][0]["url"].ToString()).ConfigureAwait(false)}> / `Quality`: {items["items"][0]["quality"].ToString()}"; + var found = items["items"][0]; + var response = $@"`Title:` {found["title"].ToString()} +`Quality:` {found["quality"]} +`URL:` {await NadekoBot.Google.ShortenUrl(found["url"].ToString()).ConfigureAwait(false)}"; await channel.SendMessageAsync(response); } catch diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index de807056..c53865ad 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -7584,7 +7584,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `{0}wikia target query`. + /// Looks up a localized string similar to `{0}wikia mtg Vigilance` or `{0}wikia mlp Dashy`. /// public static string wikia_usage { get { diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index b62ab014..1545142b 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2662,6 +2662,6 @@ Gives you back a wikia link - `{0}wikia target query` + `{0}wikia mtg Vigilance` or `{0}wikia mlp Dashy` \ No newline at end of file From c88d516345daa73c793e80fac77cc2d097ea861d Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 10 Nov 2016 02:02:22 +0100 Subject: [PATCH 55/58] updated version number to rc2 :D --- src/NadekoBot/Services/Impl/StatsService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Services/Impl/StatsService.cs b/src/NadekoBot/Services/Impl/StatsService.cs index ea80f41d..f24bbc96 100644 --- a/src/NadekoBot/Services/Impl/StatsService.cs +++ b/src/NadekoBot/Services/Impl/StatsService.cs @@ -19,7 +19,7 @@ namespace NadekoBot.Services.Impl private DateTime started; private int commandsRan = 0; - public const string BotVersion = "1.0-rc1"; + public const string BotVersion = "1.0-rc2"; public string Heap => Math.Round((double)GC.GetTotalMemory(false) / 1.MiB(), 2).ToString(); From df8b67e3c8bd69f13bb553d8be2bf2d861d35cb8 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 10 Nov 2016 21:12:43 +0100 Subject: [PATCH 56/58] Fixed a bugged answer in trivia --- src/NadekoBot/data/questions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/data/questions.json b/src/NadekoBot/data/questions.json index a41bd6a9..b74a23a1 100644 --- a/src/NadekoBot/data/questions.json +++ b/src/NadekoBot/data/questions.json @@ -11533,7 +11533,7 @@ }, { "Question": "What is the capital of the Canadian province of British Columbia", - "Answer": "victor1a" + "Answer": "victoria" }, { "Question": "What is the capital of the US state of Delaware", From 98576311c162c8a469a76713af64d6b7052761c3 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 10 Nov 2016 22:31:15 +0100 Subject: [PATCH 57/58] Fixed migration of currency from 0.9 to 1.0 --- src/NadekoBot/Modules/Administration/Commands/Migration.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/Migration.cs b/src/NadekoBot/Modules/Administration/Commands/Migration.cs index feb3aab0..fb2f9c00 100644 --- a/src/NadekoBot/Modules/Administration/Commands/Migration.cs +++ b/src/NadekoBot/Modules/Administration/Commands/Migration.cs @@ -128,18 +128,19 @@ namespace NadekoBot.Modules.Administration } var com2 = db.CreateCommand(); - com.CommandText = "SELECT * FROM CurrencyState"; + com.CommandText = "SELECT * FROM CurrencyState GROUP BY UserId"; i = 0; var reader2 = com.ExecuteReader(); while (reader2.Read()) { _log.Info(++i); - uow.Currency.Add(new Currency() + var curr = new Currency() { Amount = (long)reader2["Value"], UserId = (ulong)(long)reader2["UserId"] - }); + }; + uow.Currency.Add(curr); } db.Close(); try { File.Move("data/nadekobot.sqlite", "data/DELETE_ME_nadekobot.sqlite"); } catch { } From afe459feb67374e10071b091138c3bf69ac63560 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 10 Nov 2016 23:46:41 +0100 Subject: [PATCH 58/58] More fixes to migration --- src/NadekoBot/Modules/Administration/Commands/Migration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/Migration.cs b/src/NadekoBot/Modules/Administration/Commands/Migration.cs index fb2f9c00..78814624 100644 --- a/src/NadekoBot/Modules/Administration/Commands/Migration.cs +++ b/src/NadekoBot/Modules/Administration/Commands/Migration.cs @@ -75,9 +75,9 @@ namespace NadekoBot.Modules.Administration MigrateDb0_9(uow); //NOW save it - botConfig.MigrationVersion = 1; _log.Warn("Writing to disc"); uow.Complete(); + botConfig.MigrationVersion = 1; } }