public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingBot implements ICommandRegistry
| Constructor and Description |
|---|
TelegramLongPollingCommandBot()
Creates a TelegramLongPollingCommandBot using default options
Use ICommandRegistry's methods on this bot to register commands
|
TelegramLongPollingCommandBot(DefaultBotOptions options)
Creates a TelegramLongPollingCommandBot with custom options and allowing commands with
usernames
Use ICommandRegistry's methods on this bot to register commands
|
TelegramLongPollingCommandBot(DefaultBotOptions options,
boolean allowCommandsWithUsername)
Creates a TelegramLongPollingCommandBot
Use ICommandRegistry's methods on this bot to register commands
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
deregister(BotCommand botCommand)
deregister a command
|
Map<BotCommand,Boolean> |
deregisterAll(BotCommand... botCommands)
deregister multiple commands
|
protected boolean |
filter(Message message)
Override this function in your bot implementation to filter messages with commands
For example, if you want to prevent commands execution incoming from group chat:
#
# return !message.getChat().isGroupChat();
#
|
BotCommand |
getRegisteredCommand(String commandIdentifier)
get registered command
|
Collection<BotCommand> |
getRegisteredCommands()
get a collection of all registered commands
|
void |
onUpdateReceived(Update update) |
abstract void |
processNonCommandUpdate(Update update)
Process all updates, that are not commands.
|
boolean |
register(BotCommand botCommand)
register a command
|
Map<BotCommand,Boolean> |
registerAll(BotCommand... botCommands)
register multiple commands
|
void |
registerDefaultAction(BiConsumer<AbsSender,Message> defaultConsumer)
Register a default action when there is no command register that match the message sent
|
clearWebhookdownloadFile, downloadFile, downloadFileAsync, downloadFileAsync, getBotToken, getOptions, sendApiMethod, sendApiMethodAsync, sendAudio, sendDocument, sendPhoto, sendSticker, sendVideo, sendVoiceanswerCallbackQuery, answerCallbackQueryAsync, answerInlineQuery, answerInlineQueryAsync, deleteWebhook, deleteWebhook, editMessageCaption, editMessageCaptionAsync, editMessageReplyMarkup, editMessageReplyMarkup, editMessageText, editMessageTextAsync, forwardMessage, forwardMessageAsync, getChat, getChatAdministrators, getChatAdministratorsAsync, getChatAsync, getChatMember, getChatMemberAsync, getChatMemberCount, getChatMemberCountAsync, getFile, getFileAsync, getGameHighScores, getGameHighScoresAsync, getMe, getMeAsync, getUserProfilePhotos, getUserProfilePhotosAsync, getWebhookInfo, getWebhookInfoAsync, kickMember, kickMemberAsync, leaveChat, leaveChatAsync, sendChatAction, sendChatActionAsync, sendContact, sendContactAsync, sendGame, sendGameAsync, sendLocation, sendLocationAsync, sendMessage, sendMessageAsync, sendVenue, sendVenueAsync, setGameScore, setGameScoreAsync, unbanMember, unbanMemberAsyncclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBotToken, getBotUsername, getOptions, onClosingpublic TelegramLongPollingCommandBot()
public TelegramLongPollingCommandBot(DefaultBotOptions options)
options - Bot optionspublic TelegramLongPollingCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername)
options - Bot optionsallowCommandsWithUsername - true to allow commands with parameters (default),
false otherwisepublic final void onUpdateReceived(Update update)
onUpdateReceived in interface LongPollingBotprotected boolean filter(Message message)
message - Received messagepublic final boolean register(BotCommand botCommand)
ICommandRegistryregister in interface ICommandRegistrybotCommand - the command to registerpublic final Map<BotCommand,Boolean> registerAll(BotCommand... botCommands)
ICommandRegistryregisterAll in interface ICommandRegistrybotCommands - commands to registerpublic final boolean deregister(BotCommand botCommand)
ICommandRegistryderegister in interface ICommandRegistrybotCommand - the command to deregisterpublic final Map<BotCommand,Boolean> deregisterAll(BotCommand... botCommands)
ICommandRegistryderegisterAll in interface ICommandRegistrybotCommands - commands to deregisterpublic final Collection<BotCommand> getRegisteredCommands()
ICommandRegistrygetRegisteredCommands in interface ICommandRegistrypublic void registerDefaultAction(BiConsumer<AbsSender,Message> defaultConsumer)
ICommandRegistryregisterDefaultAction in interface ICommandRegistrydefaultConsumer - Consumer to evaluate the messagepublic final BotCommand getRegisteredCommand(String commandIdentifier)
ICommandRegistrygetRegisteredCommand in interface ICommandRegistrypublic abstract void processNonCommandUpdate(Update update)
update - the updateCopyright © 2017. All rights reserved.