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
4947351b89
commit
37236d50ff
@ -20,13 +20,13 @@ namespace JetKarmaBot
|
||||
{
|
||||
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;
|
||||
|
||||
if (commands.ContainsKey(cs.Command))
|
||||
return commands[cs.Command].Execute(sender,args);
|
||||
if (commands.ContainsKey(cmd.Command))
|
||||
return commands[cmd.Command].Execute(cmd, args);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -14,7 +14,7 @@ namespace JetKarmaBot.Commands
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@ namespace JetKarmaBot.Commands
|
||||
public interface IChatCommand
|
||||
{
|
||||
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 bool Execute(object sender, MessageEventArgs args)
|
||||
public bool Execute(CommandString cmd, MessageEventArgs args)
|
||||
{
|
||||
Db.AddChat(new Db.Chat { ChatId = args.Message.Chat.Id });
|
||||
Db.AddUser(new Db.User { UserId = args.Message.From.Id });
|
||||
|
||||
Loading…
Reference in New Issue
Block a user