From b93d20e07eeee2e157d1a0171b6388eebac4f8f7 Mon Sep 17 00:00:00 2001 From: Nikolay Kochulin Date: Wed, 6 Feb 2019 23:29:12 +0300 Subject: [PATCH 1/3] Start creating help command --- JetKarmaBot/Commands/HelpCommand.cs | 29 ++++++++++++++++++++++++++++ JetKarmaBot/Commands/StartCommand.cs | 25 ------------------------ JetKarmaBot/JetKarmaBot.cs | 2 +- JetKarmaBot/lang/be-BY.json | 3 ++- JetKarmaBot/lang/en-US.json | 3 ++- JetKarmaBot/lang/ru-RU.json | 3 ++- 6 files changed, 36 insertions(+), 29 deletions(-) create mode 100644 JetKarmaBot/Commands/HelpCommand.cs delete mode 100644 JetKarmaBot/Commands/StartCommand.cs diff --git a/JetKarmaBot/Commands/HelpCommand.cs b/JetKarmaBot/Commands/HelpCommand.cs new file mode 100644 index 0000000..02eda2c --- /dev/null +++ b/JetKarmaBot/Commands/HelpCommand.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using Telegram.Bot.Args; +using Perfusion; +using JetKarmaBot.Services; +using Telegram.Bot; + +namespace JetKarmaBot.Commands +{ + public class HelpCommand : IChatCommand + { + [Inject] KarmaContextFactory Db; + [Inject] TelegramBotClient Client { get; set; } + [Inject] Localization Locale { get; set; } + public IReadOnlyCollection Names => new[] { "help" }; + + public bool Execute(CommandString cmd, MessageEventArgs args) + { + using (var db = Db.GetContext()) + { + var currentLocale = Locale[db.Chats.Find(args.Message.Chat.Id).Locale]; + Client.SendTextMessageAsync( + args.Message.Chat.Id, + currentLocale["jetkarmabot.help"], + replyToMessageId: args.Message.MessageId); + return true; + } + } + } +} diff --git a/JetKarmaBot/Commands/StartCommand.cs b/JetKarmaBot/Commands/StartCommand.cs deleted file mode 100644 index fd52cbe..0000000 --- a/JetKarmaBot/Commands/StartCommand.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Collections.Generic; -using Telegram.Bot.Args; -using Perfusion; -using JetKarmaBot.Services; - -namespace JetKarmaBot.Commands -{ - public class StartCommand : IChatCommand - { - [Inject] KarmaContextFactory Db; - - public IReadOnlyCollection Names => new[] { "start" }; - - public bool Execute(CommandString cmd, MessageEventArgs args) - { - using (var db = Db.GetContext()) - { - db.Chats.Add(new Models.Chat { ChatId = args.Message.Chat.Id }); - db.Users.Add(new Models.User { UserId = args.Message.From.Id }); - db.SaveChanges(); - return true; - } - } - } -} diff --git a/JetKarmaBot/JetKarmaBot.cs b/JetKarmaBot/JetKarmaBot.cs index 642bb4f..124f7fe 100644 --- a/JetKarmaBot/JetKarmaBot.cs +++ b/JetKarmaBot/JetKarmaBot.cs @@ -73,7 +73,7 @@ namespace JetKarmaBot void InitCommands(Container c) { Commands = c.ResolveObject(new ChatCommandRouter(Me)); - Commands.Add(c.ResolveObject(new StartCommand())); + Commands.Add(c.ResolveObject(new HelpCommand())); Commands.Add(c.ResolveObject(new AwardCommand(Me))); Commands.Add(c.ResolveObject(new StatusCommand())); Commands.Add(c.ResolveObject(new LocaleCommand())); diff --git a/JetKarmaBot/lang/be-BY.json b/JetKarmaBot/lang/be-BY.json index d1a72dd..c3db7d2 100644 --- a/JetKarmaBot/lang/be-BY.json +++ b/JetKarmaBot/lang/be-BY.json @@ -20,6 +20,7 @@ "jetkarmabot.changelocale.getlocale": "Я зараз кажу па-беларускай.", "jetkarmabot.changelocale.listalltext": "Я ведаю:", "jetkarmabot.changelocale.errorall": "Мне б хацелася гаварыць на ўсіх мовах у той жа самы час, але з-за абмежаванняў сусвету, мне гэта не дазваляецца.", - "jetkarmabot.changelocale.beforenote": "Увага: " + "jetkarmabot.changelocale.beforenote": "Увага: ", + "jetkarmabot.help": "TODO TODO TODO TODO" } } \ No newline at end of file diff --git a/JetKarmaBot/lang/en-US.json b/JetKarmaBot/lang/en-US.json index a6450af..b550268 100644 --- a/JetKarmaBot/lang/en-US.json +++ b/JetKarmaBot/lang/en-US.json @@ -19,6 +19,7 @@ "jetkarmabot.changelocale.getlocale": "I'm currently speaking English.", "jetkarmabot.changelocale.listalltext": "I know:", "jetkarmabot.changelocale.errorall": "I would like to speak all languages at once, but because of the rules of the universe, I am not allowed to do that.", - "jetkarmabot.changelocale.beforenote": "Warning: " + "jetkarmabot.changelocale.beforenote": "Warning: ", + "jetkarmabot.help": "TODO TODO TODO TODO" } } \ No newline at end of file diff --git a/JetKarmaBot/lang/ru-RU.json b/JetKarmaBot/lang/ru-RU.json index 112b596..7c744c5 100644 --- a/JetKarmaBot/lang/ru-RU.json +++ b/JetKarmaBot/lang/ru-RU.json @@ -19,6 +19,7 @@ "jetkarmabot.changelocale.getlocale": "Я сейчас говорю по-русски.", "jetkarmabot.changelocale.listalltext": "Я знаю:", "jetkarmabot.changelocale.errorall": "Мне бы хотелось говорить на всех языках в то же самое время, но из-за ограничений вселенной, мне это не позволяется.", - "jetkarmabot.changelocale.beforenote": "Внимание: " + "jetkarmabot.changelocale.beforenote": "Внимание: ", + "jetkarmabot.help": "TODO TODO TODO TODO" } } \ No newline at end of file From 83d1b458af725e47d220030bd5cdc24ddb369089 Mon Sep 17 00:00:00 2001 From: Nikolay Kochulin Date: Thu, 7 Feb 2019 16:44:32 +0300 Subject: [PATCH 2/3] Add help command mechanisms --- JetKarmaBot/CommandRouter.cs | 34 +++++++++++++++++- JetKarmaBot/Commands/AwardCommand.cs | 11 ++++++ JetKarmaBot/Commands/ChangeLocaleCommand.cs | 11 ++++++ JetKarmaBot/Commands/HelpCommand.cs | 40 ++++++++++++++++++--- JetKarmaBot/Commands/IChatCommand.cs | 17 +++++++++ JetKarmaBot/Commands/StatusCommand.cs | 10 ++++++ JetKarmaBot/JetKarmaBot.cs | 2 +- 7 files changed, 118 insertions(+), 7 deletions(-) diff --git a/JetKarmaBot/CommandRouter.cs b/JetKarmaBot/CommandRouter.cs index 53edf69..69e5499 100644 --- a/JetKarmaBot/CommandRouter.cs +++ b/JetKarmaBot/CommandRouter.cs @@ -9,7 +9,7 @@ using Telegram.Bot.Types; namespace JetKarmaBot { - class ChatCommandRouter + public class ChatCommandRouter { User BotUser { get; } [Inject] @@ -52,6 +52,7 @@ namespace JetKarmaBot return false; } + public void Add(IChatCommand c) { log.ConditionalTrace($"Adding command {c.GetType().Name}"); @@ -64,6 +65,37 @@ namespace JetKarmaBot } } + public string GetHelpText() + { + List pieces = new List(); + foreach (IChatCommand c in commands.Values.Distinct()) + { + string build = ""; + List names = c.Names.ToList(); + for (int i = 0; i < names.Count - 1; i++) + { + build = build + "/" + names[i] + "\n"; + } + build += "/" + names[names.Count - 1] + " " + string.Join(' ', c.Arguments.Select(x => (!x.Required ? "[" : "") + x.Name + (!x.Required ? "]" : ""))) + " " + c.Description + ""; + pieces.Add(build); + } + return string.Join('\n', pieces); + } + + internal string GetHelpTextFor(string commandname) + { + IChatCommand c = commands[commandname]; + string build = ""; + List names = c.Names.ToList(); + for (int i = 0; i < names.Count - 1; i++) + { + build = build + "/" + names[i] + "\n"; + } + build += "/" + names[names.Count - 1] + " " + string.Join(' ', c.Arguments.Select(x => (!x.Required ? "[" : "") + x.Name + (!x.Required ? "]" : ""))) + " " + c.Description + "\n"; + build += string.Join("\n", c.Arguments.Select(ca => (!ca.Required ? "[" : "") + ca.Name + (!ca.Required ? "]" : "") + ": " + ca.Description + "")); + return build; + } + Dictionary commands = new Dictionary(); } } diff --git a/JetKarmaBot/Commands/AwardCommand.cs b/JetKarmaBot/Commands/AwardCommand.cs index 6d07a51..00bf025 100644 --- a/JetKarmaBot/Commands/AwardCommand.cs +++ b/JetKarmaBot/Commands/AwardCommand.cs @@ -92,6 +92,17 @@ namespace JetKarmaBot.Commands [Inject] Localization Locale { get; set; } User Me { get; } + public string Description => "Awards/revokes an award to a user."; + + public IReadOnlyCollection Arguments => new ChatCommandArgument[] { + new ChatCommandArgument() { + Name="awardtype", + Required=false, + Type=ChatCommandArgumentType.String, + Description="The award to grant to/strip of the specified user" + } + }; + public AwardCommand(User me) { Me = me; diff --git a/JetKarmaBot/Commands/ChangeLocaleCommand.cs b/JetKarmaBot/Commands/ChangeLocaleCommand.cs index a60455e..99f9433 100644 --- a/JetKarmaBot/Commands/ChangeLocaleCommand.cs +++ b/JetKarmaBot/Commands/ChangeLocaleCommand.cs @@ -67,5 +67,16 @@ namespace JetKarmaBot.Commands [Inject] KarmaContextFactory Db { get; set; } [Inject] TelegramBotClient Client { get; set; } [Inject] Localization Locale { get; set; } + + public string Description => "Switches current chat locale to [locale]"; + + public IReadOnlyCollection Arguments => new ChatCommandArgument[] { + new ChatCommandArgument() { + Name="locale", + Required=false, + Type=ChatCommandArgumentType.String, + Description="The locale to switch to. Can be \"list\" to list all possible locales. Also can be empty to get current locale" + } + }; } } diff --git a/JetKarmaBot/Commands/HelpCommand.cs b/JetKarmaBot/Commands/HelpCommand.cs index 02eda2c..4f2bd8d 100644 --- a/JetKarmaBot/Commands/HelpCommand.cs +++ b/JetKarmaBot/Commands/HelpCommand.cs @@ -3,6 +3,7 @@ using Telegram.Bot.Args; using Perfusion; using JetKarmaBot.Services; using Telegram.Bot; +using Telegram.Bot.Types.Enums; namespace JetKarmaBot.Commands { @@ -11,19 +12,48 @@ namespace JetKarmaBot.Commands [Inject] KarmaContextFactory Db; [Inject] TelegramBotClient Client { get; set; } [Inject] Localization Locale { get; set; } + ChatCommandRouter Router; public IReadOnlyCollection Names => new[] { "help" }; + public string Description => "Displays help text for all(one) command(s)"; + + public IReadOnlyCollection Arguments => new ChatCommandArgument[] { + new ChatCommandArgument() { + Name="command", + Required=false, + Type=ChatCommandArgumentType.String, + Description="The command to return help text for. If empty shows all commands" + } + }; + public bool Execute(CommandString cmd, MessageEventArgs args) { using (var db = Db.GetContext()) { var currentLocale = Locale[db.Chats.Find(args.Message.Chat.Id).Locale]; - Client.SendTextMessageAsync( - args.Message.Chat.Id, - currentLocale["jetkarmabot.help"], - replyToMessageId: args.Message.MessageId); - return true; + if (cmd.Parameters.Length < 1) + { + Client.SendTextMessageAsync( + args.Message.Chat.Id, + Router.GetHelpText(), + replyToMessageId: args.Message.MessageId, + parseMode: ParseMode.Html); + return true; + } + else + { + Client.SendTextMessageAsync( + args.Message.Chat.Id, + Router.GetHelpTextFor(cmd.Parameters[0]), + replyToMessageId: args.Message.MessageId, + parseMode: ParseMode.Html); + return true; + } } } + public HelpCommand(ChatCommandRouter router) + { + Router = router; + } } } diff --git a/JetKarmaBot/Commands/IChatCommand.cs b/JetKarmaBot/Commands/IChatCommand.cs index ebfacc0..69fd0b3 100644 --- a/JetKarmaBot/Commands/IChatCommand.cs +++ b/JetKarmaBot/Commands/IChatCommand.cs @@ -6,7 +6,24 @@ namespace JetKarmaBot.Commands public interface IChatCommand { IReadOnlyCollection Names { get; } + string Description { get; } + IReadOnlyCollection Arguments { get; } + bool Execute(CommandString cmd, MessageEventArgs messageEventArgs); } + public struct ChatCommandArgument + { + public string Name; + public bool Required; + public ChatCommandArgumentType Type; + public string Description; + } + + public enum ChatCommandArgumentType + { + Boolean, + String, + Integer, + } } diff --git a/JetKarmaBot/Commands/StatusCommand.cs b/JetKarmaBot/Commands/StatusCommand.cs index c095595..6039fa8 100644 --- a/JetKarmaBot/Commands/StatusCommand.cs +++ b/JetKarmaBot/Commands/StatusCommand.cs @@ -67,5 +67,15 @@ namespace JetKarmaBot.Commands [Inject] TelegramBotClient Client { get; set; } [Inject] Localization Locale { get; set; } + public string Description => "Shows the amount of awards that you have"; + + public IReadOnlyCollection Arguments => new ChatCommandArgument[] { + new ChatCommandArgument(){ + Name="awardtype", + Required=false, + Type=ChatCommandArgumentType.String, + Description="The awardtype to show. If empty shows everything." + } + }; } } diff --git a/JetKarmaBot/JetKarmaBot.cs b/JetKarmaBot/JetKarmaBot.cs index 124f7fe..044b0a9 100644 --- a/JetKarmaBot/JetKarmaBot.cs +++ b/JetKarmaBot/JetKarmaBot.cs @@ -73,7 +73,7 @@ namespace JetKarmaBot void InitCommands(Container c) { Commands = c.ResolveObject(new ChatCommandRouter(Me)); - Commands.Add(c.ResolveObject(new HelpCommand())); + Commands.Add(c.ResolveObject(new HelpCommand(Commands))); Commands.Add(c.ResolveObject(new AwardCommand(Me))); Commands.Add(c.ResolveObject(new StatusCommand())); Commands.Add(c.ResolveObject(new LocaleCommand())); From d986a59844489589406e214935863b90e2cf1427 Mon Sep 17 00:00:00 2001 From: Nikolay Kochulin Date: Thu, 7 Feb 2019 17:45:49 +0300 Subject: [PATCH 3/3] Add functionality to localize command help strings. --- JetKarmaBot/CommandRouter.cs | 21 +++++++++++---- JetKarmaBot/Commands/AwardCommand.cs | 4 ++- JetKarmaBot/Commands/ChangeLocaleCommand.cs | 4 ++- JetKarmaBot/Commands/HelpCommand.cs | 8 +++--- JetKarmaBot/Commands/IChatCommand.cs | 2 ++ JetKarmaBot/Commands/StatusCommand.cs | 4 ++- JetKarmaBot/Services/Localization.cs | 29 ++++++++++++++++++++- JetKarmaBot/lang/be-BY.json | 9 ++++++- JetKarmaBot/lang/en-US.json | 9 ++++++- JetKarmaBot/lang/ru-RU.json | 9 ++++++- 10 files changed, 84 insertions(+), 15 deletions(-) diff --git a/JetKarmaBot/CommandRouter.cs b/JetKarmaBot/CommandRouter.cs index 69e5499..f65d5ee 100644 --- a/JetKarmaBot/CommandRouter.cs +++ b/JetKarmaBot/CommandRouter.cs @@ -65,7 +65,7 @@ namespace JetKarmaBot } } - public string GetHelpText() + internal string GetHelpText(Locale loc) { List pieces = new List(); foreach (IChatCommand c in commands.Values.Distinct()) @@ -76,13 +76,13 @@ namespace JetKarmaBot { build = build + "/" + names[i] + "\n"; } - build += "/" + names[names.Count - 1] + " " + string.Join(' ', c.Arguments.Select(x => (!x.Required ? "[" : "") + x.Name + (!x.Required ? "]" : ""))) + " " + c.Description + ""; + build += "/" + names[names.Count - 1] + " " + string.Join(' ', c.Arguments.Select(x => (!x.Required ? "[" : "") + x.Name + (!x.Required ? "]" : ""))) + " " + getLocalizedCMDDesc(c, loc) + ""; pieces.Add(build); } return string.Join('\n', pieces); } - internal string GetHelpTextFor(string commandname) + internal string GetHelpTextFor(string commandname, Locale loc) { IChatCommand c = commands[commandname]; string build = ""; @@ -91,11 +91,22 @@ namespace JetKarmaBot { build = build + "/" + names[i] + "\n"; } - build += "/" + names[names.Count - 1] + " " + string.Join(' ', c.Arguments.Select(x => (!x.Required ? "[" : "") + x.Name + (!x.Required ? "]" : ""))) + " " + c.Description + "\n"; - build += string.Join("\n", c.Arguments.Select(ca => (!ca.Required ? "[" : "") + ca.Name + (!ca.Required ? "]" : "") + ": " + ca.Description + "")); + build += "/" + names[names.Count - 1] + " " + string.Join(' ', c.Arguments.Select(x => (!x.Required ? "[" : "") + x.Name + (!x.Required ? "]" : ""))) + " " + getLocalizedCMDDesc(c, loc) + "\n"; + build += string.Join("\n", c.Arguments.Select(ca => (!ca.Required ? "[" : "") + ca.Name + (!ca.Required ? "]" : "") + ": " + getLocalizedCMDArgDesc(ca, loc) + "")); return build; } + private string getLocalizedCMDDesc(IChatCommand cmd, Locale loc) + { + if (loc.ContainsKey(cmd.DescriptionID)) return loc[cmd.DescriptionID]; + else return cmd.Description; + } + private string getLocalizedCMDArgDesc(ChatCommandArgument arg, Locale loc) + { + if (loc.ContainsKey(arg.DescriptionID)) return loc[arg.DescriptionID]; + else return arg.Description; + } + Dictionary commands = new Dictionary(); } } diff --git a/JetKarmaBot/Commands/AwardCommand.cs b/JetKarmaBot/Commands/AwardCommand.cs index 00bf025..6fe0467 100644 --- a/JetKarmaBot/Commands/AwardCommand.cs +++ b/JetKarmaBot/Commands/AwardCommand.cs @@ -93,13 +93,15 @@ namespace JetKarmaBot.Commands User Me { get; } public string Description => "Awards/revokes an award to a user."; + public string DescriptionID => "jetkarmabot.award.help"; public IReadOnlyCollection Arguments => new ChatCommandArgument[] { new ChatCommandArgument() { Name="awardtype", Required=false, Type=ChatCommandArgumentType.String, - Description="The award to grant to/strip of the specified user" + Description="The award to grant to/strip of the specified user", + DescriptionID="jetkarmabot.award.awardtypehelp" } }; diff --git a/JetKarmaBot/Commands/ChangeLocaleCommand.cs b/JetKarmaBot/Commands/ChangeLocaleCommand.cs index 99f9433..7d8c82c 100644 --- a/JetKarmaBot/Commands/ChangeLocaleCommand.cs +++ b/JetKarmaBot/Commands/ChangeLocaleCommand.cs @@ -69,13 +69,15 @@ namespace JetKarmaBot.Commands [Inject] Localization Locale { get; set; } public string Description => "Switches current chat locale to [locale]"; + public string DescriptionID => "jetkarmabot.changelocale.help"; public IReadOnlyCollection Arguments => new ChatCommandArgument[] { new ChatCommandArgument() { Name="locale", Required=false, Type=ChatCommandArgumentType.String, - Description="The locale to switch to. Can be \"list\" to list all possible locales. Also can be empty to get current locale" + Description="The locale to switch to. Can be \"list\" to list all possible locales. Also can be empty to get current locale.", + DescriptionID="jetkarmabot.changelocale.localehelp" } }; } diff --git a/JetKarmaBot/Commands/HelpCommand.cs b/JetKarmaBot/Commands/HelpCommand.cs index 4f2bd8d..1e455f7 100644 --- a/JetKarmaBot/Commands/HelpCommand.cs +++ b/JetKarmaBot/Commands/HelpCommand.cs @@ -16,13 +16,15 @@ namespace JetKarmaBot.Commands public IReadOnlyCollection Names => new[] { "help" }; public string Description => "Displays help text for all(one) command(s)"; + public string DescriptionID => "jetkarmabot.help.help"; public IReadOnlyCollection Arguments => new ChatCommandArgument[] { new ChatCommandArgument() { Name="command", Required=false, Type=ChatCommandArgumentType.String, - Description="The command to return help text for. If empty shows all commands" + Description="The command to return help text for. If empty shows all commands.", + DescriptionID="jetkarmabot.help.commandhelp" } }; @@ -35,7 +37,7 @@ namespace JetKarmaBot.Commands { Client.SendTextMessageAsync( args.Message.Chat.Id, - Router.GetHelpText(), + Router.GetHelpText(currentLocale), replyToMessageId: args.Message.MessageId, parseMode: ParseMode.Html); return true; @@ -44,7 +46,7 @@ namespace JetKarmaBot.Commands { Client.SendTextMessageAsync( args.Message.Chat.Id, - Router.GetHelpTextFor(cmd.Parameters[0]), + Router.GetHelpTextFor(cmd.Parameters[0], currentLocale), replyToMessageId: args.Message.MessageId, parseMode: ParseMode.Html); return true; diff --git a/JetKarmaBot/Commands/IChatCommand.cs b/JetKarmaBot/Commands/IChatCommand.cs index 69fd0b3..436f789 100644 --- a/JetKarmaBot/Commands/IChatCommand.cs +++ b/JetKarmaBot/Commands/IChatCommand.cs @@ -7,6 +7,7 @@ namespace JetKarmaBot.Commands { IReadOnlyCollection Names { get; } string Description { get; } + string DescriptionID { get; } IReadOnlyCollection Arguments { get; } bool Execute(CommandString cmd, MessageEventArgs messageEventArgs); @@ -18,6 +19,7 @@ namespace JetKarmaBot.Commands public bool Required; public ChatCommandArgumentType Type; public string Description; + public string DescriptionID; } public enum ChatCommandArgumentType diff --git a/JetKarmaBot/Commands/StatusCommand.cs b/JetKarmaBot/Commands/StatusCommand.cs index 6039fa8..db45e3b 100644 --- a/JetKarmaBot/Commands/StatusCommand.cs +++ b/JetKarmaBot/Commands/StatusCommand.cs @@ -68,13 +68,15 @@ namespace JetKarmaBot.Commands [Inject] Localization Locale { get; set; } public string Description => "Shows the amount of awards that you have"; + public string DescriptionID => "jetkarmabot.status.help"; public IReadOnlyCollection Arguments => new ChatCommandArgument[] { new ChatCommandArgument(){ Name="awardtype", Required=false, Type=ChatCommandArgumentType.String, - Description="The awardtype to show. If empty shows everything." + Description="The awardtype to show. If empty shows everything.", + DescriptionID= "jetkarmabot.status.awardtypehelp" } }; } diff --git a/JetKarmaBot/Services/Localization.cs b/JetKarmaBot/Services/Localization.cs index aedba8e..bb4f250 100644 --- a/JetKarmaBot/Services/Localization.cs +++ b/JetKarmaBot/Services/Localization.cs @@ -100,7 +100,7 @@ namespace JetKarmaBot } - public class Locale + public class Locale : IReadOnlyDictionary { private Dictionary locale; private string localeName; @@ -119,6 +119,33 @@ namespace JetKarmaBot public bool HasNote => note != null; public string Note => note; + + public IEnumerable Keys => ((IReadOnlyDictionary)locale).Keys; + + public IEnumerable Values => ((IReadOnlyDictionary)locale).Values; + + public int Count => ((IReadOnlyDictionary)locale).Count; + public string this[string name] => locale.ContainsKey(name) ? locale[name] : "unknown"; + + public bool ContainsKey(string key) + { + return ((IReadOnlyDictionary)locale).ContainsKey(key); + } + + public bool TryGetValue(string key, out string value) + { + return ((IReadOnlyDictionary)locale).TryGetValue(key, out value); + } + + public IEnumerator> GetEnumerator() + { + return ((IReadOnlyDictionary)locale).GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IReadOnlyDictionary)locale).GetEnumerator(); + } } } \ No newline at end of file diff --git a/JetKarmaBot/lang/be-BY.json b/JetKarmaBot/lang/be-BY.json index c3db7d2..e977481 100644 --- a/JetKarmaBot/lang/be-BY.json +++ b/JetKarmaBot/lang/be-BY.json @@ -13,14 +13,21 @@ "jetkarmabot.award.awardmessage": "Ўручыў \"{0}\" {1}!", "jetkarmabot.award.revokemessage": "Адабраў \"{0}\" у {1}!", "jetkarmabot.award.statustext": "У {0} цяпер {1}{2}.", + "jetkarmabot.award.help": "", + "jetkarmabot.award.awardtypehelp": "", "jetkarmabot.status.listalltext": "У вас :", "jetkarmabot.status.listspecifictext": "У вас зараз {0}{1}.", "jetkarmabot.status.havenothing": "У вас пакуль нічога няма.", + "jetkarmabot.status.help": "", + "jetkarmabot.status.awardtypehelp": "", "jetkarmabot.changelocale.justchanged": "Так дакладна.", "jetkarmabot.changelocale.getlocale": "Я зараз кажу па-беларускай.", "jetkarmabot.changelocale.listalltext": "Я ведаю:", "jetkarmabot.changelocale.errorall": "Мне б хацелася гаварыць на ўсіх мовах у той жа самы час, але з-за абмежаванняў сусвету, мне гэта не дазваляецца.", "jetkarmabot.changelocale.beforenote": "Увага: ", - "jetkarmabot.help": "TODO TODO TODO TODO" + "jetkarmabot.changelocale.help": "", + "jetkarmabot.changelocale.localehelp": "", + "jetkarmabot.help.help": "", + "jetkarmabot.help.commandhelp": "" } } \ No newline at end of file diff --git a/JetKarmaBot/lang/en-US.json b/JetKarmaBot/lang/en-US.json index b550268..f3eecd2 100644 --- a/JetKarmaBot/lang/en-US.json +++ b/JetKarmaBot/lang/en-US.json @@ -12,14 +12,21 @@ "jetkarmabot.award.awardmessage": "Awarded a {0} to {1}!", "jetkarmabot.award.revokemessage": "Revoked a {0} from {1}!", "jetkarmabot.award.statustext": "{0} is at {1}{2} now.", + "jetkarmabot.award.help": "Awards/revokes an award to a user.", + "jetkarmabot.award.awardtypehelp": "The award to grant to/strip of the specified user", "jetkarmabot.status.listalltext": "Your badges report:", "jetkarmabot.status.listspecifictext": "You are at {0}{1} now.", "jetkarmabot.status.havenothing": "You don't have anything yet.", + "jetkarmabot.status.help": "Shows the amount of awards that you have", + "jetkarmabot.status.awardtypehelp": "The awardtype to show. If empty shows everything.", "jetkarmabot.changelocale.justchanged": "Roger that.", "jetkarmabot.changelocale.getlocale": "I'm currently speaking English.", "jetkarmabot.changelocale.listalltext": "I know:", "jetkarmabot.changelocale.errorall": "I would like to speak all languages at once, but because of the rules of the universe, I am not allowed to do that.", "jetkarmabot.changelocale.beforenote": "Warning: ", - "jetkarmabot.help": "TODO TODO TODO TODO" + "jetkarmabot.changelocale.help": "Switches current chat locale to [locale]", + "jetkarmabot.changelocale.localehelp": "The locale to switch to. Can be \"list\" to list all possible locales. Also can be empty to get current locale", + "jetkarmabot.help.help": "Displays help text for all(one) command(s)", + "jetkarmabot.help.commandhelp": "The command to return help text for. If empty shows all commands." } } \ No newline at end of file diff --git a/JetKarmaBot/lang/ru-RU.json b/JetKarmaBot/lang/ru-RU.json index 7c744c5..83b7b90 100644 --- a/JetKarmaBot/lang/ru-RU.json +++ b/JetKarmaBot/lang/ru-RU.json @@ -12,14 +12,21 @@ "jetkarmabot.award.awardmessage": "Вручил \"{0}\" {1}!", "jetkarmabot.award.revokemessage": "Отнял \"{0}\" у {1}!", "jetkarmabot.award.statustext": "У {0} теперь {1}{2}.", + "jetkarmabot.award.help": "Поручает/лишает награду от ползователя/пользователю.", + "jetkarmabot.award.awardtypehelp": "Награду которую поручить/лишить от пользователя", "jetkarmabot.status.listalltext": "У вас :", "jetkarmabot.status.listspecifictext": "У вас сейчас {0}{1}.", "jetkarmabot.status.havenothing": "У вас пока ничего нет.", + "jetkarmabot.status.help": "", + "jetkarmabot.status.awardtypehelp": "", "jetkarmabot.changelocale.justchanged": "Так точно.", "jetkarmabot.changelocale.getlocale": "Я сейчас говорю по-русски.", "jetkarmabot.changelocale.listalltext": "Я знаю:", "jetkarmabot.changelocale.errorall": "Мне бы хотелось говорить на всех языках в то же самое время, но из-за ограничений вселенной, мне это не позволяется.", "jetkarmabot.changelocale.beforenote": "Внимание: ", - "jetkarmabot.help": "TODO TODO TODO TODO" + "jetkarmabot.changelocale.help": "", + "jetkarmabot.changelocale.localehelp": "", + "jetkarmabot.help.help": "", + "jetkarmabot.help.commandhelp": "" } } \ No newline at end of file