diff --git a/README.md b/README.md index d4fd43a1..e339dcb9 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ In order to use Long Polling mode, just create your own bot extending `org.teleg If you like to use Webhook, extend `org.telegram.telegrambots.bots.TelegramWebhookBot` -Once done, you just need to creat a `org.telegram.telegrambots.TelegramBotsApi`and register your bots: +Once done, you just need to create a `org.telegram.telegrambots.TelegramBotsApi`and register your bots: ```java diff --git a/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java b/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java index fba5b986..f9f8091f 100644 --- a/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java +++ b/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java @@ -14,7 +14,7 @@ import java.util.function.BiConsumer; /** * This class adds command functionality to the TelegramLongPollingBot * - * @author tschulz + * @author Timo Schulz (Mit0x2) */ public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingBot implements ICommandRegistry { private final CommandRegistry commandRegistry; diff --git a/src/main/java/org/telegram/telegrambots/bots/commands/BotCommand.java b/src/main/java/org/telegram/telegrambots/bots/commands/BotCommand.java index f46e9a10..4b0935fa 100644 --- a/src/main/java/org/telegram/telegrambots/bots/commands/BotCommand.java +++ b/src/main/java/org/telegram/telegrambots/bots/commands/BotCommand.java @@ -1,12 +1,13 @@ 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; /** * Representation of a command, which can be executed * - * @author tschulz + * @author Timo Schulz (Mit0x2) */ public abstract class BotCommand { public final static String COMMAND_INIT_CHARACTER = "/"; @@ -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); } \ No newline at end of file diff --git a/src/main/java/org/telegram/telegrambots/bots/commands/CommandRegistry.java b/src/main/java/org/telegram/telegrambots/bots/commands/CommandRegistry.java index 6d2d3eb7..1cbafd7f 100644 --- a/src/main/java/org/telegram/telegrambots/bots/commands/CommandRegistry.java +++ b/src/main/java/org/telegram/telegrambots/bots/commands/CommandRegistry.java @@ -10,16 +10,15 @@ import java.util.Map; import java.util.function.BiConsumer; /** - * @author tschulz + * This class manages all the commands for a bot. You can register and deregister commands on demand + * + * @author Timo Schulz (Mit0x2) */ public final class CommandRegistry implements ICommandRegistry { private final Map commandRegistryMap = new HashMap<>(); private BiConsumer defaultConsumer; - public CommandRegistry() { - } - @Override public void registerDefaultAction(BiConsumer defaultConsumer) { this.defaultConsumer = defaultConsumer; @@ -87,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); diff --git a/src/main/java/org/telegram/telegrambots/bots/commands/ICommandRegistry.java b/src/main/java/org/telegram/telegrambots/bots/commands/ICommandRegistry.java index 676e1f8f..d6cd992c 100644 --- a/src/main/java/org/telegram/telegrambots/bots/commands/ICommandRegistry.java +++ b/src/main/java/org/telegram/telegrambots/bots/commands/ICommandRegistry.java @@ -8,7 +8,9 @@ import java.util.Map; import java.util.function.BiConsumer; /** + * This Interface represents the gateway for registering and deregistering commands. * + * @author Timo Schulz (Mit0x2) */ public interface ICommandRegistry {