Add /currencies

Signed-off-by: Nikolay Kochulin <porez0xfeedface@gmail.com>
This commit is contained in:
Basique Evangelist 2019-04-18 17:28:20 +03:00
parent 86ab927005
commit 9b78abcd58
5 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,40 @@
using System.Collections.Generic;
using Telegram.Bot.Args;
using Perfusion;
using JetKarmaBot.Services;
using Telegram.Bot;
using Telegram.Bot.Types.Enums;
using System.Linq;
namespace JetKarmaBot.Commands
{
public class CurrenciesCommand : IChatCommand
{
[Inject] KarmaContextFactory Db;
[Inject] TelegramBotClient Client { get; set; }
[Inject] Localization Locale { get; set; }
public IReadOnlyCollection<string> Names => new[] { "currencies", "awardtypes" };
public string Description => "Shows all award types";
public string DescriptionID => "jetkarmabot.currencies.help";
public IReadOnlyCollection<ChatCommandArgument> Arguments => new ChatCommandArgument[] {
};
public bool Execute(CommandString cmd, MessageEventArgs args)
{
using (var db = Db.GetContext())
{
var currentLocale = Locale[db.Chats.Find(args.Message.Chat.Id).Locale];
string resp = currentLocale["jetkarmabot.currencies.listtext"] + "\n" + string.Join("\n",
db.AwardTypes.ToList().Select(x => $"{x.Symbol} ({x.CommandName}) - {currentLocale["jetkarmabot.awardtypes." + x.CommandName]}"));
Client.SendTextMessageAsync(
args.Message.Chat.Id,
resp,
replyToMessageId: args.Message.MessageId,
parseMode: ParseMode.Html);
return true;
}
}
}
}

View File

@ -77,6 +77,7 @@ namespace JetKarmaBot
Commands.Add(c.ResolveObject(new AwardCommand(Me)));
Commands.Add(c.ResolveObject(new StatusCommand()));
Commands.Add(c.ResolveObject(new LocaleCommand()));
Commands.Add(c.ResolveObject(new CurrenciesCommand()));
}
#endregion

View File

@ -29,6 +29,8 @@
"jetkarmabot.changelocale.localehelp": "Новая лакаль, альбо каманда list - спіс перакладаў. Калі пуста - паказваецца бягучая лакаль.",
"jetkarmabot.help.help": "Паказвае інструкцыю да каманды, ці спіс каманд.",
"jetkarmabot.help.commandhelp": "Каманда, да якой трэба паказаць інструкцыю. Калі пуста, то паказваецца спіс каманд.",
"jetkarmabot.currencies.help": "Паказвае ўсе тыпы узнагарод",
"jetkarmabot.currencies.listtext": "Тыпы узнагарод:",
"jetkarmabot.awardtypes.star": "Зорачка",
"jetkarmabot.awardtypes.pie": "з паліцы піражок",
"jetkarmabot.awardtypes.dream": "Мара",

View File

@ -28,6 +28,8 @@
"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.",
"jetkarmabot.currencies.help": "Shows all award types",
"jetkarmabot.currencies.listtext": "Award types:",
"jetkarmabot.awardtypes.star": "Star",
"jetkarmabot.awardtypes.pie": "a pie from the shelf",
"jetkarmabot.awardtypes.dream": "Dream",

View File

@ -28,6 +28,8 @@
"jetkarmabot.changelocale.localehelp": "Новая локаль, либо команда list - список переводов. Если пусто - показывается текущая локаль.",
"jetkarmabot.help.help": "Показывает инструкцию к команде, или список команд.",
"jetkarmabot.help.commandhelp": "Команда, к которой нужно показать инструкцию. Если пусто, то показывается список команд.",
"jetkarmabot.currencies.help": "Показывает все типы наград",
"jetkarmabot.currencies.listtext": "Типы наград:",
"jetkarmabot.awardtypes.star": "звездочку",
"jetkarmabot.awardtypes.pie": "с полки пирожок",
"jetkarmabot.awardtypes.dream": "мечту",