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