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(BotCommand botCommand)
deregister a command
|
Map<BotCommand,Boolean> |
deregisterAll(BotCommand... 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() |
BotCommand |
getRegisteredCommand(String commandIdentifier)
get registered command
|
Collection<BotCommand> |
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(BotCommand botCommand)
register a command
|
Map<BotCommand,Boolean> |
registerAll(BotCommand... 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, onClosing
addStickerToSet, createNewStickerSet, downloadFile, downloadFile, downloadFileAsync, downloadFileAsync, getBaseUrl, getBotToken, sendApiMethod, sendApiMethodAsync, sendAudio, sendDocument, sendMediaGroup, sendPhoto, sendSticker, sendVideo, sendVideoNote, sendVoice, setChatPhoto, uploadStickerFile
answerCallbackQuery, 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, unpinChatMessage
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBotToken, onUpdatesReceived
public 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.LongPollingBot
protected 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(BotCommand botCommand)
ICommandRegistry
register
in interface ICommandRegistry
botCommand
- the command to registerpublic final Map<BotCommand,Boolean> registerAll(BotCommand... botCommands)
ICommandRegistry
registerAll
in interface ICommandRegistry
botCommands
- commands to registerpublic final boolean deregister(BotCommand botCommand)
ICommandRegistry
deregister
in interface ICommandRegistry
botCommand
- the command to deregisterpublic final Map<BotCommand,Boolean> deregisterAll(BotCommand... botCommands)
ICommandRegistry
deregisterAll
in interface ICommandRegistry
botCommands
- commands to deregisterpublic final Collection<BotCommand> getRegisteredCommands()
ICommandRegistry
getRegisteredCommands
in interface ICommandRegistry
public void registerDefaultAction(BiConsumer<AbsSender,org.telegram.telegrambots.api.objects.Message> defaultConsumer)
ICommandRegistry
registerDefaultAction
in interface ICommandRegistry
defaultConsumer
- Consumer to evaluate the messagepublic final BotCommand getRegisteredCommand(String commandIdentifier)
ICommandRegistry
getRegisteredCommand
in interface ICommandRegistry
public final String getBotUsername()
getBotUsername
in interface org.telegram.telegrambots.generics.LongPollingBot
public abstract void processNonCommandUpdate(org.telegram.telegrambots.api.objects.Update update)
update
- the updateCopyright © 2018. All rights reserved.