From a24c147a17409df101212487e523c208687939d8 Mon Sep 17 00:00:00 2001 From: dartwata Date: Thu, 14 Jul 2016 12:49:06 +0800 Subject: [PATCH] get registered command by commandIdentifier --- .../telegrambots/bots/TelegramLongPollingCommandBot.java | 5 +++++ .../telegrambots/bots/commands/CommandRegistry.java | 5 +++++ .../telegrambots/bots/commands/ICommandRegistry.java | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java b/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java index f9f8091f..db39d8c4 100644 --- a/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java +++ b/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingCommandBot.java @@ -71,6 +71,11 @@ public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingB commandRegistry.registerDefaultAction(defaultConsumer); } + @Override + public final BotCommand getRegisteredCommand(String commandIdentifier) { + return commandRegistry.getRegisteredCommand(commandIdentifier); + } + /** * Process all updates, that are not commands. * @warning Commands that have valid syntax but are not registered on this bot, 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 1cbafd7f..bdc75e6d 100644 --- a/src/main/java/org/telegram/telegrambots/bots/commands/CommandRegistry.java +++ b/src/main/java/org/telegram/telegrambots/bots/commands/CommandRegistry.java @@ -65,6 +65,11 @@ public final class CommandRegistry implements ICommandRegistry { return commandRegistryMap.values(); } + @Override + public final BotCommand getRegisteredCommand(String commandIdentifier) { + return commandRegistryMap.get(commandIdentifier); + } + /** * Executes a command action if the command is registered. * 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 d6cd992c..56ae4c6c 100644 --- a/src/main/java/org/telegram/telegrambots/bots/commands/ICommandRegistry.java +++ b/src/main/java/org/telegram/telegrambots/bots/commands/ICommandRegistry.java @@ -62,4 +62,10 @@ public interface ICommandRegistry { */ Collection getRegisteredCommands(); + /** + * get registered command + * + * @return registered command if exists or null if not + */ + BotCommand getRegisteredCommand(String commandIdentifier); } \ No newline at end of file