Class TelegramWebhookCommandBot
Object
DefaultTelegramWebhookBot
TelegramWebhookCommandBot
- All Implemented Interfaces:
CommandBot,ICommandRegistry,TelegramWebhookBot
public abstract class TelegramWebhookCommandBot
extends DefaultTelegramWebhookBot
implements CommandBot, ICommandRegistry
This class adds command functionality to the TelegramWebhookBot
- Author:
- Andrey Korsakov (loolzaaa)
-
Nested Class Summary
Nested classes/interfaces inherited from class DefaultTelegramWebhookBot
DefaultTelegramWebhookBot.DefaultTelegramWebhookBotBuilder -
Constructor Summary
ConstructorsConstructorDescriptionTelegramWebhookCommandBot(TelegramClient telegramClient, boolean allowCommandsWithUsername, Supplier<String> botUsernameSupplier, String botPath, Runnable setWebhook, Runnable deleteWebhook) Creates a TelegramWebhookCommandBot Use ICommandRegistry's methods on this bot to register commands -
Method Summary
Modifier and TypeMethodDescriptionBotApiMethod<?>consumeUpdate(Update update) final booleanderegister(IBotCommand botCommand) deregister a commandfinal Map<IBotCommand,Boolean> deregisterAll(IBotCommand... botCommands) deregister multiple commandsfinal IBotCommandgetRegisteredCommand(String commandIdentifier) get registered commandfinal Collection<IBotCommand>get a collection of all registered commandsfinal booleanregister(IBotCommand botCommand) register a commandfinal Map<IBotCommand,Boolean> registerAll(IBotCommand... botCommands) register multiple commandsvoidregisterDefaultAction(BiConsumer<TelegramClient, Message> defaultConsumer) Register a default action when there is no command register that match the message sentMethods inherited from class DefaultTelegramWebhookBot
builder, canEqual, equals, getBotPath, getDeleteWebhook, getSetWebhook, getUpdateHandler, hashCode, runDeleteWebhook, runSetWebhook, toStringMethods inherited from interface CommandBot
filter, processInvalidCommandUpdate, processNonCommandUpdate
-
Constructor Details
-
TelegramWebhookCommandBot
public TelegramWebhookCommandBot(TelegramClient telegramClient, boolean allowCommandsWithUsername, Supplier<String> botUsernameSupplier, String botPath, Runnable setWebhook, Runnable deleteWebhook) Creates a TelegramWebhookCommandBot Use ICommandRegistry's methods on this bot to register commands- Parameters:
telegramClient- Telegram client used to send requestsallowCommandsWithUsername- true to allow commands with parameters (default), false otherwisebotUsernameSupplier- Bot username supplierbotPath- Bot Path for the webhooksetWebhook- Set webhook method executiondeleteWebhook- Delete webhook method execution
-
-
Method Details
-
consumeUpdate
public BotApiMethod<?> consumeUpdate(Update update) - Specified by:
consumeUpdatein interfaceTelegramWebhookBot- Overrides:
consumeUpdatein classDefaultTelegramWebhookBot
-
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
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
-