public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingBot implements ICommandRegistry
exe| Constructor and Description |
|---|
TelegramLongPollingCommandBot(DefaultBotOptions options,
boolean allowCommandsWithUsername,
String botUsername)
Creates a TelegramLongPollingCommandBot
Use ICommandRegistry's methods on this bot to register commands
|
TelegramLongPollingCommandBot(DefaultBotOptions options,
String botUsername)
Creates a TelegramLongPollingCommandBot with custom options and allowing commands with
usernames
Use ICommandRegistry's methods on this bot to register commands
|
TelegramLongPollingCommandBot(String botUsername)
Creates a TelegramLongPollingCommandBot using default options
Use ICommandRegistry's methods on this bot to register commands
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
deregister(IBotCommand botCommand)
deregister a command
|
Map<IBotCommand,Boolean> |
deregisterAll(IBotCommand... botCommands)
deregister multiple commands
|
protected boolean |
filter(org.telegram.telegrambots.api.objects.Message message)
Override this function in your bot implementation to filter messages with commands
|
String |
getBotUsername() |
IBotCommand |
getRegisteredCommand(String commandIdentifier)
get registered command
|
Collection<IBotCommand> |
getRegisteredCommands()
get a collection of all registered commands
|
void |
onUpdateReceived(org.telegram.telegrambots.api.objects.Update update) |
protected void |
processInvalidCommandUpdate(org.telegram.telegrambots.api.objects.Update update)
This method is called when user sends a not registered command.
|
abstract void |
processNonCommandUpdate(org.telegram.telegrambots.api.objects.Update update)
Process all updates, that are not commands.
|
boolean |
register(IBotCommand botCommand)
register a command
|
Map<IBotCommand,Boolean> |
registerAll(IBotCommand... botCommands)
register multiple commands
|
void |
registerDefaultAction(BiConsumer<AbsSender,org.telegram.telegrambots.api.objects.Message> defaultConsumer)
Register a default action when there is no command register that match the message sent
|
clearWebhook, onClosingaddStickerToSet, createNewStickerSet, downloadFile, downloadFile, downloadFileAsync, downloadFileAsync, getBaseUrl, getBotToken, sendApiMethod, sendApiMethodAsync, sendAudio, sendDocument, sendMediaGroup, sendPhoto, sendSticker, sendVideo, sendVideoNote, sendVoice, setChatPhoto, uploadStickerFileanswerCallbackQuery, answerCallbackQueryAsync, answerInlineQuery, answerInlineQueryAsync, answerPreCheckoutQuery, answerPreCheckoutQuery, answerShippingQuery, answerShippingQuery, deleteChatPhoto, deleteChatPhoto, deleteMessage, deleteMessage, deleteWebhook, deleteWebhook, editMessageCaption, editMessageCaptionAsync, editMessageReplyMarkup, editMessageReplyMarkup, editMessageText, editMessageTextAsync, execute, executeAsync, exportChatInviteLink, exportChatInviteLinkAsync, forwardMessage, forwardMessageAsync, getChat, getChatAdministrators, getChatAdministratorsAsync, getChatAsync, getChatMember, getChatMemberAsync, getChatMemberCount, getChatMemberCountAsync, getFile, getFileAsync, getGameHighScores, getGameHighScoresAsync, getMe, getMeAsync, getUserProfilePhotos, getUserProfilePhotosAsync, getWebhookInfo, getWebhookInfoAsync, kickMember, kickMemberAsync, leaveChat, leaveChatAsync, pinChatMessage, pinChatMessage, promoteChatMember, promoteChatMember, restrictChatMember, restrictChatMember, sendChatAction, sendChatActionAsync, sendContact, sendContactAsync, sendGame, sendGameAsync, sendInvoice, sendInvoice, sendLocation, sendLocationAsync, sendMessage, sendMessageAsync, sendVenue, sendVenueAsync, setChatDescription, setChatDescription, setChatTitle, setChatTitle, setGameScore, setGameScoreAsync, unbanMember, unbanMemberAsync, unpinChatMessage, unpinChatMessageclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBotToken, onUpdatesReceivedpublic TelegramLongPollingCommandBot(String botUsername)
botUsername - Username of the botpublic TelegramLongPollingCommandBot(DefaultBotOptions options, String botUsername)
options - Bot optionsbotUsername - Username of the botpublic TelegramLongPollingCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername, String botUsername)
options - Bot optionsallowCommandsWithUsername - true to allow commands with parameters (default),
false otherwisebotUsername - bot username of this botpublic final void onUpdateReceived(org.telegram.telegrambots.api.objects.Update update)
onUpdateReceived in interface org.telegram.telegrambots.generics.LongPollingBotprotected void processInvalidCommandUpdate(org.telegram.telegrambots.api.objects.Update update)
update - Received update from Telegramprotected boolean filter(org.telegram.telegrambots.api.objects.Message message)
For example, if you want to prevent commands execution incoming from group chat: # # return !message.getChat().isGroupChat(); #
message - Received messagepublic final boolean register(IBotCommand botCommand)
ICommandRegistryregister in interface ICommandRegistrybotCommand - the command to registerpublic final Map<IBotCommand,Boolean> registerAll(IBotCommand... botCommands)
ICommandRegistryregisterAll in interface ICommandRegistrybotCommands - commands to registerpublic final boolean deregister(IBotCommand botCommand)
ICommandRegistryderegister in interface ICommandRegistrybotCommand - the command to deregisterpublic final Map<IBotCommand,Boolean> deregisterAll(IBotCommand... botCommands)
ICommandRegistryderegisterAll in interface ICommandRegistrybotCommands - commands to deregisterpublic final Collection<IBotCommand> getRegisteredCommands()
ICommandRegistrygetRegisteredCommands in interface ICommandRegistrypublic void registerDefaultAction(BiConsumer<AbsSender,org.telegram.telegrambots.api.objects.Message> defaultConsumer)
ICommandRegistryregisterDefaultAction in interface ICommandRegistrydefaultConsumer - Consumer to evaluate the messagepublic final IBotCommand getRegisteredCommand(String commandIdentifier)
ICommandRegistrygetRegisteredCommand in interface ICommandRegistrypublic final String getBotUsername()
getBotUsername in interface org.telegram.telegrambots.generics.LongPollingBotpublic abstract void processNonCommandUpdate(org.telegram.telegrambots.api.objects.Update update)
update - the updateCopyright © 2018. All rights reserved.