mirror of
https://github.com/Jetsparrow/karmabot.git
synced 2026-01-21 09:06:09 +03:00
pass through parsed string instead of sender to command
This commit is contained in:
parent
0bb9a58711
commit
1684b62e7d
@ -20,13 +20,13 @@ namespace JetKarmaBot
|
|||||||
{
|
{
|
||||||
var text = args.Message.Text;
|
var text = args.Message.Text;
|
||||||
|
|
||||||
if (CommandString.TryParse(text, out var cs))
|
if (CommandString.TryParse(text, out var cmd))
|
||||||
{
|
{
|
||||||
if (cs.UserName != null && cs.UserName != BotUser.Username) // directed not at us!
|
if (cmd.UserName != null && cmd.UserName != BotUser.Username) // directed not at us!
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (commands.ContainsKey(cs.Command))
|
if (commands.ContainsKey(cmd.Command))
|
||||||
return commands[cs.Command].Execute(sender,args);
|
return commands[cmd.Command].Execute(cmd, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -14,7 +14,7 @@ namespace JetKarmaBot.Commands
|
|||||||
{
|
{
|
||||||
public IReadOnlyCollection<string> Names => new[] { "award", "revoke"};
|
public IReadOnlyCollection<string> Names => new[] { "award", "revoke"};
|
||||||
|
|
||||||
public bool Execute(object sender, MessageEventArgs args)
|
public bool Execute(CommandString cmd, MessageEventArgs args)
|
||||||
{
|
{
|
||||||
if (args.Message.ReplyToMessage == null)
|
if (args.Message.ReplyToMessage == null)
|
||||||
{
|
{
|
||||||
@ -60,7 +60,7 @@ namespace JetKarmaBot.Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Inject(true)]Db Db { get; set; }
|
[Inject(true)] Db Db { get; set; }
|
||||||
[Inject(true)] TelegramBotClient Client { get; set; }
|
[Inject(true)] TelegramBotClient Client { get; set; }
|
||||||
User Me { get; }
|
User Me { get; }
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace JetKarmaBot.Commands
|
|||||||
public interface IChatCommand
|
public interface IChatCommand
|
||||||
{
|
{
|
||||||
IReadOnlyCollection<string> Names { get; }
|
IReadOnlyCollection<string> Names { get; }
|
||||||
bool Execute(object sender, MessageEventArgs messageEventArgs);
|
bool Execute(CommandString cmd, MessageEventArgs messageEventArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ namespace JetKarmaBot.Commands
|
|||||||
|
|
||||||
public IReadOnlyCollection<string> Names => new[] { "start" };
|
public IReadOnlyCollection<string> Names => new[] { "start" };
|
||||||
|
|
||||||
public bool Execute(object sender, MessageEventArgs args)
|
public bool Execute(CommandString cmd, MessageEventArgs args)
|
||||||
{
|
{
|
||||||
Db.AddChat(new Db.Chat { ChatId = args.Message.Chat.Id });
|
Db.AddChat(new Db.Chat { ChatId = args.Message.Chat.Id });
|
||||||
Db.AddUser(new Db.User { UserId = args.Message.From.Id });
|
Db.AddUser(new Db.User { UserId = args.Message.From.Id });
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user