Class TelegramWebhookCommandBot
- java.lang.Object
-
- org.telegram.telegrambots.meta.bots.AbsSender
-
- org.telegram.telegrambots.bots.DefaultAbsSender
-
- org.telegram.telegrambots.bots.TelegramWebhookBot
-
- org.telegram.telegrambots.extensions.bots.commandbot.TelegramWebhookCommandBot
-
- All Implemented Interfaces:
CommandBot,ICommandRegistry,org.telegram.telegrambots.meta.generics.TelegramBot,org.telegram.telegrambots.meta.generics.WebhookBot
public abstract class TelegramWebhookCommandBot extends TelegramWebhookBot implements CommandBot, ICommandRegistry
This class adds command functionality to the TelegramWebhookBot- Author:
- Andrey Korsakov (loolzaaa)
-
-
Field Summary
-
Fields inherited from class org.telegram.telegrambots.bots.DefaultAbsSender
exe
-
-
Constructor Summary
Constructors Constructor Description TelegramWebhookCommandBot()Creates a TelegramWebhookCommandBot using default options Use ICommandRegistry's methods on this bot to register commandsTelegramWebhookCommandBot(DefaultBotOptions options)Creates a TelegramWebhookCommandBot with custom options and allowing commands with usernames Use ICommandRegistry's methods on this bot to register commandsTelegramWebhookCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername)Creates a TelegramWebhookCommandBot Use ICommandRegistry's methods on this bot to register commands
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanderegister(IBotCommand botCommand)deregister a commandMap<IBotCommand,Boolean>deregisterAll(IBotCommand... botCommands)deregister multiple commandsIBotCommandgetRegisteredCommand(String commandIdentifier)get registered commandCollection<IBotCommand>getRegisteredCommands()get a collection of all registered commandsorg.telegram.telegrambots.meta.api.methods.BotApiMethod<?>onWebhookUpdateReceived(org.telegram.telegrambots.meta.api.objects.Update update)booleanregister(IBotCommand botCommand)register a commandMap<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 sent-
Methods inherited from class org.telegram.telegrambots.bots.TelegramWebhookBot
setWebhook
-
Methods 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, sendApiMethodAsync
-
Methods inherited from class org.telegram.telegrambots.meta.bots.AbsSender
execute, executeAsync, executeAsync, getMe, getMeAsync, getMeAsync, getWebhookInfo, getWebhookInfoAsync, getWebhookInfoAsync
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.telegram.telegrambots.extensions.bots.commandbot.CommandBot
filter, processInvalidCommandUpdate, processNonCommandUpdate
-
-
-
-
Constructor Detail
-
TelegramWebhookCommandBot
public TelegramWebhookCommandBot()
Creates a TelegramWebhookCommandBot using default options Use ICommandRegistry's methods on this bot to register commands
-
TelegramWebhookCommandBot
public TelegramWebhookCommandBot(DefaultBotOptions options)
Creates a TelegramWebhookCommandBot with custom options and allowing commands with usernames Use ICommandRegistry's methods on this bot to register commands- Parameters:
options- Bot options
-
TelegramWebhookCommandBot
public TelegramWebhookCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername)
Creates a TelegramWebhookCommandBot Use ICommandRegistry's methods on this bot to register commands- Parameters:
options- Bot optionsallowCommandsWithUsername- true to allow commands with parameters (default), false otherwise
-
-
Method Detail
-
onWebhookUpdateReceived
public org.telegram.telegrambots.meta.api.methods.BotApiMethod<?> onWebhookUpdateReceived(org.telegram.telegrambots.meta.api.objects.Update update)
- Specified by:
onWebhookUpdateReceivedin interfaceorg.telegram.telegrambots.meta.generics.WebhookBot
-
register
public final boolean register(IBotCommand botCommand)
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
public final Map<IBotCommand,Boolean> registerAll(IBotCommand... botCommands)
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
public final boolean deregister(IBotCommand botCommand)
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
public final Map<IBotCommand,Boolean> deregisterAll(IBotCommand... botCommands)
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
public final Collection<IBotCommand> 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
public final IBotCommand getRegisteredCommand(String commandIdentifier)
Description copied from interface:ICommandRegistryget registered command- Specified by:
getRegisteredCommandin interfaceICommandRegistry- Returns:
- registered command if exists or null if not
-
-