mirror of
https://github.com/Jetsparrow/karmabot.git
synced 2026-01-21 00:56:09 +03:00
Start creating help command
This commit is contained in:
parent
fadd970c5d
commit
b93d20e07e
29
JetKarmaBot/Commands/HelpCommand.cs
Normal file
29
JetKarmaBot/Commands/HelpCommand.cs
Normal file
@ -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<string> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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<string> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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()));
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user