Add sender of the command to the execute method signature, to be able to do sth with it's data (e.g. userId)

This commit is contained in:
Timo Schulz 2016-05-31 19:57:54 +02:00
parent 01f321d917
commit 3a41c3fd5e
2 changed files with 4 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package org.telegram.telegrambots.bots.commands;
import org.telegram.telegrambots.api.objects.Chat;
import org.telegram.telegrambots.api.objects.User;
import org.telegram.telegrambots.bots.AbsSender;
/**
@ -69,8 +70,9 @@ public abstract class BotCommand {
* Execute the command
*
* @param absSender absSender to send messages over
* @param user the user who sent the command
* @param chat the chat, to be able to send replies
* @param arguments passed arguments
*/
public abstract void execute(AbsSender absSender, Chat chat, String[] arguments);
public abstract void execute(AbsSender absSender, User user, Chat chat, String[] arguments);
}

View File

@ -86,7 +86,7 @@ public final class CommandRegistry implements ICommandRegistry {
if (commandRegistryMap.containsKey(command)) {
String[] parameters = Arrays.copyOfRange(commandSplit, 1, commandSplit.length);
commandRegistryMap.get(command).execute(absSender, message.getChat(), parameters);
commandRegistryMap.get(command).execute(absSender, message.getFrom(), message.getChat(), parameters);
return true;
} else if (defaultConsumer != null) {
defaultConsumer.accept(absSender, message);