Class TelegramLongPollingCommandBot
java.lang.Object
org.telegram.telegrambots.meta.bots.AbsSender
org.telegram.telegrambots.bots.DefaultAbsSender
org.telegram.telegrambots.bots.TelegramLongPollingBot
org.telegram.telegrambots.extensions.bots.commandbot.TelegramLongPollingCommandBot
- All Implemented Interfaces:
CommandBot,ICommandRegistry,org.telegram.telegrambots.meta.generics.LongPollingBot,org.telegram.telegrambots.meta.generics.TelegramBot
public abstract class TelegramLongPollingCommandBot
extends TelegramLongPollingBot
implements CommandBot, ICommandRegistry
This class adds command functionality to the TelegramLongPollingBot
- Author:
- Timo Schulz (Mit0x2)
-
Field Summary
Fields inherited from class org.telegram.telegrambots.bots.DefaultAbsSender
exe -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.TelegramLongPollingCommandBot(String botToken) Creates a TelegramLongPollingCommandBot using default options Use ICommandRegistry's methods on this bot to register commandsDeprecated.Use {#TelegramLongPollingBot(DefaultBotOptions, String)TelegramLongPollingCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername) Deprecated.Use {#TelegramLongPollingBot(DefaultBotOptions, boolean, String)TelegramLongPollingCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername, String botToken) Creates a TelegramLongPollingCommandBot Use ICommandRegistry's methods on this bot to register commandsTelegramLongPollingCommandBot(DefaultBotOptions options, String botToken) Creates a TelegramLongPollingCommandBot with custom options and allowing commands with usernames Use ICommandRegistry's methods on this bot to register commands -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanderegister(IBotCommand botCommand) deregister a commandfinal Map<IBotCommand,Boolean> deregisterAll(IBotCommand... botCommands) deregister multiple commandsabstract Stringfinal IBotCommandgetRegisteredCommand(String commandIdentifier) get registered commandfinal Collection<IBotCommand>get a collection of all registered commandsfinal voidonUpdateReceived(org.telegram.telegrambots.meta.api.objects.Update update) final booleanregister(IBotCommand botCommand) register a commandfinal Map<IBotCommand,Boolean> registerAll(IBotCommand... botCommands) register multiple commandsvoidregisterDefaultAction(BiConsumer<org.telegram.telegrambots.meta.bots.AbsSender, org.telegram.telegrambots.meta.api.objects.Message> defaultConsumer) Register a default action when there is no command register that match the message sentMethods inherited from class org.telegram.telegrambots.bots.TelegramLongPollingBot
clearWebhook, onClosingMethods inherited from class org.telegram.telegrambots.bots.DefaultAbsSender
downloadFile, downloadFile, downloadFile, downloadFile, downloadFileAsStream, downloadFileAsStream, downloadFileAsync, downloadFileAsync, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, getBaseUrl, getBotToken, getOptions, sendApiMethod, sendApiMethodAsync, sendApiMethodAsyncMethods inherited from class org.telegram.telegrambots.meta.bots.AbsSender
execute, executeAsync, executeAsync, getMe, getMeAsync, getMeAsync, getWebhookInfo, getWebhookInfoAsync, getWebhookInfoAsyncMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.telegram.telegrambots.extensions.bots.commandbot.CommandBot
filter, processInvalidCommandUpdate, processNonCommandUpdateMethods inherited from interface org.telegram.telegrambots.meta.generics.LongPollingBot
getOptions, onUpdatesReceivedMethods inherited from interface org.telegram.telegrambots.meta.generics.TelegramBot
getBotToken, onRegister
-
Constructor Details
-
TelegramLongPollingCommandBot
Deprecated.Use {#TelegramLongPollingBot(String)Creates a TelegramLongPollingCommandBot using default options Use ICommandRegistry's methods on this bot to register commands -
TelegramLongPollingCommandBot
Deprecated.Use {#TelegramLongPollingBot(DefaultBotOptions, String)Creates a TelegramLongPollingCommandBot with custom options and allowing commands with usernames Use ICommandRegistry's methods on this bot to register commands- Parameters:
options- Bot options
-
TelegramLongPollingCommandBot
@Deprecated public TelegramLongPollingCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername) Deprecated.Use {#TelegramLongPollingBot(DefaultBotOptions, boolean, String)Creates a TelegramLongPollingCommandBot Use ICommandRegistry's methods on this bot to register commands- Parameters:
options- Bot optionsallowCommandsWithUsername- true to allow commands with parameters (default), false otherwise
-
TelegramLongPollingCommandBot
Creates a TelegramLongPollingCommandBot using default options Use ICommandRegistry's methods on this bot to register commands -
TelegramLongPollingCommandBot
Creates a TelegramLongPollingCommandBot with custom options and allowing commands with usernames Use ICommandRegistry's methods on this bot to register commands- Parameters:
options- Bot options
-
TelegramLongPollingCommandBot
public TelegramLongPollingCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername, String botToken) Creates a TelegramLongPollingCommandBot Use ICommandRegistry's methods on this bot to register commands- Parameters:
options- Bot optionsallowCommandsWithUsername- true to allow commands with parameters (default), false otherwise
-
-
Method Details
-
onUpdateReceived
public final void onUpdateReceived(org.telegram.telegrambots.meta.api.objects.Update update) - Specified by:
onUpdateReceivedin interfaceorg.telegram.telegrambots.meta.generics.LongPollingBot
-
register
Description copied from interface:ICommandRegistryregister a command- Specified by:
registerin interfaceICommandRegistry- Parameters:
botCommand- the command to register- Returns:
- whether the command could be registered, was not already registered
-
registerAll
Description copied from interface:ICommandRegistryregister multiple commands- Specified by:
registerAllin interfaceICommandRegistry- Parameters:
botCommands- commands to register- Returns:
- map with results of the command register per command
-
deregister
Description copied from interface:ICommandRegistryderegister a command- Specified by:
deregisterin interfaceICommandRegistry- Parameters:
botCommand- the command to deregister- Returns:
- whether the command could be deregistered, was registered
-
deregisterAll
Description copied from interface:ICommandRegistryderegister multiple commands- Specified by:
deregisterAllin interfaceICommandRegistry- Parameters:
botCommands- commands to deregister- Returns:
- map with results of the command deregistered per command
-
getRegisteredCommands
Description copied from interface:ICommandRegistryget a collection of all registered commands- Specified by:
getRegisteredCommandsin interfaceICommandRegistry- Returns:
- a collection of registered commands
-
registerDefaultAction
public void registerDefaultAction(BiConsumer<org.telegram.telegrambots.meta.bots.AbsSender, org.telegram.telegrambots.meta.api.objects.Message> defaultConsumer) Description copied from interface:ICommandRegistryRegister a default action when there is no command register that match the message sent- Specified by:
registerDefaultActionin interfaceICommandRegistry- Parameters:
defaultConsumer- Consumer to evaluate the message
-
getRegisteredCommand
Description copied from interface:ICommandRegistryget registered command- Specified by:
getRegisteredCommandin interfaceICommandRegistry- Returns:
- registered command if exists or null if not
-
getBotUsername
- Specified by:
getBotUsernamein interfaceorg.telegram.telegrambots.meta.generics.TelegramBot- Returns:
- Bot username
-
#TelegramLongPollingBot(String)